Page tree
Skip to end of metadata
Go to start of metadata

Descrizione

Questo metodo può essere utilizzato per modificare la password di un cliente all'interno del sistema.

Utilizzo

I parametri richiesti da questo metodo sono:

  • customerId: Id del cliente di cui si vuole modificare la password
  • customerOldPasswordHash: Hash in formato SHA1 dell'attuale password dell'utente.
  • customerNewPasswordHash: Hash in formato SHA1 della nuova password dell'utente.

 Il metodo non ha nessun valore di ritorno.

Gestione errori

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

  • 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');
 
	$customers = $ezPrintSDK->backOffice->bGetCustomers(false);
	$ezPrintSDK->backoffice->bEditCustomerPassword($customers[0]['customerId'], sha1("old_password"), sha1("new_password"));
} catch (Exception $e) {
    echo 'Error Code: ',  $e->getMessage();
}

Node.js
try {
	var ezPrintSDK = require('ezprint-sdk-wrapper');
	var sha1 = require('sha1');
	
	ezPrintSDK.initializeWrapper('http://demo.ezprint.it');
    var apiToken = ezPrintSDK.cLoginAPI('1WHm0icsupAEm9fil9en','yCHZ0nKiyn1MU0DhpgmG');
	
	var customers = ezPrintSDK.backOffice.bGetCustomers(false);
	ezPrintSDK.backoffice.bEditCustomerPassword(customer[0].customerId, sha1("old_password"), sha1("new_password"));
} 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.customerItem> customers = ezPrintSDK.BackOffice.bGetCustomers(false);
	HashAlgorithm algorithm = SHA1.Create();
	StringBuilder sb1 = new StringBuilder();
	StringBuilder sb2 = new StringBuilder();
	foreach (byte b in algorithm.ComputeHash(Encoding.UTF8.GetBytes("old_password")))
		sb1.Append(b.ToString("x2"));
 
	foreach (byte b in algorithm.ComputeHash(Encoding.UTF8.GetBytes("new_password")))
		sb2.Append(b.ToString("x2"));

	ezPrintSDK.BackOffice.bEditCustomerPassword(customers[0].customerId, sb1.ToString(), sb2.ToString());
} catch (ezPrintException ex) {
	string ErrorMessage = ex.Message;
}
  • No labels