(function(root, factory) {
if (typeof module === 'object' && module.exports) {
// CommonJS-like environments that support module.exports, like Node.
module.exports = factory(require('logtown').getLogger('/src/handlers/RetrieveCustomersPageHandler'), require('../ApiClient'), require('../api/CustomerApi'), require('../OrbipayApiError'), require('../CommonUtil'));
}
}(this, function(logger, ApiClient, CustomerApi, OrbipayApiError, CommonUtil) {
'use strict';
/**
* @module ApiClient
*/
/**
* <h3 style="color:red"> This class subject to change without prior notice, Please dont use this class directly. </h3>
* @module handlers/RetrieveCustomersPageHandler
* @class
*/
var exports = function() {
};
exports.prototype.process = function (customers, callback) {
var secret = customers.invocation_context.secret;
var host = customers.api_end_point;
var api_key = customers.invocation_context.api_key;
var auth_scheme = customers.invocation_context.auth_scheme;
var _this=this;
var response = {};
var exception;
try {
var api_client = new ApiClient(secret, host,api_key,auth_scheme);
var api_instance = new CustomerApi(api_client);
var channel = customers.invocation_context['channel'];
var client_key = customers.invocation_context['client_key'];
var product = customers.invocation_context['product'];
var timestamp;
if (customers.invocation_context['timestamp'])
{
timestamp = customers.invocation_context['timestamp'];
}
else
{
timestamp = CommonUtil.getTimeStamp();
}
var idempotent_request_key = customers.invocation_context['idempotent_request_key'];
var requestor_type = customers.invocation_context['requestor_type'];
var query_id = customers['query_id'];
var opts = _this.getOptions(customers);
var result = api_instance.retrieveCustomersPage(channel, client_key, product, timestamp, idempotent_request_key, requestor_type, query_id, opts, callback);
response['request'] = result;
return response;
} catch (e) {
exception = OrbipayApiError.getDefaultException(e);
if (callback) {
callback(null, null, null, exception);
}
response['exception'] = exception;
return response;
}
};
exports.prototype.getOptions = function (customers) {
return {
'query_id': customers['query_id'],
'requestor': customers['invocation_context']['requestor'],
'x_opay_headers': customers['invocation_context']['X-OPAY-Headers'],
'page_size': customers['page_size'],
'from_index': customers['from_index'],
'to_index': customers['to_index']
};
};
return exports;
}));