- 1 :
- 2 :
- 3 :
(function(root, factory) {
- 4 :
- 5 :
if (typeof module === 'object' && module.exports) {
- 6 :
// CommonJS-like environments that support module.exports, like Node.
- 7 :
module.exports = factory(require('../ApiClient'), require('./InvocationContext'), require('../CommonUtil'), require('../ResponseWrapper'), require('./Base')
- 8 :
, require('../handlers/RetrieveCustomersHandler')
- 9 :
, require('../handlers/RetrieveCustomersPageHandler'), require('../OrbipayApiError'));
- 10 :
}
- 11 :
}(this, function(ApiClient, InvocationContext, CommonUtil, ResponseWrapper, Base, RetrieveCustomersHandler, RetrieveCustomersPageHandler, OrbipayApiError) {
- 12 :
'use strict';
- 13 :
- 14 :
/**
- 15 :
* The Customers wrapper module.
- 16 :
* @module wrappers/Customers
- 17 :
*/
- 18 :
var exports = function() {
- 19 :
- 20 :
};
- 21 :
exports.constructFromObject = function (data, obj) {
- 22 :
if (data) {
- 23 :
obj = obj || new exports();
- 24 :
if (data.hasOwnProperty('list')) {
- 25 :
var Customer = require('./Customer');
- 26 :
obj['list'] = ApiClient.convertToType(data['list'], [Customer]);
- 27 :
}
- 28 :
if (data.hasOwnProperty('total_results_count')) {
- 29 :
obj['total_results_count'] = data['total_results_count'];
- 30 :
}
- 31 :
if (data.hasOwnProperty('has_more_results')) {
- 32 :
obj['has_more_results'] = data['has_more_results'];
- 33 :
}
- 34 :
if (data.hasOwnProperty('url')) {
- 35 :
obj['url'] = data['url'];
- 36 :
}
- 37 :
if (data.hasOwnProperty('from_index')) {
- 38 :
obj['from_index'] = data['from_index'];
- 39 :
}
- 40 :
if (data.hasOwnProperty('to_index')) {
- 41 :
obj['to_index'] = data['to_index'];
- 42 :
}
- 43 :
if (data.hasOwnProperty('query_id')) {
- 44 :
obj['query_id'] = data['query_id'];
- 45 :
}
- 46 :
if (data.hasOwnProperty('page_size')) {
- 47 :
obj['page_size'] = data['page_size'];
- 48 :
}
- 49 :
if (data.hasOwnProperty('customer_reference')) {
- 50 :
obj['customer_reference'] = data['customer_reference'];
- 51 :
}
- 52 :
if (data.hasOwnProperty('ssn')) {
- 53 :
obj['ssn'] = data['ssn'];
- 54 :
}
- 55 :
if (data.hasOwnProperty('email')) {
- 56 :
obj['email'] = data['email'];
- 57 :
}
- 58 :
if (data.hasOwnProperty('account_number')) {
- 59 :
obj['account_number'] = data['account_number'];
- 60 :
}
- 61 :
}
- 62 :
return obj;
- 63 :
};
- 64 :
- 65 :
- 66 :
exports.prototype = Object.create(Base.prototype);
- 67 :
exports.prototype.constructor = exports;
- 68 :
- 69 :
/**
- 70 :
* @member [Customer] list
- 71 :
*/
- 72 :
exports.prototype['list'] = undefined;
- 73 :
/**
- 74 :
* The total number of customers available matching the search criteria.
- 75 :
* @member {String} total_results_count
- 76 :
*/
- 77 :
exports.prototype['total_results_count'] = undefined;
- 78 :
/**
- 79 :
* true if there are more results or pages
- 80 :
* @member {String} has_more_results
- 81 :
*/
- 82 :
exports.prototype['has_more_results'] = undefined;
- 83 :
/**
- 84 :
* This URL fetches the next or previous set of payments, based on the presence of after_object or before_object parameter.
- 85 :
* @member {String} url
- 86 :
*/
- 87 :
exports.prototype['url'] = undefined;
- 88 :
/**
- 89 :
* The id of the object before which the previous set of objects are to be retrieved.
- 90 :
* @member {String} from_index
- 91 :
*/
- 92 :
exports.prototype['from_index'] = undefined;
- 93 :
/**
- 94 :
* The id of the object after which the next set of objects are to be retrieved.
- 95 :
* @member {String} to_index
- 96 :
*/
- 97 :
exports.prototype['to_index'] = undefined;
- 98 :
/**
- 99 :
* The query id of the object.
- 100 :
* @member {String} query_id
- 101 :
*/
- 102 :
exports.prototype['query_id'] = undefined;
- 103 :
/**
- 104 :
* The maximum number of objects returned in the query.
- 105 :
* @member {String} page_size
- 106 :
*/
- 107 :
exports.prototype['page_size'] = undefined;
- 108 :
/**
- 109 :
* Unique ID assigned by the biller/client system for a given customer.
- 110 :
* @member {String} customer_reference
- 111 :
*/
- 112 :
exports.prototype['customer_reference'] = undefined;
- 113 :
/**
- 114 :
* The SSN of the customer if the account holder is an individual or the tax ID, if the customer is a business.
- 115 :
* @member {String} ssn
- 116 :
*/
- 117 :
exports.prototype['ssn'] = undefined;
- 118 :
/**
- 119 :
* This field contains the customer’s email address within EBPP.
- 120 :
* @member {String} email
- 121 :
*/
- 122 :
exports.prototype['email'] = undefined;
- 123 :
/**
- 124 :
* Customer Account Number of the customer to get details of.
- 125 :
* @member {String} account_number
- 126 :
*/
- 127 :
exports.prototype['account_number'] = undefined;
- 128 :
- 129 :
/**
- 130 :
* @param {String} client_key - The client_key of Customers.
- 131 :
* @return {module:wrappers/Customers} The instance of <code>Customers</code>.
- 132 :
*/
- 133 :
exports.prototype.forClient = function (client_key) {
- 134 :
var _this = this;
- 135 :
Base.prototype.forClient.call(_this,client_key);
- 136 :
return _this;
- 137 :
};
- 138 :
/**
- 139 :
* @param {String} channel - The channel of Customers.
- 140 :
* @return {module:wrappers/Customers} The instance of <code>Customers</code>.
- 141 :
*/
- 142 :
exports.prototype.videChannel = function (channel) {
- 143 :
var _this = this;
- 144 :
Base.prototype.videChannel.call(_this,channel);
- 145 :
return _this;
- 146 :
};
- 147 :
/**
- 148 :
* @param {String} customer_reference - The customer_reference of Customers.
- 149 :
* @param {String} ssn - The ssn of Customers.
- 150 :
* @param {String} email - The email of Customers.
- 151 :
* @param {String} account_number - The account_number of Customers.
- 152 :
* @param {String} page_size - The page_size of Customers.
- 153 :
* @param {String} query_id - The query_id of Customers.
- 154 :
* @param {String} from_index - The from_index of Customers.
- 155 :
* @param {String} to_index - The to_index of Customers.
- 156 :
* @return {module:wrappers/Customers} The instance of <code>Customers</code>.
- 157 :
*/
- 158 :
exports.prototype.findBy = function (filterParameters) {
- 159 :
var _this = this;
- 160 :
if(filterParameters){
- 161 :
- 162 :
_this['customer_reference'] = CommonUtil.getValuesFromMultiMap(filterParameters, 'customer_reference', false);
- 163 :
- 164 :
_this['ssn'] = CommonUtil.getValuesFromMultiMap(filterParameters, 'ssn', false);
- 165 :
- 166 :
_this['email'] = CommonUtil.getValuesFromMultiMap(filterParameters, 'email', false);
- 167 :
- 168 :
_this['account_number'] = CommonUtil.getValuesFromMultiMap(filterParameters, 'account_number', false);
- 169 :
- 170 :
_this['page_size'] = CommonUtil.getValuesFromMultiMap(filterParameters, 'page_size', false);
- 171 :
- 172 :
_this['query_id'] = CommonUtil.getValuesFromMultiMap(filterParameters, 'query_id', false);
- 173 :
- 174 :
_this['from_index'] = CommonUtil.getValuesFromMultiMap(filterParameters, 'from_index', false);
- 175 :
- 176 :
_this['to_index'] = CommonUtil.getValuesFromMultiMap(filterParameters, 'to_index', false);
- 177 :
}
- 178 :
return _this;
- 179 :
};
- 180 :
- 181 :
exports.prototype.retrievedBy = function (requestor, requestor_type) {
- 182 :
var _this = this;
- 183 :
_this.requestedBy(requestor, requestor_type);
- 184 :
return _this;
- 185 :
};
- 186 :
- 187 :
exports.prototype.get = function (invocation_context, callback, live_mode, api_end_point) {
- 188 :
var _this = this;
- 189 :
var internalCallback = function (errorMessage, parsedData, httpResponse, exception) {
- 190 :
try {
- 191 :
var response = ResponseWrapper.wrapResponse(exports, exception, errorMessage, parsedData, httpResponse);
- 192 :
if (callback) {
- 193 :
callback(response['exception'], response['data'])
- 194 :
}
- 195 :
} catch (e) {
- 196 :
exception = OrbipayApiError.getDefaultException(e);
- 197 :
if (callback) {
- 198 :
callback(exception)
- 199 :
}
- 200 :
}
- 201 :
};
- 202 :
try {
- 203 :
_this.withContext(invocation_context, live_mode, api_end_point);
- 204 :
var handler = new RetrieveCustomersHandler();
- 205 :
if (callback && CommonUtil.isFunction(callback)) {
- 206 :
return handler.process(_this, internalCallback);
- 207 :
} else {
- 208 :
return handler.process(_this);
- 209 :
}
- 210 :
}
- 211 :
catch (e){
- 212 :
var error = OrbipayApiError.getDefaultException(e);
- 213 :
if (callback) {
- 214 :
callback(error)
- 215 :
}
- 216 :
}
- 217 :
};
- 218 :
exports.prototype.getPage = function (invocation_context, callback, live_mode, api_end_point) {
- 219 :
var _this = this;
- 220 :
var internalCallback = function (errorMessage, parsedData, httpResponse, exception) {
- 221 :
try {
- 222 :
var response = ResponseWrapper.wrapResponse(exports, exception, errorMessage, parsedData, httpResponse);
- 223 :
if (callback) {
- 224 :
callback(response['exception'], response['data'])
- 225 :
}
- 226 :
} catch (e) {
- 227 :
exception = OrbipayApiError.getDefaultException(e);
- 228 :
if (callback) {
- 229 :
callback(exception)
- 230 :
}
- 231 :
}
- 232 :
};
- 233 :
try {
- 234 :
_this.withContext(invocation_context, live_mode, api_end_point);
- 235 :
var handler = new RetrieveCustomersPageHandler();
- 236 :
if (callback && CommonUtil.isFunction(callback)) {
- 237 :
return handler.process(_this, internalCallback);
- 238 :
} else {
- 239 :
return handler.process(_this);
- 240 :
}
- 241 :
}
- 242 :
catch (e){
- 243 :
var error = OrbipayApiError.getDefaultException(e);
- 244 :
if (callback) {
- 245 :
callback(error)
- 246 :
}
- 247 :
}
- 248 :
};
- 249 :
- 250 :
return exports;
- 251 :
- 252 :
}));