cybersource-rest-client
Version:
Node.js SDK for the CyberSource REST API
260 lines (221 loc) • 12.4 kB
JavaScript
/**
* 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/CreateWebhook', 'model/InlineResponse2003', 'model/InlineResponse2014', 'model/InlineResponse2015', 'model/SaveSymEgressKey'], 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/CreateWebhook'), require('../model/InlineResponse2003'), require('../model/InlineResponse2014'), require('../model/InlineResponse2015'), require('../model/SaveSymEgressKey'));
} else {
// Browser globals (root is window)
if (!root.CyberSource) {
root.CyberSource = {};
}
root.CyberSource.CreateNewWebhooksApi = factory(root.Authentication.MLEUtility, root.CyberSource.ApiClient, root.CyberSource.CreateWebhook, root.CyberSource.InlineResponse2003, root.CyberSource.InlineResponse2014, root.CyberSource.InlineResponse2015, root.CyberSource.SaveSymEgressKey);
}
}(this, function(MLEUtility, ApiClient, CreateWebhook, InlineResponse2003, InlineResponse2014, InlineResponse2015, SaveSymEgressKey) {
'use strict';
/**
* CreateNewWebhooks service.
* @module api/CreateNewWebhooksApi
* @version 0.0.1
*/
/**
* Constructs a new CreateNewWebhooksApi.
* @alias module:api/CreateNewWebhooksApi
* @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 findProductsToSubscribe operation.
* @callback module:api/CreateNewWebhooksApi~findProductsToSubscribeCallback
* @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.
*/
/**
* Find Products You Can Subscribe To
* Retrieve a list of products and event types that your account is eligible for. These products and events are the ones that you may subscribe to in the next step of creating webhooks.
* @param {String} organizationId The Organization Identifier.
* @param {module:api/CreateNewWebhooksApi~findProductsToSubscribeCallback} callback The callback function, accepting three arguments: error, data, response
* data is of type: {@link Array.<module:model/InlineResponse2003>}
*/
this.findProductsToSubscribe = function(organizationId, callback) {
var postBody = null;
if ('GET' == 'POST') {
postBody = '{}';
}
// verify the required parameter 'organizationId' is set
if (organizationId === undefined || organizationId === null) {
throw new Error("Missing the required parameter 'organizationId' when calling findProductsToSubscribe");
}
var pathParams = {
'organizationId': organizationId
};
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.findProductsToSubscribe'
var inboundMLEStatus = 'false';
var isMLEForApi = MLEUtility.checkIsMLEForAPI(this.apiClient.merchantConfig, inboundMLEStatus, 'findProductsToSubscribe');
if (isMLEForApi === true) {
MLEUtility.encryptRequestPayload(this.apiClient.merchantConfig, postBody).then(postBody => {
return this.apiClient.callApi(
'/notification-subscriptions/v2/products/{organizationId}', 'GET',
pathParams, queryParams, headerParams, formParams, postBody,
authNames, contentTypes, accepts, returnType, callback
);
});
} else {
return this.apiClient.callApi(
'/notification-subscriptions/v2/products/{organizationId}', 'GET',
pathParams, queryParams, headerParams, formParams, postBody,
authNames, contentTypes, accepts, returnType, callback
);
}
}
/**
* Callback function to receive the result of the notificationSubscriptionsV2WebhooksPost operation.
* @callback module:api/CreateNewWebhooksApi~notificationSubscriptionsV2WebhooksPostCallback
* @param {String} error Error message, if any.
* @param {module:model/InlineResponse2015} data The data returned by the service call.
* @param {String} response The complete HTTP response.
*/
/**
* Create a New Webhook Subscription
* Create a new webhook subscription. Before creating a webhook, ensure that a signature key has been created. For the example \"Create Webhook using oAuth with Client Credentials\" - for clients who have more than one oAuth Provider and have different client secrets that they would like to config for a given webhook, they may do so by overriding the keyId inside security config of webhook subscription. See the Developer Center examples section titled \"Webhook Security - Create or Store Egress Symmetric Key - Store oAuth Credentials For Symmetric Key\" to store these oAuth credentials that CYBS will need for oAuth. For JWT authentication, attach your oAuth details to the webhook subscription. See the example \"Create Webhook using oAuth with JWT\"
* @param {Object} opts Optional parameters
* @param {module:model/CreateWebhook} opts.createWebhook The webhook payload
* @param {module:api/CreateNewWebhooksApi~notificationSubscriptionsV2WebhooksPostCallback} callback The callback function, accepting three arguments: error, data, response
* data is of type: {@link module:model/InlineResponse2015}
*/
this.notificationSubscriptionsV2WebhooksPost = function(opts, callback) {
opts = opts || {};
var postBody = opts['createWebhook'];
var SdkTracker = require('../utilities/tracking/SdkTracker');
var sdkTracker = new SdkTracker();
postBody = sdkTracker.insertDeveloperIdTracker(postBody, 'module:model/CreateWebhook', 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 = InlineResponse2015;
//check isMLE for an api method 'this.notificationSubscriptionsV2WebhooksPost'
var inboundMLEStatus = 'false';
var isMLEForApi = MLEUtility.checkIsMLEForAPI(this.apiClient.merchantConfig, inboundMLEStatus, 'notificationSubscriptionsV2WebhooksPost');
if (isMLEForApi === true) {
MLEUtility.encryptRequestPayload(this.apiClient.merchantConfig, postBody).then(postBody => {
return this.apiClient.callApi(
'/notification-subscriptions/v2/webhooks', 'POST',
pathParams, queryParams, headerParams, formParams, postBody,
authNames, contentTypes, accepts, returnType, callback
);
});
} else {
return this.apiClient.callApi(
'/notification-subscriptions/v2/webhooks', 'POST',
pathParams, queryParams, headerParams, formParams, postBody,
authNames, contentTypes, accepts, returnType, callback
);
}
}
/**
* Callback function to receive the result of the saveSymEgressKey operation.
* @callback module:api/CreateNewWebhooksApi~saveSymEgressKeyCallback
* @param {String} error Error message, if any.
* @param {module:model/InlineResponse2014} data The data returned by the service call.
* @param {String} response The complete HTTP response.
*/
/**
* Create Webhook Security Keys
* Create security keys that CyberSource will use internally to connect to your servers and validate messages using a digital signature. Select the CREATE example for CyberSource to generate the key on our server and maintain it for you as well. Remember to save the key in the API response, so that you can use it to validate messages later.
* @param {String} vCSenderOrganizationId Sender organization id
* @param {String} vCPermissions Encoded user permissions returned by the CGK, for the entity user who initiated the boarding
* @param {Object} opts Optional parameters
* @param {String} opts.vCCorrelationId A globally unique id associated with your request
* @param {module:model/SaveSymEgressKey} opts.saveSymEgressKey Provide egress Symmetric key information to save (create or store or refresh)
* @param {module:api/CreateNewWebhooksApi~saveSymEgressKeyCallback} callback The callback function, accepting three arguments: error, data, response
* data is of type: {@link module:model/InlineResponse2014}
*/
this.saveSymEgressKey = function(vCSenderOrganizationId, vCPermissions, opts, callback) {
opts = opts || {};
var postBody = opts['saveSymEgressKey'];
// verify the required parameter 'vCSenderOrganizationId' is set
if (vCSenderOrganizationId === undefined || vCSenderOrganizationId === null) {
throw new Error("Missing the required parameter 'vCSenderOrganizationId' when calling saveSymEgressKey");
}
// verify the required parameter 'vCPermissions' is set
if (vCPermissions === undefined || vCPermissions === null) {
throw new Error("Missing the required parameter 'vCPermissions' when calling saveSymEgressKey");
}
var SdkTracker = require('../utilities/tracking/SdkTracker');
var sdkTracker = new SdkTracker();
postBody = sdkTracker.insertDeveloperIdTracker(postBody, 'module:model/SaveSymEgressKey', this.apiClient.merchantConfig.runEnvironment, this.apiClient.merchantConfig.defaultDeveloperId);
var pathParams = {
};
var queryParams = {
};
var headerParams = {
'v-c-correlation-id': opts['vCCorrelationId'],
'v-c-sender-organization-id': vCSenderOrganizationId,
'v-c-permissions': vCPermissions
};
var formParams = {
};
var authNames = [];
var contentTypes = ['application/json;charset=utf-8'];
var accepts = ['application/hal+json;charset=utf-8'];
var returnType = InlineResponse2014;
//check isMLE for an api method 'this.saveSymEgressKey'
var inboundMLEStatus = 'false';
var isMLEForApi = MLEUtility.checkIsMLEForAPI(this.apiClient.merchantConfig, inboundMLEStatus, 'saveSymEgressKey');
if (isMLEForApi === true) {
MLEUtility.encryptRequestPayload(this.apiClient.merchantConfig, postBody).then(postBody => {
return this.apiClient.callApi(
'/kms/egress/v2/keys-sym', 'POST',
pathParams, queryParams, headerParams, formParams, postBody,
authNames, contentTypes, accepts, returnType, callback
);
});
} else {
return this.apiClient.callApi(
'/kms/egress/v2/keys-sym', 'POST',
pathParams, queryParams, headerParams, formParams, postBody,
authNames, contentTypes, accepts, returnType, callback
);
}
}
};
return exports;
}));