geography-apis-sdk
Version:
SDK for making requests to Geography APIs
233 lines (196 loc) • 5.25 kB
JavaScript
const Name = require('./Name');
const Currency = require('./Currency');
const Idd = require('./Idd');
const Capital = require('./Capital');
const Language = require('./Language');
const LatLng = require('./LatLng');
const Flag = require('./Flag');
const Demonyms = require('./Demonyms');
const CoatOfArms = require('./CoatOfArms');
const Map = require('./Map');
const Gini = require('./Gini');
const Car = require('./Car');
const PostalCode = require('./PostalCode');
/**
* Represents a country.
*/
class Country {
/**
* Creates an instance of the Country class.
* @param {object} data - The country data.
*/
constructor(data) {
if(typeof data == 'undefined') return;
/**
* The URL of the country.
* @type {string}
*/
this.href = data.href;
/**
* The name of the country.
* @type {Name}
*/
this.name = new Name(data.name);
/**
* The top-level domain of the country.
* @type {Array.<string>}
*/
this.tld = data.tld || [];
/**
* The two-letter country code.
* @type {string}
*/
this.cca2 = data.cca2;
/**
* The three-digit country code.
* @type {string}
*/
this.ccn3 = data.ccn3;
/**
* The three-letter country code.
* @type {string}
*/
this.cca3 = data.cca3;
/**
* The IOC code of the country.
* @type {string}
*/
this.cioc = data.cioc;
/**
* The FIFA code of the country.
* @type {string}
*/
this.fifa = data.fifa;
/**
* Indicates if the country is independent.
* @type {boolean}
*/
this.independent = data.independent;
/**
* The status of the country.
* @type {string}
*/
this.status = data.status;
/**
* Indicates if the country is a member of the United Nations.
* @type {boolean}
*/
this.unMember = data.unMember;
/**
* The currencies used in the country.
* @type {Array.<Currency>}
*/
this.currencies = (data.currencies || []).map(currencyData => new Currency(currencyData));
/**
* The International Direct Dialing (IDD) of the country.
* @type {Idd}
*/
this.idd = new Idd(data.idd);
/**
* The capital cities of the country.
* @type {Array.<Capital>}
*/
this.capital = (data.capital || []).map(capitalData => new Capital(capitalData));
/**
* Alternative spellings of the country's name.
* @type {Array.<string>}
*/
this.altSpellings = data.altSpellings || [];
/**
* The region of the country.
* @type {string}
*/
this.region = data.region;
/**
* The subregion of the country.
* @type {string}
*/
this.subregion = data.subregion;
/**
* The continents where the country is located.
* @type {Array.<string>}
*/
this.continents = data.continents || [];
/**
* The languages spoken in the country.
* @type {Array.<Language>}
*/
this.languages = (data.languages || []).map(languageData => new Language(languageData));
/**
* The latitude and longitude coordinates of the country.
* @type {LatLng}
*/
this.latLng = new LatLng(data.latLng);
/**
* Indicates if the country is landlocked.
* @type {boolean}
*/
this.landlocked = data.landlocked;
/**
* The neighboring countries of the country.
* @type {Array.<string>}
*/
this.borders = data.borders || [];
/**
* The area of the country.
* @type {number}
*/
this.area = data.area;
/**
* The URL of the country's flag.
* @type {string}
*/
this.flag = data.flag;
/**
* The flags of the country.
* @type {Flag}
*/
this.flags = new Flag(data.flags);
/**
* The demonyms of the country.
* @type {Array.<Demonyms>}
*/
this.demonyms = (data.demonyms || []).map(demonymsData => new Demonyms(demonymsData));
/**
* The coat of arms of the country.
* @type {CoatOfArms}
*/
this.coatOfArms = new CoatOfArms(data.coatOfArms);
/**
* The population of the country.
* @type {number}
*/
this.population = data.population;
/**
* The maps of the country.
* @type {Map}
*/
this.maps = new Map(data.maps);
/**
* The Gini coefficient of the country.
* @type {Gini}
*/
this.gini = new Gini(data.gini);
/**
* The driving side and road signs of the country.
* @type {Car}
*/
this.car = new Car(data.car);
/**
* The timezones of the country.
* @type {Array.<string>}
*/
this.timezones = data.timezones || [];
/**
* The start day of the week in the country.
* @type {string}
*/
this.startOfWeek = data.startOfWeek;
/**
* The postal code information of the country.
* @type {PostalCode}
*/
this.postalCode = new PostalCode(data.postalCode);
}
}
module.exports = Country;