UNPKG

cybersource-rest-client

Version:

Node.js SDK for the CyberSource REST API

338 lines (285 loc) 15.1 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/InlineResponse2003', 'model/InlineResponse4041', 'model/MerchantDefinedFieldCore', 'model/MerchantDefinedFieldDefinitionRequest'], 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/InlineResponse2003'), require('../model/InlineResponse4041'), require('../model/MerchantDefinedFieldCore'), require('../model/MerchantDefinedFieldDefinitionRequest')); } else { // Browser globals (root is window) if (!root.CyberSource) { root.CyberSource = {}; } root.CyberSource.MerchantDefinedFieldsApi = factory(root.Authentication.MLEUtility, root.CyberSource.ApiClient, root.CyberSource.InlineResponse2003, root.CyberSource.InlineResponse4041, root.CyberSource.MerchantDefinedFieldCore, root.CyberSource.MerchantDefinedFieldDefinitionRequest); } }(this, function(MLEUtility, ApiClient, InlineResponse2003, InlineResponse4041, MerchantDefinedFieldCore, MerchantDefinedFieldDefinitionRequest) { 'use strict'; /** * MerchantDefinedFields service. * @module api/MerchantDefinedFieldsApi * @version 0.0.1 */ /** * Constructs a new MerchantDefinedFieldsApi. * @alias module:api/MerchantDefinedFieldsApi * @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 createMerchantDefinedFieldDefinition operation. * @callback module:api/MerchantDefinedFieldsApi~createMerchantDefinedFieldDefinitionCallback * @param {String} error Error message, if any. * @param {Array.<module:model/InlineResponse2003>} data The data returned by the service call. * @param {String} response The complete HTTP response. */ /** * Create merchant defined field for a given reference type * @param {module:model/String} referenceType The reference type for which merchant defined fields are to be fetched. Available values are Invoice, Purchase, Donation * @param {module:model/MerchantDefinedFieldDefinitionRequest} merchantDefinedFieldDefinitionRequest * @param {module:api/MerchantDefinedFieldsApi~createMerchantDefinedFieldDefinitionCallback} callback The callback function, accepting three arguments: error, data, response * data is of type: {@link Array.<module:model/InlineResponse2003>} */ this.createMerchantDefinedFieldDefinition = function(referenceType, merchantDefinedFieldDefinitionRequest, callback) { var postBody = merchantDefinedFieldDefinitionRequest; // verify the required parameter 'referenceType' is set if (referenceType === undefined || referenceType === null) { throw new Error("Missing the required parameter 'referenceType' when calling createMerchantDefinedFieldDefinition"); } // verify the required parameter 'merchantDefinedFieldDefinitionRequest' is set if (merchantDefinedFieldDefinitionRequest === undefined || merchantDefinedFieldDefinitionRequest === null) { throw new Error("Missing the required parameter 'merchantDefinedFieldDefinitionRequest' when calling createMerchantDefinedFieldDefinition"); } var SdkTracker = require('../utilities/tracking/SdkTracker'); var sdkTracker = new SdkTracker(); postBody = sdkTracker.insertDeveloperIdTracker(postBody, 'module:model/MerchantDefinedFieldDefinitionRequest', this.apiClient.merchantConfig.runEnvironment, this.apiClient.merchantConfig.defaultDeveloperId); var pathParams = { 'referenceType': referenceType }; var queryParams = { }; var headerParams = { }; var formParams = { }; var authNames = []; var contentTypes = ['application/json']; var accepts = ['application/json']; var returnType = [InlineResponse2003]; //check isMLE for an api method 'this.createMerchantDefinedFieldDefinition' var inboundMLEStatus = 'false'; var isMLEForApi = MLEUtility.checkIsMLEForAPI(this.apiClient.merchantConfig, inboundMLEStatus, 'createMerchantDefinedFieldDefinition'); if (isMLEForApi === true) { MLEUtility.encryptRequestPayload(this.apiClient.merchantConfig, postBody).then(postBody => { return this.apiClient.callApi( '/invoicing/v2/{referenceType}/merchantDefinedFields', 'POST', pathParams, queryParams, headerParams, formParams, postBody, authNames, contentTypes, accepts, returnType, callback ); }); } else { return this.apiClient.callApi( '/invoicing/v2/{referenceType}/merchantDefinedFields', 'POST', pathParams, queryParams, headerParams, formParams, postBody, authNames, contentTypes, accepts, returnType, callback ); } } /** * Callback function to receive the result of the deleteMerchantDefinedFieldsDefinitions operation. * @callback module:api/MerchantDefinedFieldsApi~deleteMerchantDefinedFieldsDefinitionsCallback * @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 MerchantDefinedField by ID * @param {module:model/String} referenceType * @param {Number} id * @param {module:api/MerchantDefinedFieldsApi~deleteMerchantDefinedFieldsDefinitionsCallback} callback The callback function, accepting three arguments: error, data, response */ this.deleteMerchantDefinedFieldsDefinitions = function(referenceType, id, callback) { var postBody = null; if ('DELETE' == 'POST') { postBody = '{}'; } // verify the required parameter 'referenceType' is set if (referenceType === undefined || referenceType === null) { throw new Error("Missing the required parameter 'referenceType' when calling deleteMerchantDefinedFieldsDefinitions"); } // verify the required parameter 'id' is set if (id === undefined || id === null) { throw new Error("Missing the required parameter 'id' when calling deleteMerchantDefinedFieldsDefinitions"); } var pathParams = { 'referenceType': referenceType, 'id': id }; 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 = null; //check isMLE for an api method 'this.deleteMerchantDefinedFieldsDefinitions' var inboundMLEStatus = 'false'; var isMLEForApi = MLEUtility.checkIsMLEForAPI(this.apiClient.merchantConfig, inboundMLEStatus, 'deleteMerchantDefinedFieldsDefinitions'); if (isMLEForApi === true) { MLEUtility.encryptRequestPayload(this.apiClient.merchantConfig, postBody).then(postBody => { return this.apiClient.callApi( '/invoicing/v2/{referenceType}/merchantDefinedFields/{id}', 'DELETE', pathParams, queryParams, headerParams, formParams, postBody, authNames, contentTypes, accepts, returnType, callback ); }); } else { return this.apiClient.callApi( '/invoicing/v2/{referenceType}/merchantDefinedFields/{id}', 'DELETE', pathParams, queryParams, headerParams, formParams, postBody, authNames, contentTypes, accepts, returnType, callback ); } } /** * Callback function to receive the result of the getMerchantDefinedFieldsDefinitions operation. * @callback module:api/MerchantDefinedFieldsApi~getMerchantDefinedFieldsDefinitionsCallback * @param {String} error Error message, if any. * @param {Array.<module:model/InlineResponse2003>} data The data returned by the service call. * @param {String} response The complete HTTP response. */ /** * Get all merchant defined fields for a given reference type * @param {module:model/String} referenceType The reference type for which merchant defined fields are to be fetched. Available values are Invoice, Purchase, Donation * @param {module:api/MerchantDefinedFieldsApi~getMerchantDefinedFieldsDefinitionsCallback} callback The callback function, accepting three arguments: error, data, response * data is of type: {@link Array.<module:model/InlineResponse2003>} */ this.getMerchantDefinedFieldsDefinitions = function(referenceType, callback) { var postBody = null; if ('GET' == 'POST') { postBody = '{}'; } // verify the required parameter 'referenceType' is set if (referenceType === undefined || referenceType === null) { throw new Error("Missing the required parameter 'referenceType' when calling getMerchantDefinedFieldsDefinitions"); } var pathParams = { 'referenceType': referenceType }; var queryParams = { }; var headerParams = { }; var formParams = { }; var authNames = []; var contentTypes = ['application/json']; var accepts = ['application/json']; var returnType = [InlineResponse2003]; //check isMLE for an api method 'this.getMerchantDefinedFieldsDefinitions' var inboundMLEStatus = 'false'; var isMLEForApi = MLEUtility.checkIsMLEForAPI(this.apiClient.merchantConfig, inboundMLEStatus, 'getMerchantDefinedFieldsDefinitions'); if (isMLEForApi === true) { MLEUtility.encryptRequestPayload(this.apiClient.merchantConfig, postBody).then(postBody => { return this.apiClient.callApi( '/invoicing/v2/{referenceType}/merchantDefinedFields', 'GET', pathParams, queryParams, headerParams, formParams, postBody, authNames, contentTypes, accepts, returnType, callback ); }); } else { return this.apiClient.callApi( '/invoicing/v2/{referenceType}/merchantDefinedFields', 'GET', pathParams, queryParams, headerParams, formParams, postBody, authNames, contentTypes, accepts, returnType, callback ); } } /** * Callback function to receive the result of the putMerchantDefinedFieldsDefinitions operation. * @callback module:api/MerchantDefinedFieldsApi~putMerchantDefinedFieldsDefinitionsCallback * @param {String} error Error message, if any. * @param {Array.<module:model/InlineResponse2003>} data The data returned by the service call. * @param {String} response The complete HTTP response. */ /** * Update a MerchantDefinedField by ID * @param {module:model/String} referenceType * @param {Number} id * @param {module:model/MerchantDefinedFieldCore} merchantDefinedFieldCore * @param {module:api/MerchantDefinedFieldsApi~putMerchantDefinedFieldsDefinitionsCallback} callback The callback function, accepting three arguments: error, data, response * data is of type: {@link Array.<module:model/InlineResponse2003>} */ this.putMerchantDefinedFieldsDefinitions = function(referenceType, id, merchantDefinedFieldCore, callback) { var postBody = merchantDefinedFieldCore; // verify the required parameter 'referenceType' is set if (referenceType === undefined || referenceType === null) { throw new Error("Missing the required parameter 'referenceType' when calling putMerchantDefinedFieldsDefinitions"); } // verify the required parameter 'id' is set if (id === undefined || id === null) { throw new Error("Missing the required parameter 'id' when calling putMerchantDefinedFieldsDefinitions"); } // verify the required parameter 'merchantDefinedFieldCore' is set if (merchantDefinedFieldCore === undefined || merchantDefinedFieldCore === null) { throw new Error("Missing the required parameter 'merchantDefinedFieldCore' when calling putMerchantDefinedFieldsDefinitions"); } var SdkTracker = require('../utilities/tracking/SdkTracker'); var sdkTracker = new SdkTracker(); postBody = sdkTracker.insertDeveloperIdTracker(postBody, 'module:model/MerchantDefinedFieldCore', this.apiClient.merchantConfig.runEnvironment, this.apiClient.merchantConfig.defaultDeveloperId); var pathParams = { 'referenceType': referenceType, 'id': id }; 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 = [InlineResponse2003]; //check isMLE for an api method 'this.putMerchantDefinedFieldsDefinitions' var inboundMLEStatus = 'false'; var isMLEForApi = MLEUtility.checkIsMLEForAPI(this.apiClient.merchantConfig, inboundMLEStatus, 'putMerchantDefinedFieldsDefinitions'); if (isMLEForApi === true) { MLEUtility.encryptRequestPayload(this.apiClient.merchantConfig, postBody).then(postBody => { return this.apiClient.callApi( '/invoicing/v2/{referenceType}/merchantDefinedFields/{id}', 'PUT', pathParams, queryParams, headerParams, formParams, postBody, authNames, contentTypes, accepts, returnType, callback ); }); } else { return this.apiClient.callApi( '/invoicing/v2/{referenceType}/merchantDefinedFields/{id}', 'PUT', pathParams, queryParams, headerParams, formParams, postBody, authNames, contentTypes, accepts, returnType, callback ); } } }; return exports; }));