UNPKG

cybersource-rest-client

Version:

Node.js SDK for the CyberSource REST API

178 lines (151 loc) 8.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/InvoiceSettingsRequest', 'model/InvoicingV2InvoiceSettingsGet200Response', 'model/InvoicingV2InvoicesAllGet400Response', 'model/InvoicingV2InvoicesAllGet502Response'], 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/InvoiceSettingsRequest'), require('../model/InvoicingV2InvoiceSettingsGet200Response'), require('../model/InvoicingV2InvoicesAllGet400Response'), require('../model/InvoicingV2InvoicesAllGet502Response')); } else { // Browser globals (root is window) if (!root.CyberSource) { root.CyberSource = {}; } root.CyberSource.InvoiceSettingsApi = factory(root.Authentication.MLEUtility, root.CyberSource.ApiClient, root.CyberSource.InvoiceSettingsRequest, root.CyberSource.InvoicingV2InvoiceSettingsGet200Response, root.CyberSource.InvoicingV2InvoicesAllGet400Response, root.CyberSource.InvoicingV2InvoicesAllGet502Response); } }(this, function(MLEUtility, ApiClient, InvoiceSettingsRequest, InvoicingV2InvoiceSettingsGet200Response, InvoicingV2InvoicesAllGet400Response, InvoicingV2InvoicesAllGet502Response) { 'use strict'; /** * InvoiceSettings service. * @module api/InvoiceSettingsApi * @version 0.0.1 */ /** * Constructs a new InvoiceSettingsApi. * @alias module:api/InvoiceSettingsApi * @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 getInvoiceSettings operation. * @callback module:api/InvoiceSettingsApi~getInvoiceSettingsCallback * @param {String} error Error message, if any. * @param {module:model/InvoicingV2InvoiceSettingsGet200Response} data The data returned by the service call. * @param {String} response The complete HTTP response. */ /** * Get Invoice Settings * Allows you to retrieve the invoice settings for the payment page. * @param {module:api/InvoiceSettingsApi~getInvoiceSettingsCallback} callback The callback function, accepting three arguments: error, data, response * data is of type: {@link module:model/InvoicingV2InvoiceSettingsGet200Response} */ this.getInvoiceSettings = function(callback) { var postBody = null; if ('GET' == 'POST') { postBody = '{}'; } var pathParams = { }; 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 = InvoicingV2InvoiceSettingsGet200Response; //check isMLE for an api method 'this.getInvoiceSettings' var inboundMLEStatus = 'false'; var isMLEForApi = MLEUtility.checkIsMLEForAPI(this.apiClient.merchantConfig, inboundMLEStatus, 'getInvoiceSettings'); if (isMLEForApi === true) { MLEUtility.encryptRequestPayload(this.apiClient.merchantConfig, postBody).then(postBody => { return this.apiClient.callApi( '/invoicing/v2/invoiceSettings', 'GET', pathParams, queryParams, headerParams, formParams, postBody, authNames, contentTypes, accepts, returnType, callback ); }); } else { return this.apiClient.callApi( '/invoicing/v2/invoiceSettings', 'GET', pathParams, queryParams, headerParams, formParams, postBody, authNames, contentTypes, accepts, returnType, callback ); } } /** * Callback function to receive the result of the updateInvoiceSettings operation. * @callback module:api/InvoiceSettingsApi~updateInvoiceSettingsCallback * @param {String} error Error message, if any. * @param {module:model/InvoicingV2InvoiceSettingsGet200Response} data The data returned by the service call. * @param {String} response The complete HTTP response. */ /** * Update Invoice Settings * Allows you to customize the payment page, the checkout experience, email communication and payer authentication. You can customize the invoice to match your brand with your business name, logo and brand colors, and a VAT Tax number. You can choose to capture the payers shipping details, phone number and email during the checkout process. You can add a custom message to all invoice emails and enable or disable payer authentication for invoice payments. * @param {module:model/InvoiceSettingsRequest} invoiceSettingsRequest * @param {module:api/InvoiceSettingsApi~updateInvoiceSettingsCallback} callback The callback function, accepting three arguments: error, data, response * data is of type: {@link module:model/InvoicingV2InvoiceSettingsGet200Response} */ this.updateInvoiceSettings = function(invoiceSettingsRequest, callback) { var postBody = invoiceSettingsRequest; // verify the required parameter 'invoiceSettingsRequest' is set if (invoiceSettingsRequest === undefined || invoiceSettingsRequest === null) { throw new Error("Missing the required parameter 'invoiceSettingsRequest' when calling updateInvoiceSettings"); } var SdkTracker = require('../utilities/tracking/SdkTracker'); var sdkTracker = new SdkTracker(); postBody = sdkTracker.insertDeveloperIdTracker(postBody, 'module:model/InvoiceSettingsRequest', 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', 'application/hal+json', 'application/json;charset=utf-8', 'application/hal+json;charset=utf-8']; var returnType = InvoicingV2InvoiceSettingsGet200Response; //check isMLE for an api method 'this.updateInvoiceSettings' var inboundMLEStatus = 'false'; var isMLEForApi = MLEUtility.checkIsMLEForAPI(this.apiClient.merchantConfig, inboundMLEStatus, 'updateInvoiceSettings'); if (isMLEForApi === true) { MLEUtility.encryptRequestPayload(this.apiClient.merchantConfig, postBody).then(postBody => { return this.apiClient.callApi( '/invoicing/v2/invoiceSettings', 'PUT', pathParams, queryParams, headerParams, formParams, postBody, authNames, contentTypes, accepts, returnType, callback ); }); } else { return this.apiClient.callApi( '/invoicing/v2/invoiceSettings', 'PUT', pathParams, queryParams, headerParams, formParams, postBody, authNames, contentTypes, accepts, returnType, callback ); } } }; return exports; }));