Get List of Countries - virtocommerce

Not seeing the country list in the database nor any settings around them.
I'm writing a custom shipping methods module and need to convert the three character country code into the two character code.
What is the best way to get the list of countries for use server side?

Unfortunately VC does not contains countries resources for using from server side code. But I would to suggest for you to include this countries JSON from our storefront GitHub repository as embedded resource into your module project and read it as described here.

Related

REST API Resource Granularity

I wanted to get opinion on resource granularity. Say, I have a an domain entity called "magazines". But there are different types of magazines, including Sports, Nature, Automobiles, Computers and Aeroplanes, etc.
When I want to create a new "sports" magazine, should I be using construct such as:
PUT /magazines
PUT /sports-magazines
PUT /magazines/sports
When I want to get a specific sports magazine, should I be saying:
GET /magazines/{id}
GET /sports-magazines/{id}
GET /magazines/sports/{id}
If I want to get sports magazines for the year 2001, should I be using:
GET /magazines?type=sports&year=2001
GET /sports-magazines?year=2001
GET /magazines/sports?year=2001
And finally, if I want to return how many pages each type of magazine has for January 2001 publication, how would I do that? Do I need to create a new pages resource for that? Or make two independent requests or something else? First of these is listed below:
GET /magazines/pages?type1=sports&type2=nature&year=2001&month=01
GET /sports-magazines/pages?type=nature&year=2001&month=01
Given these scenarios how would you model your resources?
I have a an domain entity called "magazines". But there are different types of magazines, including Sports, Nature, Automobiles, Computers and Aeroplanes, etc.
Important thing to understand: resources aren't domain entities. Your resource model is a facade that sits in front of your domain model.
Notice, for example, that this resource (REST API Resource Granularity) describes not only your question, but also my answer.
PUT probably is NOT what you want for "create a new resource" unless the client is already in position to know what URI should be used for the new resource. The target URI of a PUT request is the same URI that we expect to use later to GET the data
PUT /magazines/{id}
GET /magazines/{id}
In the case where we don't expect the client to know what the URI is going to be... well, we don't have an HTTP method that means precisely that, so we fall back to using POST (see Fielding, 2009).
POST /magazines
201 Created
Location: /magazines/12345
Note that the machines don't care if the URI of the created resource(s) match the target URI of the POST request.
REST really doesn't care what spelling conventions you use for your resource identifiers (in much the same way that the machines don't care what spelling conventions you use for variable names).
GET /magazines?type=sports&year=2001
GET /sports-magazines?year=2001
GET /magazines/sports?year=2001
GET /magazines/sports/year=2001
GET /magazines/sports/2001
Those are all fine; there are trade-offs. Key value pairs encoded into a query string make creating URI with HTML forms easier, using path segments makes relative resolution easier.
I want to return how many pages each type of magazine has for January 2001 publication
Creating a new URI with that information is fine. Extending the schema of your existing resources to include that information is also fine.

Is it possible to have custom content types in big commerce?

For a bigcommerce site I'm working on we will need to have custom content types or something similar that would accomplish the same goal.
One example is we need a way for the admin to arbitrarily add locations that have the following fields: latitude, longitude, as well as text fields for facts.
I saw that there were ways that you could add ui fields to products
https://developer.bigcommerce.com/stencil-docs/configure-store-design-ui/defining-ui-options
But what I want to create is not a product. I want various types of posts with their own set of fields. Basically the same kind of features I would be able to find in something like Drupal.
Edit: Also I cannot use any outside cms. It can only be the bigcommerce cms alone

In magento 2, zip code text box to search the store available or not

I am new to Magento.
I want a text box where i can type the zip code and if the store available in that location then i need to show the products of that particular store otherwise we need to show that "the store is not available in particular location".
The following is the example site. i want it as it is.
this site prompts for users zip location .after it will display stores of that particular.
Click on this link to see the working example
how do i do this . Do i need to install a module ?
Follow Some Steps:
You need an entity 'store' that is bound to a geo location.
You need to create a multi select attribute which values are located (using a
source model) with these stores. This way, you can attach a single product to
multiple stores (one to many relation)
Then you need some sort of external API to convert a postcode entered by the
customer to a geo location. I assume the Google Maps API can do this. It would
be best to handle this server side.
Then you need the math to calculate the distance between 2 geo locations in
your database query (probably enough to find on that subject on Google) and
filter your product collection on that.
Once you have the collection you have the power.
The external API will probably have a request threshold so you might have to
pay for that (depending on the traffic).
You need to determine the radius of maximum distance between 2 geo locations.
In a small country like the Netherlands stores could be a couple of km's apart
from each other, whilst in the United States it's not uncommon to have stores
tens or hundreds of km's from each other.
**Best Of Luck For Your Project**

Get a list of Sprints using YouTrack REST API

I am creating a C# tool that pulls information from YouTrack using the REST API. I am looking for a way to get a list of the sprints that have been created. Is there a way to easily get this information through the REST API? Worst case I could get the list of issues and parse through all of them to collect all of the available sprints, but there has to be an easier way.
Version 5 changed the agile method. The new agile method is returned with the following command:
{baseUrl}/rest/agile/{agileID}/sprints
I had to get the list of the Agile ID's to use in the above url using the following command:
{baseUrl}/rest/agile/agiles
This now gives a list of all the agile boards and using the 'id' element in the first command above will return the list of sprints for that agile board. The AgileID's are returned something like 'myprojectname-99'. I found that if you just use the numeric number at the end of the ID, that will also work instead of using the full agile name.
I found a much simpler way to get the sprints:
{baseUrl}/rest/agile/{projectName}/sprints?"
This gives an XML with all of the sprints for that project and their start/end dates.
What you request can be obtained by GET {youtrac.base.url}/rest/admin/customfield/versionBundle/{bundleName}. To find out {bundleName}, go to agile settings and have a look at 'Field to identify sprints:' setting which gives you the field name. For this field, in Administration you can locate the name of the bundle.
{baseUrl}/rest/agile/{projectName}/sprints? is only working if the name of the agile board is the same as the projectName!!!
The API is: {baseUrl}/rest/agile/{agileName}/sprints?

Structured data in Joomla

I'm currently developing a back-end for chefs at various restaurants to report their daily menues in a structured format. Of pragmatic reasons have I chosen to use a web CMS and use many of the features already include including a flexible rights-management module
I want to utilise the existing functions in Joomla for access control, editing and navigation, but I need to replace the textfield with five field (each representing one day of the working week) and save this in a structured way into the database. I was planning to create a editor plugin which displays the field for the chef-users and parse the in-data into a structured data-format e.g. XML. For each week I will need to create empty templates for all the restaurants displaying the week number and dates.
I was also hoping for third-party developers to access this data through RESTful methods in the URL where the structure could be something like: http://domain.no/restaurant-name/menu for a text-menu http://domain.no/restaurant-name/json for json etc.
I guess my question is how I can start developing such features. Has there been developed anything similar and are there modules developed for Joomla which I can utilise? Does my approach sounds sensible or are there any other good way of solving my problem?
For a custom content management i would use Zoo component from Yootheme (not free!). You can define your fields,
But for developers access, i have no idea, sorry!