(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/UpdateFundingAccountHandler'), require('../ApiClient'), require('../api/FundingAccountApi'), require('../OrbipayApiError'), require('../CommonUtil'));
}
}(this, function(logger, ApiClient, FundingAccountApi, 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/UpdateFundingAccountHandler
* @class
*/
var exports = function() {
};
exports.prototype.process = function (fundingAccount, callback) {
var secret = fundingAccount.invocation_context.secret;
var host = fundingAccount.api_end_point;
var api_key = fundingAccount.invocation_context.api_key;
var auth_scheme = fundingAccount.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 FundingAccountApi(api_client);
var channel = fundingAccount.invocation_context['channel'];
var client_key = fundingAccount.invocation_context['client_key'];
var product = fundingAccount.invocation_context['product'];
var timestamp;
if (fundingAccount.invocation_context['timestamp'])
{
timestamp = fundingAccount.invocation_context['timestamp'];
}
else
{
timestamp = CommonUtil.getTimeStamp();
}
var idempotent_request_key = fundingAccount.invocation_context['idempotent_request_key'];
var requestor_type = fundingAccount.invocation_context['requestor_type'];
var id_funding_account = fundingAccount['ID_FUNDING_ACCOUNT'];
var id_customer = fundingAccount['ID_CUSTOMER'];
var update_funding_account_request = _this.populate_body(fundingAccount);
var opts = _this.getOptions(fundingAccount);
var result = api_instance.updateFundingAccount(channel, client_key, product, timestamp, idempotent_request_key, requestor_type, id_funding_account, id_customer, update_funding_account_request, 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 (fundingAccount) {
return {
'requestor': fundingAccount['invocation_context']['requestor'],
'x_opay_headers': fundingAccount['invocation_context']['X-OPAY-Headers']
};
};
exports.prototype.populate_body = function(fundingAccount){
var UpdateFundingAccountRequest = require('../models/UpdateFundingAccountRequest');
return UpdateFundingAccountRequest.constructFromObject(fundingAccount);
};
return exports;
}));