Page tree

Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

Descrizione

Questo metodo può essere utilizzato per ottenere la lista delle zone di una nazione presenti all'interno del sistema.

Utilizzo

I parametri richiesti da questa funzione sono:

  • countryId: Id della nazione di cui si vogliono ottenere le zone.

In caso di successo ritorna un'array di oggetti così strutturati:

  • countryZoneId: Id della zona all'interno del sistema.
  • countryZoneCode: Codice identificativo della zona.
  • countryZoneName: Nome della zona.
  • enable: true se la nazione è attiva, false se non lo è.

Gestione errori

In caso di errore il metodo genererà un'eccezione che riporterà uno dei seguenti codici di errore:

  • ERROR_INVALID_COUNTRY_ID: Id della nazione non valido.
  • ERROR_INVALID_TOKEN: Non è stato effettuato nessun login in precedenza o la sessione è scaduta per inutilizzo.
  • ERROR_INVALID_IP: L'indirizzo ip del server che sta effettuando la chiamata non valido perchè non inserito nella whitelist associata alle credenziali.
  • ERROR_SERVER_UNAVAILABLE: Il server non è disponibile o si è verificato un errore di comunicazione generico.

 

Code Block
languagephp
titlePHP
linenumberstrue
require "vendor/autoload.php"
 
try {
    $ezPrintSDK = new ezPrintSDKWrapper('http://demo.ezprint.it');
	$apiToken = $ezPrintSDK->cLoginAPI('1WHm0icsupAEm9fil9en','yCHZ0nKiyn1MU0DhpgmG');
 
	$availableCountries = $ezPrintSDK->backOffice->bGetCountries();
	$countryZones = $ezPrintSDK->backOffice->bGetCountryZones($availableCountries[0]['countryId']);
 
	foreach($countryZones as $countryZone) {
		echo $countryZone['countryZoneId'], ' ', $countryZone['countryZoneName'];
	}
} catch (Exception $e) {
    echo 'Error Code: ',  $e->getMessage();
}

Code Block
languagejs
titleNode.js
linenumberstrue
try {
	var ezPrintSDK = require('ezprint-sdk-wrapper');
	ezPrintSDK.initializeWrapper('http://demo.ezprint.it');
 
    var apiToken = ezPrintSDK.cLoginAPI('1WHm0icsupAEm9fil9en','yCHZ0nKiyn1MU0DhpgmG');
	var availableCountries = ezPrintSDK.backOffice.bGetCountries();
 	var countryZones = ezPrintSDK.backOffice.bGetCountryZones(availableCountries[0].countryId);
	countryZones.forEach(function(countryZone) {
		console.log(countryZone.countryZoneId);
		console.log(countryZone.countryZoneName);
	});
} catch (ex) {
	console.log(ex);
}
Code Block
languagec#
title.NET (C#)
linenumberstrue
try {
	ezPrintSDKWrapper.Client ezPrintSDK = new ezPrintSDKWrapper.Client("http://demo.ezprint.it");
	ezPrintSDK.cLoginAPI("1WHm0icsupAEm9fil9en","yCHZ0nKiyn1MU0DhpgmG");
	List<ezPrintSDKWrapper.Structures.countryItem> availableCountries = ezPrintSDK.BackOffice.bGetCountries();
	List<ezPrintSDKWrapper.Structures.countryZoneItem> countryZones = ezPrintSDK.BackOffice.bGetCountryZones(availableCountries[0].countryId);
 
	foreach (ezPrintSDKWrapper.Structures.countryZoneItem countryZone in countryZones) {
        System.Console.WriteLine("Country {0}: {1}", countryZone.countryZoneId, countrycountryZone.countryZoneName);
    }
} catch (ezPrintException ex) {
	string ErrorMessage = ex.Message;
}