Page tree

Versions Compared

Key

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

Descrizione

Questo metodo può essere utilizzato per ottenere lo storico delle transazioni dei punti fedeltà di uno specifico cliente.

Utilizzo

I parametri richiesti da questa funzione sono:

  • customerId: Id del cliente di cui si vogliono ottenere le lo storico delle transazioni.

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

  • rewardDescription: Descrizione della transazione.
  • rewardPoints: Numero di punti fedeltà assegnati al cliente.
  • orderId: Id dell'ordine a cui fa riferimento la transazione.
  • dateCreated: Stringa contenente la data in cui è stata registrata la transazione nel formato YYYY-MM-DD HH:MM:SS.

Gestione errori

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

  • ERROR_INVALID_CUSTOMER_ID: L'id del cliente fornito 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');
 
	$customers = $ezPrintSDK->backOffice->bGetCustomers(false);
	$customerRewards = $ezPrintSDK->backOffice->bGetCustomerRewards($customers[0]['customerId']);
	foreach($customerRewards as $customerReward) {
        echo $customerReward['rewardDescription'], ' ', $customerReward['rewardPoints'];
    }
} catch (Exception $e) {
    echo 'Error Code: ',  $e->getMessage();
}

Code Block
languagejs
titleNode.js
linenumberstrue
try {
	var util = require('util');
	var ezPrintSDK = require('ezprint-sdk-wrapper');
	ezPrintSDK.initializeWrapper('http://demo.ezprint.it');
 
    var apiToken = ezPrintSDK.cLoginAPI('1WHm0icsupAEm9fil9en','yCHZ0nKiyn1MU0DhpgmG');
 
	var customers = ezPrintSDK.backOffice.bGetCustomers(false);
	var customerRewards = ezPrintSDK.backOffice.bGetCustomerRewards(customers[0].customerId);
 
	customerRewards.forEach(function(customerReward) {
        console.log(customerReward.rewardDescription);
        console.log(customerReward.rewardPoints);
    });
} 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.customerItem> customers = ezPrintSDK.BackOffice.bGetCustomers(false);
 	List<ezPrintSDKWrapper.Structures.customerRewardItem> customerRewards = ezPrintSDK.BackOffice.bGetCustomerRewards(customers[0].customerId);
	System.Console.WriteLine("Customer AddressReward {0}: {1}", customerRewards[0].rewardDescription, customerRewards[0].rewardPoints);
} catch (ezPrintException ex) {
	string ErrorMessage = ex.Message;
}