(function(root, factory) {
if (typeof module === 'object' && module.exports) {
// CommonJS-like environments that support module.exports, like Node.
module.exports = factory(require('../ApiClient'), require('./InvocationContext'), require('../CommonUtil'), require('../ResponseWrapper'), require('./Base')
, require('../handlers/RetrieveCustomersHandler')
, require('../handlers/RetrieveCustomersPageHandler'), require('../OrbipayApiError'));
}
}(this, function(ApiClient, InvocationContext, CommonUtil, ResponseWrapper, Base, RetrieveCustomersHandler, RetrieveCustomersPageHandler, OrbipayApiError) {
'use strict';
/**
* The Customers wrapper module.
* @module wrappers/Customers
*/
var exports = function() {
};
exports.constructFromObject = function (data, obj) {
if (data) {
obj = obj || new exports();
if (data.hasOwnProperty('list')) {
var Customer = require('./Customer');
obj['list'] = ApiClient.convertToType(data['list'], [Customer]);
}
if (data.hasOwnProperty('total_results_count')) {
obj['total_results_count'] = data['total_results_count'];
}
if (data.hasOwnProperty('has_more_results')) {
obj['has_more_results'] = data['has_more_results'];
}
if (data.hasOwnProperty('url')) {
obj['url'] = data['url'];
}
if (data.hasOwnProperty('from_index')) {
obj['from_index'] = data['from_index'];
}
if (data.hasOwnProperty('to_index')) {
obj['to_index'] = data['to_index'];
}
if (data.hasOwnProperty('query_id')) {
obj['query_id'] = data['query_id'];
}
if (data.hasOwnProperty('page_size')) {
obj['page_size'] = data['page_size'];
}
if (data.hasOwnProperty('customer_reference')) {
obj['customer_reference'] = data['customer_reference'];
}
if (data.hasOwnProperty('ssn')) {
obj['ssn'] = data['ssn'];
}
if (data.hasOwnProperty('email')) {
obj['email'] = data['email'];
}
if (data.hasOwnProperty('account_number')) {
obj['account_number'] = data['account_number'];
}
}
return obj;
};
exports.prototype = Object.create(Base.prototype);
exports.prototype.constructor = exports;
/**
* @member [Customer] list
*/
exports.prototype['list'] = undefined;
/**
* The total number of customers available matching the search criteria.
* @member {String} total_results_count
*/
exports.prototype['total_results_count'] = undefined;
/**
* true if there are more results or pages
* @member {String} has_more_results
*/
exports.prototype['has_more_results'] = undefined;
/**
* This URL fetches the next or previous set of payments, based on the presence of after_object or before_object parameter.
* @member {String} url
*/
exports.prototype['url'] = undefined;
/**
* The id of the object before which the previous set of objects are to be retrieved.
* @member {String} from_index
*/
exports.prototype['from_index'] = undefined;
/**
* The id of the object after which the next set of objects are to be retrieved.
* @member {String} to_index
*/
exports.prototype['to_index'] = undefined;
/**
* The query id of the object.
* @member {String} query_id
*/
exports.prototype['query_id'] = undefined;
/**
* The maximum number of objects returned in the query.
* @member {String} page_size
*/
exports.prototype['page_size'] = undefined;
/**
* Unique ID assigned by the biller/client system for a given customer.
* @member {String} customer_reference
*/
exports.prototype['customer_reference'] = undefined;
/**
* The SSN of the customer if the account holder is an individual or the tax ID, if the customer is a business.
* @member {String} ssn
*/
exports.prototype['ssn'] = undefined;
/**
* This field contains the customer’s email address within EBPP.
* @member {String} email
*/
exports.prototype['email'] = undefined;
/**
* Customer Account Number of the customer to get details of.
* @member {String} account_number
*/
exports.prototype['account_number'] = undefined;
/**
* @param {String} client_key - The client_key of Customers.
* @return {module:wrappers/Customers} The instance of <code>Customers</code>.
*/
exports.prototype.forClient = function (client_key) {
var _this = this;
Base.prototype.forClient.call(_this,client_key);
return _this;
};
/**
* @param {String} channel - The channel of Customers.
* @return {module:wrappers/Customers} The instance of <code>Customers</code>.
*/
exports.prototype.videChannel = function (channel) {
var _this = this;
Base.prototype.videChannel.call(_this,channel);
return _this;
};
/**
* @param {String} customer_reference - The customer_reference of Customers.
* @param {String} ssn - The ssn of Customers.
* @param {String} email - The email of Customers.
* @param {String} account_number - The account_number of Customers.
* @param {String} page_size - The page_size of Customers.
* @param {String} query_id - The query_id of Customers.
* @param {String} from_index - The from_index of Customers.
* @param {String} to_index - The to_index of Customers.
* @return {module:wrappers/Customers} The instance of <code>Customers</code>.
*/
exports.prototype.findBy = function (filterParameters) {
var _this = this;
if(filterParameters){
_this['customer_reference'] = CommonUtil.getValuesFromMultiMap(filterParameters, 'customer_reference', false);
_this['ssn'] = CommonUtil.getValuesFromMultiMap(filterParameters, 'ssn', false);
_this['email'] = CommonUtil.getValuesFromMultiMap(filterParameters, 'email', false);
_this['account_number'] = CommonUtil.getValuesFromMultiMap(filterParameters, 'account_number', false);
_this['page_size'] = CommonUtil.getValuesFromMultiMap(filterParameters, 'page_size', false);
_this['query_id'] = CommonUtil.getValuesFromMultiMap(filterParameters, 'query_id', false);
_this['from_index'] = CommonUtil.getValuesFromMultiMap(filterParameters, 'from_index', false);
_this['to_index'] = CommonUtil.getValuesFromMultiMap(filterParameters, 'to_index', false);
}
return _this;
};
exports.prototype.retrievedBy = function (requestor, requestor_type) {
var _this = this;
_this.requestedBy(requestor, requestor_type);
return _this;
};
exports.prototype.get = function (invocation_context, callback, live_mode, api_end_point) {
var _this = this;
var internalCallback = function (errorMessage, parsedData, httpResponse, exception) {
try {
var response = ResponseWrapper.wrapResponse(exports, exception, errorMessage, parsedData, httpResponse);
if (callback) {
callback(response['exception'], response['data'])
}
} catch (e) {
exception = OrbipayApiError.getDefaultException(e);
if (callback) {
callback(exception)
}
}
};
try {
_this.withContext(invocation_context, live_mode, api_end_point);
var handler = new RetrieveCustomersHandler();
if (callback && CommonUtil.isFunction(callback)) {
return handler.process(_this, internalCallback);
} else {
return handler.process(_this);
}
}
catch (e){
var error = OrbipayApiError.getDefaultException(e);
if (callback) {
callback(error)
}
}
};
exports.prototype.getPage = function (invocation_context, callback, live_mode, api_end_point) {
var _this = this;
var internalCallback = function (errorMessage, parsedData, httpResponse, exception) {
try {
var response = ResponseWrapper.wrapResponse(exports, exception, errorMessage, parsedData, httpResponse);
if (callback) {
callback(response['exception'], response['data'])
}
} catch (e) {
exception = OrbipayApiError.getDefaultException(e);
if (callback) {
callback(exception)
}
}
};
try {
_this.withContext(invocation_context, live_mode, api_end_point);
var handler = new RetrieveCustomersPageHandler();
if (callback && CommonUtil.isFunction(callback)) {
return handler.process(_this, internalCallback);
} else {
return handler.process(_this);
}
}
catch (e){
var error = OrbipayApiError.getDefaultException(e);
if (callback) {
callback(error)
}
}
};
return exports;
}));