File: D:/HostingSpaces/SBogers10/csb.komma.pro/resources/js/components/GlobalisationService.js
import { ErrorResponse } from "../global/models/errorResponse";
import { CountryLanguagesResponse } from "../global/models/countryLanguagesResponse";
class GlobalisationService
{
constructor()
{
this._baseRoute = '/';
}
/**
* Adds a product to the shopping cart
*
* @param {string} countryIso3
*/
getLanguagesForCountryWithIso3(countryIso3) {
let self = this;
return new Promise(function(resolve, reject) {
Ajax.post(
self._baseRoute+'getLanguagesForCountryWithIso3',
{ countryIso3: countryIso3 },
function(xhr) {
// let response = JSON.parse(xhr.response);
let isErrorResponse = ErrorResponse.is(xhr.response, false);
let isCountryLanguagesResponse = CountryLanguagesResponse.is(xhr.response, false);
if(!isErrorResponse) {
if(isCountryLanguagesResponse) {
let countryLanguagesResponse = CountryLanguagesResponse.fromJsonString(xhr.response);
resolve(countryLanguagesResponse);
}
else {
console.error('RegisterService:getLanguagesForCountryWithIso3 The response was not a valid CountryLanguagesResponse: '+xhr.response);
reject();
}
} else {
let response = ErrorResponse.fromJsonString(xhr.response);
reject(response);
}
}
);
});
};
}
export { GlobalisationService }