cybersource-rest-client
Version:
Node.js SDK for the CyberSource REST API
540 lines (458 loc) • 24.6 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/InlineResponse2004', 'model/InlineResponse2005', 'model/InlineResponse2015', 'model/InlineResponse2016', 'model/InlineResponse2017', 'model/InlineResponse4042', 'model/SaveAsymEgressKey', 'model/UpdateStatus', 'model/UpdateWebhook'], 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/InlineResponse2004'), require('../model/InlineResponse2005'), require('../model/InlineResponse2015'), require('../model/InlineResponse2016'), require('../model/InlineResponse2017'), require('../model/InlineResponse4042'), require('../model/SaveAsymEgressKey'), require('../model/UpdateStatus'), require('../model/UpdateWebhook'));
} else {
// Browser globals (root is window)
if (!root.CyberSource) {
root.CyberSource = {};
}
root.CyberSource.ManageWebhooksApi = factory(root.Authentication.MLEUtility, root.CyberSource.ApiClient, root.CyberSource.InlineResponse2004, root.CyberSource.InlineResponse2005, root.CyberSource.InlineResponse2015, root.CyberSource.InlineResponse2016, root.CyberSource.InlineResponse2017, root.CyberSource.InlineResponse4042, root.CyberSource.SaveAsymEgressKey, root.CyberSource.UpdateStatus, root.CyberSource.UpdateWebhook);
}
}(this, function(MLEUtility, ApiClient, InlineResponse2004, InlineResponse2005, InlineResponse2015, InlineResponse2016, InlineResponse2017, InlineResponse4042, SaveAsymEgressKey, UpdateStatus, UpdateWebhook) {
'use strict';
/**
* ManageWebhooks service.
* @module api/ManageWebhooksApi
* @version 0.0.1
*/
/**
* Constructs a new ManageWebhooksApi.
* @alias module:api/ManageWebhooksApi
* @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 deleteWebhookSubscription operation.
* @callback module:api/ManageWebhooksApi~deleteWebhookSubscriptionCallback
* @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 Webhook Subscription
* Delete the webhook. Please note that deleting a particular webhook does not delete the history of the webhook notifications.
* @param {String} webhookId The webhook identifier.
* @param {module:api/ManageWebhooksApi~deleteWebhookSubscriptionCallback} callback The callback function, accepting three arguments: error, data, response
*/
this.deleteWebhookSubscription = function(webhookId, callback) {
var postBody = null;
if ('DELETE' == 'POST') {
postBody = '{}';
}
// verify the required parameter 'webhookId' is set
if (webhookId === undefined || webhookId === null) {
throw new Error("Missing the required parameter 'webhookId' when calling deleteWebhookSubscription");
}
var pathParams = {
'webhookId': webhookId
};
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.deleteWebhookSubscription'
var inboundMLEStatus = 'false';
var isMLEForApi = MLEUtility.checkIsMLEForAPI(this.apiClient.merchantConfig, inboundMLEStatus, 'deleteWebhookSubscription');
if (isMLEForApi === true) {
MLEUtility.encryptRequestPayload(this.apiClient.merchantConfig, postBody).then(postBody => {
return this.apiClient.callApi(
'/notification-subscriptions/v2/webhooks/{webhookId}', 'DELETE',
pathParams, queryParams, headerParams, formParams, postBody,
authNames, contentTypes, accepts, returnType, callback
);
});
} else {
return this.apiClient.callApi(
'/notification-subscriptions/v2/webhooks/{webhookId}', 'DELETE',
pathParams, queryParams, headerParams, formParams, postBody,
authNames, contentTypes, accepts, returnType, callback
);
}
}
/**
* Callback function to receive the result of the getWebhookSubscriptionById operation.
* @callback module:api/ManageWebhooksApi~getWebhookSubscriptionByIdCallback
* @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.
*/
/**
* Get Details On a Single Webhook
* Retrieve the details of a specific webhook by supplying the webhook ID in the path.
* @param {String} webhookId The webhook Identifier
* @param {module:api/ManageWebhooksApi~getWebhookSubscriptionByIdCallback} callback The callback function, accepting three arguments: error, data, response
* data is of type: {@link module:model/InlineResponse2015}
*/
this.getWebhookSubscriptionById = function(webhookId, callback) {
var postBody = null;
if ('GET' == 'POST') {
postBody = '{}';
}
// verify the required parameter 'webhookId' is set
if (webhookId === undefined || webhookId === null) {
throw new Error("Missing the required parameter 'webhookId' when calling getWebhookSubscriptionById");
}
var pathParams = {
'webhookId': webhookId
};
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.getWebhookSubscriptionById'
var inboundMLEStatus = 'false';
var isMLEForApi = MLEUtility.checkIsMLEForAPI(this.apiClient.merchantConfig, inboundMLEStatus, 'getWebhookSubscriptionById');
if (isMLEForApi === true) {
MLEUtility.encryptRequestPayload(this.apiClient.merchantConfig, postBody).then(postBody => {
return this.apiClient.callApi(
'/notification-subscriptions/v2/webhooks/{webhookId}', 'GET',
pathParams, queryParams, headerParams, formParams, postBody,
authNames, contentTypes, accepts, returnType, callback
);
});
} else {
return this.apiClient.callApi(
'/notification-subscriptions/v2/webhooks/{webhookId}', 'GET',
pathParams, queryParams, headerParams, formParams, postBody,
authNames, contentTypes, accepts, returnType, callback
);
}
}
/**
* Callback function to receive the result of the getWebhookSubscriptionsByOrg operation.
* @callback module:api/ManageWebhooksApi~getWebhookSubscriptionsByOrgCallback
* @param {String} error Error message, if any.
* @param {Array.<module:model/InlineResponse2004>} data The data returned by the service call.
* @param {String} response The complete HTTP response.
*/
/**
* Get Details On All Created Webhooks
* Retrieve a list of all previously created webhooks.
* @param {String} organizationId The Organization Identifier.
* @param {Object} opts Optional parameters
* @param {String} opts.productId The Product Identifier.
* @param {String} opts.eventType The Event Type.
* @param {module:api/ManageWebhooksApi~getWebhookSubscriptionsByOrgCallback} callback The callback function, accepting three arguments: error, data, response
* data is of type: {@link Array.<module:model/InlineResponse2004>}
*/
this.getWebhookSubscriptionsByOrg = function(organizationId, opts, callback) {
opts = opts || {};
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 getWebhookSubscriptionsByOrg");
}
var pathParams = {
};
var queryParams = {
'organizationId': organizationId,
'productId': opts['productId'],
'eventType': opts['eventType']
};
var headerParams = {
};
var formParams = {
};
var authNames = [];
var contentTypes = ['application/json;charset=utf-8'];
var accepts = ['application/hal+json;charset=utf-8'];
var returnType = [InlineResponse2004];
//check isMLE for an api method 'this.getWebhookSubscriptionsByOrg'
var inboundMLEStatus = 'false';
var isMLEForApi = MLEUtility.checkIsMLEForAPI(this.apiClient.merchantConfig, inboundMLEStatus, 'getWebhookSubscriptionsByOrg');
if (isMLEForApi === true) {
MLEUtility.encryptRequestPayload(this.apiClient.merchantConfig, postBody).then(postBody => {
return this.apiClient.callApi(
'/notification-subscriptions/v2/webhooks', 'GET',
pathParams, queryParams, headerParams, formParams, postBody,
authNames, contentTypes, accepts, returnType, callback
);
});
} else {
return this.apiClient.callApi(
'/notification-subscriptions/v2/webhooks', 'GET',
pathParams, queryParams, headerParams, formParams, postBody,
authNames, contentTypes, accepts, returnType, callback
);
}
}
/**
* Callback function to receive the result of the notificationSubscriptionsV1WebhooksWebhookIdPost operation.
* @callback module:api/ManageWebhooksApi~notificationSubscriptionsV1WebhooksWebhookIdPostCallback
* @param {String} error Error message, if any.
* @param {module:model/InlineResponse2016} data The data returned by the service call.
* @param {String} response The complete HTTP response.
*/
/**
* Test a Webhook Configuration
* Test the webhook configuration by sending a sample webhook. Calling this endpoint sends a sample webhook to the endpoint identified in the user's subscription. It will contain sample values for the product & eventType based on values present in your subscription along with a sample message in the payload. Based on the webhook response users can make any necessary modifications or rest assured knowing their setup is configured correctly.
* @param {String} webhookId The Webhook Identifier.
* @param {module:api/ManageWebhooksApi~notificationSubscriptionsV1WebhooksWebhookIdPostCallback} callback The callback function, accepting three arguments: error, data, response
* data is of type: {@link module:model/InlineResponse2016}
*/
this.notificationSubscriptionsV1WebhooksWebhookIdPost = function(webhookId, callback) {
var postBody = null;
if ('POST' == 'POST') {
postBody = '{}';
}
// verify the required parameter 'webhookId' is set
if (webhookId === undefined || webhookId === null) {
throw new Error("Missing the required parameter 'webhookId' when calling notificationSubscriptionsV1WebhooksWebhookIdPost");
}
var pathParams = {
'webhookId': webhookId
};
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 = InlineResponse2016;
//check isMLE for an api method 'this.notificationSubscriptionsV1WebhooksWebhookIdPost'
var inboundMLEStatus = 'false';
var isMLEForApi = MLEUtility.checkIsMLEForAPI(this.apiClient.merchantConfig, inboundMLEStatus, 'notificationSubscriptionsV1WebhooksWebhookIdPost');
if (isMLEForApi === true) {
MLEUtility.encryptRequestPayload(this.apiClient.merchantConfig, postBody).then(postBody => {
return this.apiClient.callApi(
'/notification-subscriptions/v1/webhooks/{webhookId}', 'POST',
pathParams, queryParams, headerParams, formParams, postBody,
authNames, contentTypes, accepts, returnType, callback
);
});
} else {
return this.apiClient.callApi(
'/notification-subscriptions/v1/webhooks/{webhookId}', 'POST',
pathParams, queryParams, headerParams, formParams, postBody,
authNames, contentTypes, accepts, returnType, callback
);
}
}
/**
* Callback function to receive the result of the notificationSubscriptionsV2WebhooksWebhookIdPatch operation.
* @callback module:api/ManageWebhooksApi~notificationSubscriptionsV2WebhooksWebhookIdPatchCallback
* @param {String} error Error message, if any.
* @param {module:model/InlineResponse2005} data The data returned by the service call.
* @param {String} response The complete HTTP response.
*/
/**
* Update a Webhook Subscription
* Update a Webhook Subscription.
* @param {String} webhookId The Webhook Identifier.
* @param {Object} opts Optional parameters
* @param {module:model/UpdateWebhook} opts.updateWebhook The webhook payload or changes to apply.
* @param {module:api/ManageWebhooksApi~notificationSubscriptionsV2WebhooksWebhookIdPatchCallback} callback The callback function, accepting three arguments: error, data, response
* data is of type: {@link module:model/InlineResponse2005}
*/
this.notificationSubscriptionsV2WebhooksWebhookIdPatch = function(webhookId, opts, callback) {
opts = opts || {};
var postBody = opts['updateWebhook'];
// verify the required parameter 'webhookId' is set
if (webhookId === undefined || webhookId === null) {
throw new Error("Missing the required parameter 'webhookId' when calling notificationSubscriptionsV2WebhooksWebhookIdPatch");
}
var SdkTracker = require('../utilities/tracking/SdkTracker');
var sdkTracker = new SdkTracker();
postBody = sdkTracker.insertDeveloperIdTracker(postBody, 'module:model/UpdateWebhook', this.apiClient.merchantConfig.runEnvironment, this.apiClient.merchantConfig.defaultDeveloperId);
var pathParams = {
'webhookId': webhookId
};
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 = InlineResponse2005;
//check isMLE for an api method 'this.notificationSubscriptionsV2WebhooksWebhookIdPatch'
var inboundMLEStatus = 'false';
var isMLEForApi = MLEUtility.checkIsMLEForAPI(this.apiClient.merchantConfig, inboundMLEStatus, 'notificationSubscriptionsV2WebhooksWebhookIdPatch');
if (isMLEForApi === true) {
MLEUtility.encryptRequestPayload(this.apiClient.merchantConfig, postBody).then(postBody => {
return this.apiClient.callApi(
'/notification-subscriptions/v2/webhooks/{webhookId}', 'PATCH',
pathParams, queryParams, headerParams, formParams, postBody,
authNames, contentTypes, accepts, returnType, callback
);
});
} else {
return this.apiClient.callApi(
'/notification-subscriptions/v2/webhooks/{webhookId}', 'PATCH',
pathParams, queryParams, headerParams, formParams, postBody,
authNames, contentTypes, accepts, returnType, callback
);
}
}
/**
* Callback function to receive the result of the notificationSubscriptionsV2WebhooksWebhookIdStatusPut operation.
* @callback module:api/ManageWebhooksApi~notificationSubscriptionsV2WebhooksWebhookIdStatusPutCallback
* @param {String} error Error message, if any.
* @param data This operation does not return a value.
* @param {String} response The complete HTTP response.
*/
/**
* Update a Webhook Status
* Users can update the status of a webhook subscription by calling this endpoint. The webhookId parameter in the URL path identifies the specific webhook subscription to be updated. The request body accepts the values ACTIVE or INACTIVE. If the subscription is set to INACTIVE, webhooks will not be delivered until the subscription is activated again.
* @param {String} webhookId The Webhook Identifier.
* @param {Object} opts Optional parameters
* @param {module:model/UpdateStatus} opts.updateStatus The status that the subscription should be updated to.
* @param {module:api/ManageWebhooksApi~notificationSubscriptionsV2WebhooksWebhookIdStatusPutCallback} callback The callback function, accepting three arguments: error, data, response
*/
this.notificationSubscriptionsV2WebhooksWebhookIdStatusPut = function(webhookId, opts, callback) {
opts = opts || {};
var postBody = opts['updateStatus'];
// verify the required parameter 'webhookId' is set
if (webhookId === undefined || webhookId === null) {
throw new Error("Missing the required parameter 'webhookId' when calling notificationSubscriptionsV2WebhooksWebhookIdStatusPut");
}
var SdkTracker = require('../utilities/tracking/SdkTracker');
var sdkTracker = new SdkTracker();
postBody = sdkTracker.insertDeveloperIdTracker(postBody, 'module:model/UpdateStatus', this.apiClient.merchantConfig.runEnvironment, this.apiClient.merchantConfig.defaultDeveloperId);
var pathParams = {
'webhookId': webhookId
};
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.notificationSubscriptionsV2WebhooksWebhookIdStatusPut'
var inboundMLEStatus = 'false';
var isMLEForApi = MLEUtility.checkIsMLEForAPI(this.apiClient.merchantConfig, inboundMLEStatus, 'notificationSubscriptionsV2WebhooksWebhookIdStatusPut');
if (isMLEForApi === true) {
MLEUtility.encryptRequestPayload(this.apiClient.merchantConfig, postBody).then(postBody => {
return this.apiClient.callApi(
'/notification-subscriptions/v2/webhooks/{webhookId}/status', 'PUT',
pathParams, queryParams, headerParams, formParams, postBody,
authNames, contentTypes, accepts, returnType, callback
);
});
} else {
return this.apiClient.callApi(
'/notification-subscriptions/v2/webhooks/{webhookId}/status', 'PUT',
pathParams, queryParams, headerParams, formParams, postBody,
authNames, contentTypes, accepts, returnType, callback
);
}
}
/**
* Callback function to receive the result of the saveAsymEgressKey operation.
* @callback module:api/ManageWebhooksApi~saveAsymEgressKeyCallback
* @param {String} error Error message, if any.
* @param {module:model/InlineResponse2017} data The data returned by the service call.
* @param {String} response The complete HTTP response.
*/
/**
* Message Level Encryption
* Store and manage certificates that will be used to preform Message Level Encryption (MLE). Each new webhook will need its own unique asymmetric certificate. You can either use a digital certificate issued/signed by a CA or self-sign your own using the documentation available on the Developer Guide.
* @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 {module:model/SaveAsymEgressKey} saveAsymEgressKey Provide egress Asymmetric key information to save (create or store)
* @param {Object} opts Optional parameters
* @param {String} opts.vCCorrelationId A globally unique id associated with your request
* @param {module:api/ManageWebhooksApi~saveAsymEgressKeyCallback} callback The callback function, accepting three arguments: error, data, response
* data is of type: {@link module:model/InlineResponse2017}
*/
this.saveAsymEgressKey = function(vCSenderOrganizationId, vCPermissions, saveAsymEgressKey, opts, callback) {
opts = opts || {};
var postBody = saveAsymEgressKey;
// verify the required parameter 'vCSenderOrganizationId' is set
if (vCSenderOrganizationId === undefined || vCSenderOrganizationId === null) {
throw new Error("Missing the required parameter 'vCSenderOrganizationId' when calling saveAsymEgressKey");
}
// verify the required parameter 'vCPermissions' is set
if (vCPermissions === undefined || vCPermissions === null) {
throw new Error("Missing the required parameter 'vCPermissions' when calling saveAsymEgressKey");
}
// verify the required parameter 'saveAsymEgressKey' is set
if (saveAsymEgressKey === undefined || saveAsymEgressKey === null) {
throw new Error("Missing the required parameter 'saveAsymEgressKey' when calling saveAsymEgressKey");
}
var SdkTracker = require('../utilities/tracking/SdkTracker');
var sdkTracker = new SdkTracker();
postBody = sdkTracker.insertDeveloperIdTracker(postBody, 'module:model/SaveAsymEgressKey', 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 = InlineResponse2017;
//check isMLE for an api method 'this.saveAsymEgressKey'
var inboundMLEStatus = 'false';
var isMLEForApi = MLEUtility.checkIsMLEForAPI(this.apiClient.merchantConfig, inboundMLEStatus, 'saveAsymEgressKey');
if (isMLEForApi === true) {
MLEUtility.encryptRequestPayload(this.apiClient.merchantConfig, postBody).then(postBody => {
return this.apiClient.callApi(
'/kms/egress/v2/keys-asym', 'POST',
pathParams, queryParams, headerParams, formParams, postBody,
authNames, contentTypes, accepts, returnType, callback
);
});
} else {
return this.apiClient.callApi(
'/kms/egress/v2/keys-asym', 'POST',
pathParams, queryParams, headerParams, formParams, postBody,
authNames, contentTypes, accepts, returnType, callback
);
}
}
};
return exports;
}));