assistance-engine/docs/developer.avapframework.com/Obtener_Paises_Activos_EN.md

4.7 KiB

This service is used to obtain the active countries in the system.

GET: URL_BASE + /ws/util.py/countries

Returns:

Depending on the result of the operation, this service can return two different JSON:

Answer JSON OK:

{
         "status"
        :{' '}
        true
        ,
         "countries"
        :{' '}
        [
         {
         "currency_symbol"
        :{' '}
        "$ "
        ,
         "currency_data"
        :{' '}
        {
         "abbreviation"
        :{' '}
        "MXN"
        ,
         "suffix"
        :{' '}
        "pesos"
        ,
         "format"
        :{' '}
        "$%.2f pesos"
        ,
         "symbol"
        :{' '}
        "$"
        ,
         "prefix"
        :{' '}
        "$"
        ,
         "decimals"
        :{' '}
        2.0
        ,
         "id"
        :{' '}
        70
         }
        ,
         "currency_format"
        :{' '}
        "$%.2f pesos"
        ,
         "precision_currency"
        :{' '}
        2.0
        ,
         "phone_longitude"
        :{' '}
        10
        ,
         "currency"
        :{' '}
        "Mexico Peso"
        ,
         "name"
        :{' '}
        "Mexico"
        ,
         "prefix"
        :{' '}
        "52"
        ,
         "phone"
        :{' '}
        "98780"
        ,
         "placeholder_currency"
        :{' '}
        "$0.00 pesos"
        ,
         "country_code"
        :{' '}
        "MX"
         }
         ]
        ,
         "elapsed"
        :{' '}
        0.0168149471282959
         }

Where:

  • status: Shows if the call has been successful (true) or not (false).
  • countries: List with the active countries of the system.
  • currency_symbol: Symbol of the country's currency.
  • currency_data: Contains the different details of the currency used in the operation.
  • abbreviation: The abbreviated name of the currency (EUR, MXN).
  • suffix: Indicates the suffix that is applied in the currency format (pesos, euros).
  • format: The full format that applies to the currency, it includes the suffix and the prefix.
  • symbol: The symbol associated to the currency (€, ¢, $).
  • prefix: The prefix that is applied in the currency format.
  • decimals: The maximum number of decimal places that will be included in the currency format.
  • id: Identifier of the currency in BBDD.
  • currency_format: Format to be applied to the amounts that use this currency.
  • precision_currency: Decimals of the amounts that use this currency.
  • phone_longitude: Size of telephone numbers used in the country.
  • currency: Full name of the country's currency.
  • name: Name of the country.
  • prefix: Telephone prefix of the country's telephone numbers.
  • phone: Telephone from which the system's SMS for the country are sent.
  • placeholder_currency: Text to display in the fields that are of the currency and have no value.
  • country_code: Code of the country.
  • 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 level.
  • message: Error message.
  • error: Sole error code.

Example requests:

Python - Requests:

import requests
         url ={' '}
        "URL_BASE/ws/util.py/countries"
         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/countries',
         '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/countries", 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/countries'

Business logic:

By means of this service all the active countries in the system are obtained.