UNPKG

cybersource-rest-client

Version:

Node.js SDK for the CyberSource REST API

192 lines (163 loc) 8.78 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/CreateSubscriptionRequest1', 'model/CreateSubscriptionResponse', 'model/GetSubscriptionResponse1', 'model/InlineResponse4005', 'model/InlineResponse404', 'model/PtsV2PaymentsPost502Response'], 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/CreateSubscriptionRequest1'), require('../model/CreateSubscriptionResponse'), require('../model/GetSubscriptionResponse1'), require('../model/InlineResponse4005'), require('../model/InlineResponse404'), require('../model/PtsV2PaymentsPost502Response')); } else { // Browser globals (root is window) if (!root.CyberSource) { root.CyberSource = {}; } root.CyberSource.SubscriptionsFollowOnsApi = factory(root.Authentication.MLEUtility, root.CyberSource.ApiClient, root.CyberSource.CreateSubscriptionRequest1, root.CyberSource.CreateSubscriptionResponse, root.CyberSource.GetSubscriptionResponse1, root.CyberSource.InlineResponse4005, root.CyberSource.InlineResponse404, root.CyberSource.PtsV2PaymentsPost502Response); } }(this, function(MLEUtility, ApiClient, CreateSubscriptionRequest1, CreateSubscriptionResponse, GetSubscriptionResponse1, InlineResponse4005, InlineResponse404, PtsV2PaymentsPost502Response) { 'use strict'; /** * SubscriptionsFollowOns service. * @module api/SubscriptionsFollowOnsApi * @version 0.0.1 */ /** * Constructs a new SubscriptionsFollowOnsApi. * @alias module:api/SubscriptionsFollowOnsApi * @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 createFollowOnSubscription operation. * @callback module:api/SubscriptionsFollowOnsApi~createFollowOnSubscriptionCallback * @param {String} error Error message, if any. * @param {module:model/CreateSubscriptionResponse} data The data returned by the service call. * @param {String} response The complete HTTP response. */ /** * Create a Follow-On Subscription * Create a new Subscription based on the Request Id of an existing successful Transaction. * @param {String} requestId Request Id of an existing successful Transaction * @param {module:model/CreateSubscriptionRequest1} createSubscriptionRequest * @param {module:api/SubscriptionsFollowOnsApi~createFollowOnSubscriptionCallback} callback The callback function, accepting three arguments: error, data, response * data is of type: {@link module:model/CreateSubscriptionResponse} */ this.createFollowOnSubscription = function(requestId, createSubscriptionRequest, callback) { var postBody = createSubscriptionRequest; // verify the required parameter 'requestId' is set if (requestId === undefined || requestId === null) { throw new Error("Missing the required parameter 'requestId' when calling createFollowOnSubscription"); } // verify the required parameter 'createSubscriptionRequest' is set if (createSubscriptionRequest === undefined || createSubscriptionRequest === null) { throw new Error("Missing the required parameter 'createSubscriptionRequest' when calling createFollowOnSubscription"); } var SdkTracker = require('../utilities/tracking/SdkTracker'); var sdkTracker = new SdkTracker(); postBody = sdkTracker.insertDeveloperIdTracker(postBody, 'module:model/CreateSubscriptionRequest1', this.apiClient.merchantConfig.runEnvironment, this.apiClient.merchantConfig.defaultDeveloperId); var pathParams = { 'requestId': requestId }; var queryParams = { }; var headerParams = { }; var formParams = { }; var authNames = []; var contentTypes = ['application/json;charset=utf-8']; var accepts = ['application/json', 'application/hal+json', 'application/json;charset=utf-8', 'application/hal+json;charset=utf-8']; var returnType = CreateSubscriptionResponse; //check isMLE for an api method 'this.createFollowOnSubscription' var inboundMLEStatus = 'false'; var isMLEForApi = MLEUtility.checkIsMLEForAPI(this.apiClient.merchantConfig, inboundMLEStatus, 'createFollowOnSubscription'); if (isMLEForApi === true) { MLEUtility.encryptRequestPayload(this.apiClient.merchantConfig, postBody).then(postBody => { return this.apiClient.callApi( '/rbs/v1/subscriptions/follow-ons/{requestId}', 'POST', pathParams, queryParams, headerParams, formParams, postBody, authNames, contentTypes, accepts, returnType, callback ); }); } else { return this.apiClient.callApi( '/rbs/v1/subscriptions/follow-ons/{requestId}', 'POST', pathParams, queryParams, headerParams, formParams, postBody, authNames, contentTypes, accepts, returnType, callback ); } } /** * Callback function to receive the result of the getFollowOnSubscription operation. * @callback module:api/SubscriptionsFollowOnsApi~getFollowOnSubscriptionCallback * @param {String} error Error message, if any. * @param {module:model/GetSubscriptionResponse1} data The data returned by the service call. * @param {String} response The complete HTTP response. */ /** * Get a Follow-On Subscription * Get details of the Subscription being created based on the Request Id of an existing successful Transaction. * @param {String} requestId Request Id of an existing successful Transaction * @param {module:api/SubscriptionsFollowOnsApi~getFollowOnSubscriptionCallback} callback The callback function, accepting three arguments: error, data, response * data is of type: {@link module:model/GetSubscriptionResponse1} */ this.getFollowOnSubscription = function(requestId, callback) { var postBody = null; if ('GET' == 'POST') { postBody = '{}'; } // verify the required parameter 'requestId' is set if (requestId === undefined || requestId === null) { throw new Error("Missing the required parameter 'requestId' when calling getFollowOnSubscription"); } var pathParams = { 'requestId': requestId }; var queryParams = { }; var headerParams = { }; var formParams = { }; var authNames = []; var contentTypes = ['application/json;charset=utf-8']; var accepts = ['application/json', 'application/hal+json', 'application/json;charset=utf-8', 'application/hal+json;charset=utf-8']; var returnType = GetSubscriptionResponse1; //check isMLE for an api method 'this.getFollowOnSubscription' var inboundMLEStatus = 'false'; var isMLEForApi = MLEUtility.checkIsMLEForAPI(this.apiClient.merchantConfig, inboundMLEStatus, 'getFollowOnSubscription'); if (isMLEForApi === true) { MLEUtility.encryptRequestPayload(this.apiClient.merchantConfig, postBody).then(postBody => { return this.apiClient.callApi( '/rbs/v1/subscriptions/follow-ons/{requestId}', 'GET', pathParams, queryParams, headerParams, formParams, postBody, authNames, contentTypes, accepts, returnType, callback ); }); } else { return this.apiClient.callApi( '/rbs/v1/subscriptions/follow-ons/{requestId}', 'GET', pathParams, queryParams, headerParams, formParams, postBody, authNames, contentTypes, accepts, returnType, callback ); } } }; return exports; }));