UNPKG

cybersource-rest-client

Version:

Node.js SDK for the CyberSource REST API

261 lines (223 loc) 11.5 kB
/** * 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/InlineResponse400', 'model/InlineResponse403', 'model/InlineResponse409', 'model/InlineResponse410', 'model/InlineResponse424', 'model/InlineResponse500', 'model/TokenizedcardRequest'], 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/InlineResponse400'), require('../model/InlineResponse403'), require('../model/InlineResponse409'), require('../model/InlineResponse410'), require('../model/InlineResponse424'), require('../model/InlineResponse500'), require('../model/TokenizedcardRequest')); } else { // Browser globals (root is window) if (!root.CyberSource) { root.CyberSource = {}; } root.CyberSource.TokenizedCardApi = factory(root.Authentication.MLEUtility, root.CyberSource.ApiClient, root.CyberSource.InlineResponse400, root.CyberSource.InlineResponse403, root.CyberSource.InlineResponse409, root.CyberSource.InlineResponse410, root.CyberSource.InlineResponse424, root.CyberSource.InlineResponse500, root.CyberSource.TokenizedcardRequest); } }(this, function(MLEUtility, ApiClient, InlineResponse400, InlineResponse403, InlineResponse409, InlineResponse410, InlineResponse424, InlineResponse500, TokenizedcardRequest) { 'use strict'; /** * TokenizedCard service. * @module api/TokenizedCardApi * @version 0.0.1 */ /** * Constructs a new TokenizedCardApi. * @alias module:api/TokenizedCardApi * @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 deleteTokenizedCard operation. * @callback module:api/TokenizedCardApi~deleteTokenizedCardCallback * @param {String} error Error message, if any. * @param data This operation does not return a value. * @param {String} response The complete HTTP response. */ /** * Delete a Tokenized Card * | | | | | --- | --- | --- | | The Network Token will attempt to be deleted from the card association and if successful the corresponding TMS Network Token will be deleted. * @param {String} tokenizedCardId The Id of a tokenized card. * @param {Object} opts Optional parameters * @param {String} opts.profileId The Id of a profile containing user specific TMS configuration. * @param {module:api/TokenizedCardApi~deleteTokenizedCardCallback} callback The callback function, accepting three arguments: error, data, response */ this.deleteTokenizedCard = function(tokenizedCardId, opts, callback) { opts = opts || {}; var postBody = null; if ('DELETE' == 'POST') { postBody = '{}'; } // verify the required parameter 'tokenizedCardId' is set if (tokenizedCardId === undefined || tokenizedCardId === null) { throw new Error("Missing the required parameter 'tokenizedCardId' when calling deleteTokenizedCard"); } var pathParams = { 'tokenizedCardId': tokenizedCardId }; var queryParams = { }; var headerParams = { 'profile-id': opts['profileId'] }; var formParams = { }; var authNames = []; var contentTypes = ['application/json;charset=utf-8']; var accepts = ['application/json;charset=utf-8']; var returnType = null; //check isMLE for an api method 'this.deleteTokenizedCard' var inboundMLEStatus = 'false'; var isMLEForApi = MLEUtility.checkIsMLEForAPI(this.apiClient.merchantConfig, inboundMLEStatus, 'deleteTokenizedCard'); if (isMLEForApi === true) { MLEUtility.encryptRequestPayload(this.apiClient.merchantConfig, postBody).then(postBody => { return this.apiClient.callApi( '/tms/v2/tokenized-cards/{tokenizedCardId}', 'DELETE', pathParams, queryParams, headerParams, formParams, postBody, authNames, contentTypes, accepts, returnType, callback ); }); } else { return this.apiClient.callApi( '/tms/v2/tokenized-cards/{tokenizedCardId}', 'DELETE', pathParams, queryParams, headerParams, formParams, postBody, authNames, contentTypes, accepts, returnType, callback ); } } /** * Callback function to receive the result of the getTokenizedCard operation. * @callback module:api/TokenizedCardApi~getTokenizedCardCallback * @param {String} error Error message, if any. * @param {module:model/TokenizedcardRequest} data The data returned by the service call. * @param {String} response The complete HTTP response. */ /** * Retrieve a Tokenized Card * | | | | | --- | --- | --- | |**Tokenized Cards**<br>A Tokenized Card represents a network token. Network tokens perform better than regular card numbers and they are not necessarily invalidated when a cardholder loses their card, or it expires. * @param {String} tokenizedCardId The Id of a tokenized card. * @param {Object} opts Optional parameters * @param {String} opts.profileId The Id of a profile containing user specific TMS configuration. * @param {module:api/TokenizedCardApi~getTokenizedCardCallback} callback The callback function, accepting three arguments: error, data, response * data is of type: {@link module:model/TokenizedcardRequest} */ this.getTokenizedCard = function(tokenizedCardId, opts, callback) { opts = opts || {}; var postBody = null; if ('GET' == 'POST') { postBody = '{}'; } // verify the required parameter 'tokenizedCardId' is set if (tokenizedCardId === undefined || tokenizedCardId === null) { throw new Error("Missing the required parameter 'tokenizedCardId' when calling getTokenizedCard"); } var pathParams = { 'tokenizedCardId': tokenizedCardId }; var queryParams = { }; var headerParams = { 'profile-id': opts['profileId'] }; var formParams = { }; var authNames = []; var contentTypes = ['application/json;charset=utf-8']; var accepts = ['application/json;charset=utf-8']; var returnType = TokenizedcardRequest; //check isMLE for an api method 'this.getTokenizedCard' var inboundMLEStatus = 'false'; var isMLEForApi = MLEUtility.checkIsMLEForAPI(this.apiClient.merchantConfig, inboundMLEStatus, 'getTokenizedCard'); if (isMLEForApi === true) { MLEUtility.encryptRequestPayload(this.apiClient.merchantConfig, postBody).then(postBody => { return this.apiClient.callApi( '/tms/v2/tokenized-cards/{tokenizedCardId}', 'GET', pathParams, queryParams, headerParams, formParams, postBody, authNames, contentTypes, accepts, returnType, callback ); }); } else { return this.apiClient.callApi( '/tms/v2/tokenized-cards/{tokenizedCardId}', 'GET', pathParams, queryParams, headerParams, formParams, postBody, authNames, contentTypes, accepts, returnType, callback ); } } /** * Callback function to receive the result of the postTokenizedCard operation. * @callback module:api/TokenizedCardApi~postTokenizedCardCallback * @param {String} error Error message, if any. * @param {module:model/TokenizedcardRequest} data The data returned by the service call. * @param {String} response The complete HTTP response. */ /** * Create a Tokenized Card * | | | | | --- | --- | --- | |**Tokenized cards**<br>A Tokenized card represents a network token. Network tokens perform better than regular card numbers and they are not necessarily invalidated when a cardholder loses their card, or it expires. * @param {module:model/TokenizedcardRequest} tokenizedcardRequest * @param {Object} opts Optional parameters * @param {String} opts.profileId The Id of a profile containing user specific TMS configuration. * @param {module:api/TokenizedCardApi~postTokenizedCardCallback} callback The callback function, accepting three arguments: error, data, response * data is of type: {@link module:model/TokenizedcardRequest} */ this.postTokenizedCard = function(tokenizedcardRequest, opts, callback) { opts = opts || {}; var postBody = tokenizedcardRequest; // verify the required parameter 'tokenizedcardRequest' is set if (tokenizedcardRequest === undefined || tokenizedcardRequest === null) { throw new Error("Missing the required parameter 'tokenizedcardRequest' when calling postTokenizedCard"); } var SdkTracker = require('../utilities/tracking/SdkTracker'); var sdkTracker = new SdkTracker(); postBody = sdkTracker.insertDeveloperIdTracker(postBody, 'module:model/TokenizedcardRequest', this.apiClient.merchantConfig.runEnvironment, this.apiClient.merchantConfig.defaultDeveloperId); var pathParams = { }; var queryParams = { }; var headerParams = { 'profile-id': opts['profileId'] }; var formParams = { }; var authNames = []; var contentTypes = ['application/json;charset=utf-8']; var accepts = ['application/json;charset=utf-8']; var returnType = TokenizedcardRequest; //check isMLE for an api method 'this.postTokenizedCard' var inboundMLEStatus = 'false'; var isMLEForApi = MLEUtility.checkIsMLEForAPI(this.apiClient.merchantConfig, inboundMLEStatus, 'postTokenizedCard'); if (isMLEForApi === true) { MLEUtility.encryptRequestPayload(this.apiClient.merchantConfig, postBody).then(postBody => { return this.apiClient.callApi( '/tms/v2/tokenized-cards', 'POST', pathParams, queryParams, headerParams, formParams, postBody, authNames, contentTypes, accepts, returnType, callback ); }); } else { return this.apiClient.callApi( '/tms/v2/tokenized-cards', 'POST', pathParams, queryParams, headerParams, formParams, postBody, authNames, contentTypes, accepts, returnType, callback ); } } }; return exports; }));