cybersource-rest-client
Version:
Node.js SDK for the CyberSource REST API
318 lines (271 loc) • 14.3 kB
JavaScript
/**
* CyberSource Merged Spec
* All CyberSource API specs merged together. These are available at https://developer.cybersource.com/api/reference/api-reference.html
*
* OpenAPI spec version: 0.0.1
*
* NOTE: This class is auto generated by the swagger code generator program.
* https://github.com/swagger-api/swagger-codegen.git
*
* Swagger Codegen version: 2.4.38
*
* Do not edit the class manually.
*
*/
(function(root, factory) {
if (typeof define === 'function' && define.amd) {
// AMD. Register as an anonymous module.
define(['Authentication/MLEUtility', 'ApiClient', 'model/Body', 'model/InlineResponse20010', 'model/InlineResponse20011', 'model/InlineResponse2009', 'model/InlineResponse202', 'model/InlineResponse4011'], factory);
} else if (typeof module === 'object' && module.exports) {
// CommonJS-like environments that support module.exports, like Node.
module.exports = factory(require('../authentication/util/MLEUtility'), require('../ApiClient'), require('../model/Body'), require('../model/InlineResponse20010'), require('../model/InlineResponse20011'), require('../model/InlineResponse2009'), require('../model/InlineResponse202'), require('../model/InlineResponse4011'));
} else {
// Browser globals (root is window)
if (!root.CyberSource) {
root.CyberSource = {};
}
root.CyberSource.BatchesApi = factory(root.Authentication.MLEUtility, root.CyberSource.ApiClient, root.CyberSource.Body, root.CyberSource.InlineResponse20010, root.CyberSource.InlineResponse20011, root.CyberSource.InlineResponse2009, root.CyberSource.InlineResponse202, root.CyberSource.InlineResponse4011);
}
}(this, function(MLEUtility, ApiClient, Body, InlineResponse20010, InlineResponse20011, InlineResponse2009, InlineResponse202, InlineResponse4011) {
'use strict';
/**
* Batches service.
* @module api/BatchesApi
* @version 0.0.1
*/
/**
* Constructs a new BatchesApi.
* @alias module:api/BatchesApi
* @class
* @param {module:ApiClient} apiClient Optional API client implementation to use,
* default to {@link module:ApiClient#instance} if unspecified.
*/
var exports = function(configObject, apiClient) {
this.apiClient = apiClient || ApiClient.instance;
this.apiClient.setConfiguration(configObject);
/**
* Callback function to receive the result of the getBatchReport operation.
* @callback module:api/BatchesApi~getBatchReportCallback
* @param {String} error Error message, if any.
* @param {module:model/InlineResponse20011} data The data returned by the service call.
* @param {String} response The complete HTTP response.
*/
/**
* Retrieve a Batch Report
* **Get Batch Report**<br>This resource accepts a batch id and returns: - The batch status. - The total number of accepted, rejected, updated records. - The total number of card association responses. - The billable quantities of: - New Account Numbers (NAN) - New Expiry Dates (NED) - Account Closures (ACL) - Contact Card Holders (CCH) - Source record information including token ids, masked card number, expiration dates & card type. - Response record information including response code, reason, token ids, masked card number, expiration dates & card type.
* @param {String} batchId Unique identification number assigned to the submitted request.
* @param {module:api/BatchesApi~getBatchReportCallback} callback The callback function, accepting three arguments: error, data, response
* data is of type: {@link module:model/InlineResponse20011}
*/
this.getBatchReport = function(batchId, callback) {
var postBody = null;
if ('GET' == 'POST') {
postBody = '{}';
}
// verify the required parameter 'batchId' is set
if (batchId === undefined || batchId === null) {
throw new Error("Missing the required parameter 'batchId' when calling getBatchReport");
}
var pathParams = {
'batchId': batchId
};
var queryParams = {
};
var headerParams = {
};
var formParams = {
};
var authNames = [];
var contentTypes = ['application/json;charset=utf-8'];
var accepts = ['application/json;charset=utf-8'];
var returnType = InlineResponse20011;
//check isMLE for an api method 'this.getBatchReport'
var inboundMLEStatus = 'false';
var isMLEForApi = MLEUtility.checkIsMLEForAPI(this.apiClient.merchantConfig, inboundMLEStatus, 'getBatchReport');
if (isMLEForApi === true) {
MLEUtility.encryptRequestPayload(this.apiClient.merchantConfig, postBody).then(postBody => {
return this.apiClient.callApi(
'/accountupdater/v1/batches/{batchId}/report', 'GET',
pathParams, queryParams, headerParams, formParams, postBody,
authNames, contentTypes, accepts, returnType, callback
);
});
} else {
return this.apiClient.callApi(
'/accountupdater/v1/batches/{batchId}/report', 'GET',
pathParams, queryParams, headerParams, formParams, postBody,
authNames, contentTypes, accepts, returnType, callback
);
}
}
/**
* Callback function to receive the result of the getBatchStatus operation.
* @callback module:api/BatchesApi~getBatchStatusCallback
* @param {String} error Error message, if any.
* @param {module:model/InlineResponse20010} data The data returned by the service call.
* @param {String} response The complete HTTP response.
*/
/**
* Retrieve a Batch Status
* **Get Batch Status**<br>This resource accepts a batch id and returns: - The batch status. - The total number of accepted, rejected, updated records. - The total number of card association responses. - The billable quantities of: - New Account Numbers (NAN) - New Expiry Dates (NED) - Account Closures (ACL) - Contact Card Holders (CCH)
* @param {String} batchId Unique identification number assigned to the submitted request.
* @param {module:api/BatchesApi~getBatchStatusCallback} callback The callback function, accepting three arguments: error, data, response
* data is of type: {@link module:model/InlineResponse20010}
*/
this.getBatchStatus = function(batchId, callback) {
var postBody = null;
if ('GET' == 'POST') {
postBody = '{}';
}
// verify the required parameter 'batchId' is set
if (batchId === undefined || batchId === null) {
throw new Error("Missing the required parameter 'batchId' when calling getBatchStatus");
}
var pathParams = {
'batchId': batchId
};
var queryParams = {
};
var headerParams = {
};
var formParams = {
};
var authNames = [];
var contentTypes = ['application/json;charset=utf-8'];
var accepts = ['application/json;charset=utf-8'];
var returnType = InlineResponse20010;
//check isMLE for an api method 'this.getBatchStatus'
var inboundMLEStatus = 'false';
var isMLEForApi = MLEUtility.checkIsMLEForAPI(this.apiClient.merchantConfig, inboundMLEStatus, 'getBatchStatus');
if (isMLEForApi === true) {
MLEUtility.encryptRequestPayload(this.apiClient.merchantConfig, postBody).then(postBody => {
return this.apiClient.callApi(
'/accountupdater/v1/batches/{batchId}/status', 'GET',
pathParams, queryParams, headerParams, formParams, postBody,
authNames, contentTypes, accepts, returnType, callback
);
});
} else {
return this.apiClient.callApi(
'/accountupdater/v1/batches/{batchId}/status', 'GET',
pathParams, queryParams, headerParams, formParams, postBody,
authNames, contentTypes, accepts, returnType, callback
);
}
}
/**
* Callback function to receive the result of the getBatchesList operation.
* @callback module:api/BatchesApi~getBatchesListCallback
* @param {String} error Error message, if any.
* @param {module:model/InlineResponse2009} data The data returned by the service call.
* @param {String} response The complete HTTP response.
*/
/**
* List Batches
* **List Batches**<br>This resource accepts a optional date range, record offset and limit, returning a paginated response of batches containing: - The batch id. - The batch status. - The batch created / modified dates. - The total number of accepted, rejected, updated records. - The total number of card association responses.
* @param {Object} opts Optional parameters
* @param {Number} opts.offset Starting record in zero-based dataset that should be returned as the first object in the array. (default to 0)
* @param {Number} opts.limit The maximum number that can be returned in the array starting from the offset record in zero-based dataset. (default to 20)
* @param {String} opts.fromDate ISO-8601 format: yyyyMMddTHHmmssZ
* @param {String} opts.toDate ISO-8601 format: yyyyMMddTHHmmssZ
* @param {module:api/BatchesApi~getBatchesListCallback} callback The callback function, accepting three arguments: error, data, response
* data is of type: {@link module:model/InlineResponse2009}
*/
this.getBatchesList = function(opts, callback) {
opts = opts || {};
var postBody = null;
if ('GET' == 'POST') {
postBody = '{}';
}
var pathParams = {
};
var queryParams = {
'offset': opts['offset'],
'limit': opts['limit'],
'fromDate': opts['fromDate'],
'toDate': opts['toDate']
};
var headerParams = {
};
var formParams = {
};
var authNames = [];
var contentTypes = ['application/json;charset=utf-8'];
var accepts = ['application/json;charset=utf-8'];
var returnType = InlineResponse2009;
//check isMLE for an api method 'this.getBatchesList'
var inboundMLEStatus = 'false';
var isMLEForApi = MLEUtility.checkIsMLEForAPI(this.apiClient.merchantConfig, inboundMLEStatus, 'getBatchesList');
if (isMLEForApi === true) {
MLEUtility.encryptRequestPayload(this.apiClient.merchantConfig, postBody).then(postBody => {
return this.apiClient.callApi(
'/accountupdater/v1/batches', 'GET',
pathParams, queryParams, headerParams, formParams, postBody,
authNames, contentTypes, accepts, returnType, callback
);
});
} else {
return this.apiClient.callApi(
'/accountupdater/v1/batches', 'GET',
pathParams, queryParams, headerParams, formParams, postBody,
authNames, contentTypes, accepts, returnType, callback
);
}
}
/**
* Callback function to receive the result of the postBatch operation.
* @callback module:api/BatchesApi~postBatchCallback
* @param {String} error Error message, if any.
* @param {module:model/InlineResponse202} data The data returned by the service call.
* @param {String} response The complete HTTP response.
*/
/**
* Create a Batch
* **Create a Batch**<br>This resource accepts TMS tokens ids of a Customer, Payment Instrument or Instrument Identifier. <br> The card numbers for the supplied tokens ids are then sent to the relevant card associations to check for updates.<br>The following type of batches can be submitted: - **oneOff** batch containing tokens id for Visa or MasterCard card numbers. - **amexRegistration** batch containing tokens id for Amex card numbers. A batch id will be returned on a successful response which can be used to get the batch status and the batch report. The availability of API features for a merchant may depend on the portfolio configuration and may need to be enabled at the portfolio level before they can be added to merchant accounts.
* @param {module:model/Body} body
* @param {module:api/BatchesApi~postBatchCallback} callback The callback function, accepting three arguments: error, data, response
* data is of type: {@link module:model/InlineResponse202}
*/
this.postBatch = function(body, callback) {
var postBody = body;
// verify the required parameter 'body' is set
if (body === undefined || body === null) {
throw new Error("Missing the required parameter 'body' when calling postBatch");
}
var SdkTracker = require('../utilities/tracking/SdkTracker');
var sdkTracker = new SdkTracker();
postBody = sdkTracker.insertDeveloperIdTracker(postBody, 'module:model/Body', this.apiClient.merchantConfig.runEnvironment, this.apiClient.merchantConfig.defaultDeveloperId);
var pathParams = {
};
var queryParams = {
};
var headerParams = {
};
var formParams = {
};
var authNames = [];
var contentTypes = ['application/json;charset=utf-8'];
var accepts = ['application/json;charset=utf-8'];
var returnType = InlineResponse202;
//check isMLE for an api method 'this.postBatch'
var inboundMLEStatus = 'false';
var isMLEForApi = MLEUtility.checkIsMLEForAPI(this.apiClient.merchantConfig, inboundMLEStatus, 'postBatch');
if (isMLEForApi === true) {
MLEUtility.encryptRequestPayload(this.apiClient.merchantConfig, postBody).then(postBody => {
return this.apiClient.callApi(
'/accountupdater/v1/batches', 'POST',
pathParams, queryParams, headerParams, formParams, postBody,
authNames, contentTypes, accepts, returnType, callback
);
});
} else {
return this.apiClient.callApi(
'/accountupdater/v1/batches', 'POST',
pathParams, queryParams, headerParams, formParams, postBody,
authNames, contentTypes, accepts, returnType, callback
);
}
}
};
return exports;
}));