UNPKG

cybersource-rest-client

Version:

Node.js SDK for the CyberSource REST API

120 lines (102 loc) 5.07 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/InlineResponse201', 'model/PtsV2RetrievePaymentTokenGet400Response', 'model/PtsV2RetrievePaymentTokenGet502Response', 'model/Request'], 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/InlineResponse201'), require('../model/PtsV2RetrievePaymentTokenGet400Response'), require('../model/PtsV2RetrievePaymentTokenGet502Response'), require('../model/Request')); } else { // Browser globals (root is window) if (!root.CyberSource) { root.CyberSource = {}; } root.CyberSource.PaymentTokensApi = factory(root.Authentication.MLEUtility, root.CyberSource.ApiClient, root.CyberSource.InlineResponse201, root.CyberSource.PtsV2RetrievePaymentTokenGet400Response, root.CyberSource.PtsV2RetrievePaymentTokenGet502Response, root.CyberSource.Request); } }(this, function(MLEUtility, ApiClient, InlineResponse201, PtsV2RetrievePaymentTokenGet400Response, PtsV2RetrievePaymentTokenGet502Response, Request) { 'use strict'; /** * PaymentTokens service. * @module api/PaymentTokensApi * @version 0.0.1 */ /** * Constructs a new PaymentTokensApi. * @alias module:api/PaymentTokensApi * @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 retrieveOrDeletePaymentToken operation. * @callback module:api/PaymentTokensApi~retrieveOrDeletePaymentTokenCallback * @param {String} error Error message, if any. * @param {module:model/InlineResponse201} data The data returned by the service call. * @param {String} response The complete HTTP response. */ /** * Retrieve or Delete Payment Token * This API can be used in two flavours - for retrieval or deletion of vault id. * @param {module:model/Request} request * @param {module:api/PaymentTokensApi~retrieveOrDeletePaymentTokenCallback} callback The callback function, accepting three arguments: error, data, response * data is of type: {@link module:model/InlineResponse201} */ this.retrieveOrDeletePaymentToken = function(request, callback) { var postBody = request; // verify the required parameter 'request' is set if (request === undefined || request === null) { throw new Error("Missing the required parameter 'request' when calling retrieveOrDeletePaymentToken"); } var SdkTracker = require('../utilities/tracking/SdkTracker'); var sdkTracker = new SdkTracker(); postBody = sdkTracker.insertDeveloperIdTracker(postBody, 'module:model/Request', 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/hal+json;charset=utf-8']; var returnType = InlineResponse201; //check isMLE for an api method 'this.retrieveOrDeletePaymentToken' var inboundMLEStatus = 'false'; var isMLEForApi = MLEUtility.checkIsMLEForAPI(this.apiClient.merchantConfig, inboundMLEStatus, 'retrieveOrDeletePaymentToken'); if (isMLEForApi === true) { MLEUtility.encryptRequestPayload(this.apiClient.merchantConfig, postBody).then(postBody => { return this.apiClient.callApi( '/pts/v2/payment-tokens', 'POST', pathParams, queryParams, headerParams, formParams, postBody, authNames, contentTypes, accepts, returnType, callback ); }); } else { return this.apiClient.callApi( '/pts/v2/payment-tokens', 'POST', pathParams, queryParams, headerParams, formParams, postBody, authNames, contentTypes, accepts, returnType, callback ); } } }; return exports; }));