Descrizione
Questo metodo può essere utilizzato per inserire un utente all'interno del sistema.
Utilizzo
I parametri richiesti da questo metodo sono:
- customerFirstName: Nome del cliente
- customerLastName: Cognome del cliente.
- customerEmail: Indirizzo email del cliente.
- customerTelephone: Numero di telefono del cliente.
- customerFax: Numero del fax del cliente.
- passwordHash: Hash in formato SHA1 della password scelta dal cliente.
- secureQuestionId: Id della domanda di sicurezza associata al cliente. Per ottenere maggiori informazioni e la lista delle domande consultare bGetSecureQuestions.
- secureQuestionHash_MD5: Hash in formato MD5 della risposta alla domanda di sicurezza.
- secureQuestionHash_SHA1: Hash in formato SHA1 della risposta alla domanda di sicurezza.
- customerGroupId: Id del gruppo clienti a cui è associato il cliente.
- storeId: Id dello store a cui è associato il cliente.
- newsletter: true se il cliente ha autorizzato all'utilizzo dei dati personali per comunicazioni commerciali, false in caso contrario.
- approved: true se il cliente è stato approvato, false in caso il cliente necessiti dell'approvazione da parte dell'amministratore.
- enable: true se il cliente è attivo, false in caso contrario.
In caso di successo ritorna un intero che rappresenta l'id del cliente.
Gestione errori
In caso di errore il metodo genererà un'eccezione che riporterà uno dei seguenti codici di errore:
- ERROR_EMAIL_ADDRESS_ALREADY_USED: L'indirizzo email specificato è già registrato all'interno del sistema.
- ERROR_INVALID_PARAMS: Uno dei parametri inviati 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.
PHP
require "vendor/autoload.php" try { $ezPrintSDK = new ezPrintSDKWrapper('http://demo.ezprint.it'); $apiToken = $ezPrintSDK->cLoginAPI('1WHm0icsupAEm9fil9en','yCHZ0nKiyn1MU0DhpgmG'); $availableLanguages = $ezPrintSDK->backOffice->bGetAvailableLanguages(); $customerGroups = $ezPrintSDK->backOffice->bGetCustomerGroups(false, $availableLanguages[0]['languageId']); $secureQuestions = $ezPrintSDK->backOffice->bGetSecureQuestions($availableLanguages[0]['languageId']); $storesList = $ezPrintSDK->backOffice->bGetStores(false); $customerId = $ezPrintSDK->backOffice->bAddCustomer("Nome Cliente", "Cognome Cliente", "demo@demo.it", "0559752330", "0559752332", sha1("password"), secureQuestions[0]["secureQuestionId"], md5("risposta"), sha1("risposta"), customerGroups[0]["customerGroupId"], $storesList[0]["storeId"], true, true, true); } catch (Exception $e) { echo 'Error Code: ', $e->getMessage(); }
Node.js
try { var ezPrintSDK = require('ezprint-sdk-wrapper'); var sha1 = require('sha1'); var md5 = require('md5'); ezPrintSDK.initializeWrapper('http://demo.ezprint.it'); var apiToken = ezPrintSDK.cLoginAPI('1WHm0icsupAEm9fil9en','yCHZ0nKiyn1MU0DhpgmG'); var availableLanguages = ezPrintSDK.backOffice.bGetAvailableLanguages(); var customerGroups = ezPrintSDK.backOffice.bGetCustomerGroups(false, availableLanguages[0].languageId); var secureQuestions = ezPrintSDK.backOffice.bGetSecureQuestions(availableLanguages[0].languageId); var storesList = ezPrintSDK.backOffice.bGetStores(false); var customerId = ezPrintSDK.backOffice.bAddCustomer("Nome Cliente", "Cognome Cliente", "demo@demo.it", "0559752330", "0559752332", sha1("password"), secureQuestions[0].secureQuestionId, md5("risposta"), sha1("risposta"), customerGroups[0].customerGroupId, storesList[0].storeId, true, true, true); } catch (ex) { console.log(ex); }
.NET (C#)
try { ezPrintSDKWrapper.Client ezPrintSDK = new ezPrintSDKWrapper.Client("http://demo.ezprint.it"); ezPrintSDK.cLoginAPI("1WHm0icsupAEm9fil9en","yCHZ0nKiyn1MU0DhpgmG"); List<ezPrintSDKWrapper.Structures.languageItem> availableLanguages = ezPrintSDK.BackOffice.bGetAvailableLanguages(); List<ezPrintSDKWrapper.Structures.customerGroupItem> customerGroups = ezPrintSDK.BackOffice.bGetCustomerGroups(false, availableLanguages[0].languageId); List<ezPrintSDKWrapper.Structures.secureQuestionItem> secureQuestions = ezPrintSDK.BackOffice.bGetSecureQuestions(availableLanguages[0].languageId); List<ezPrintSDKWrapper.Structures.storeItem> storesList = ezPrintSDK.BackOffice.bGetStores(false); HashAlgorithm algorithmSHA1 = SHA1.Create(); MD5 algorithmMD5 = MD5.Create(); StringBuilder sb1 = new StringBuilder(); StringBuilder sb2 = new StringBuilder(); StringBuilder sb3 = new StringBuilder(); foreach (byte b in algorithmMD5.ComputeHash(Encoding.UTF8.GetBytes("risposta"))) sb1.Append(b.ToString("x2")); foreach (byte b in algorithmSHA1.ComputeHash(Encoding.UTF8.GetBytes("risposta"))) sb2.Append(b.ToString("x2")); foreach (byte b in algorithmSHA1.ComputeHash(Encoding.UTF8.GetBytes("password"))) sb3.Append(b.ToString("x2")); int customerId = ezPrintSDK.BackOffice.bAddCustomer("Nome Cliente", "Cognome Cliente", "demo@demo.it", "0559752330", "0559752332", sb3.ToString(), secureQuestions[0].secureQuestionId, sb1.ToString(), sb2.ToString(), customerGroups[0].customerGroupId, storesList[0].storeId, true, true, true); } catch (ezPrintException ex) { string ErrorMessage = ex.Message; }