2.8 KiB
2.8 KiB
This service is used to obtain the regions of the indicated country.
GET:
URL_BASE + /ws/util.py/regions
Receives:
All parameters are sent in the querystring of the call, so a percentage encoding for URI must be applied (aka URL encoding).
Returns:
Depending on the result of the operation, this service can return two different JSON:
Answer JSON OK:
{
"status"
: <boolean>
,
"regions"
:{' '}
[
{
"name"
: <string>
,
"region_id"
: <integer>
}
]
,
"elapsed"
: <float>
}
Where:
status:Shows if the call has been successful (true) or not (false).regions:List of regions.name:Name of the regionregion_id:Identifier of the region.elapsed:Operation execution time.
Answer JSON KO:
{
"status"
:{' '}
false
,
"level"
: <string>
,
"message"
: <string>
,
"error"
: <string>
}
Where:
status:Shows if the call has been successful (true) or not (false).level:Error importance levelmessage:Error message.error:Sole error code.
Example requests:
Python - Requests:
import requests
url ={' '}
"URL_BASE/ws/util.py/regions?county_code=MX"
payload ={' '}
{
}
headers={' '}
{
}
response = requests
.request
(
"GET"
, url
, headers
=headers
, data{' '}
= payload
)
print
(response
.text
.encode
(
'utf8'
)
)
NodeJs - Request:
var request = require('request');
var options = {
'method': 'GET',
'url': 'URL_BASE/ws/util.py/regions?county_code=MX',
'headers': {}
};
request(options, function (error, response) {{' '}
if (error) throw new Error(error);
console.log(response.body);
});
JavaScript - Fetch:
var requestOptions = {
method: 'GET',
redirect: 'follow'
};
fetch("URL_BASE/ws/util.py/regions?county_code=MX",
requestOptions)
.then(response => response.text())
.then(result => console.log(result))
.catch(error => console.log('error', error));
CURL:
curl --location --request GET{' '}
'URL_BASE/ws/util.py/regions?county_code=MX'
Business logic:
By means of this service all the regions of the indicated country are obtained.