(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/RetrieveCustomerAccountsHandler'), require('../ApiClient'), require('../api/CustomerAccountApi'), require('../OrbipayApiError'), require('../CommonUtil'));
}
}(this, function(logger, ApiClient, CustomerAccountApi, 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/RetrieveCustomerAccountsHandler
* @class
*/
var exports = function() {
};
exports.prototype.process = function (customerAccounts, callback) {
var secret = customerAccounts.invocation_context.secret;
var host = customerAccounts.api_end_point;
var api_key = customerAccounts.invocation_context.api_key;
var auth_scheme = customerAccounts.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 CustomerAccountApi(api_client);
var channel = customerAccounts.invocation_context['channel'];
var client_key = customerAccounts.invocation_context['client_key'];
var product = customerAccounts.invocation_context['product'];
var timestamp;
if (customerAccounts.invocation_context['timestamp'])
{
timestamp = customerAccounts.invocation_context['timestamp'];
}
else
{
timestamp = CommonUtil.getTimeStamp();
}
var idempotent_request_key = customerAccounts.invocation_context['idempotent_request_key'];
var requestor_type = customerAccounts.invocation_context['requestor_type'];
var id_customer = customerAccounts['ID_CUSTOMER'];
var opts = _this.getOptions(customerAccounts);
var result = api_instance.retrieveCustomerAccounts(channel, client_key, product, timestamp, idempotent_request_key, requestor_type, id_customer, 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 (customerAccounts) {
return {
'requestor': customerAccounts['invocation_context']['requestor'],
'x_opay_headers': customerAccounts['invocation_context']['X-OPAY-Headers'],
'trace_id': customerAccounts['invocation_context']['trace_id'],
'page_size': customerAccounts['page_size'],
'account_number': customerAccounts['account_number'],
'status': customerAccounts['status']
};
};
return exports;
}));