UNPKG

infusionsoft-nodejs

Version:

A NodeJS SDK automatically generated from Infusionsoft API Swagger definitions.

339 lines (273 loc) 22.1 kB
'use strict'; Object.defineProperty(exports, "__esModule", { value: true }); var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); /** * Infusionsoft REST API * No description provided (generated by Swagger Codegen https://github.com/swagger-api/swagger-codegen) * * OpenAPI spec version: V1.0 * * * NOTE: This class is auto generated by the swagger code generator program. * https://github.com/swagger-api/swagger-codegen.git * Do not edit the class manually. * */ var _ApiClient = require('../ApiClient'); var _ApiClient2 = _interopRequireDefault(_ApiClient); var _Error = require('../model/Error'); var _Error2 = _interopRequireDefault(_Error); var _RestHook = require('../model/RestHook'); var _RestHook2 = _interopRequireDefault(_RestHook); var _RestHookRequest = require('../model/RestHookRequest'); var _RestHookRequest2 = _interopRequireDefault(_RestHookRequest); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } /** * RESTHooks service. * @module api/RESTHooksApi * @version V1.0 */ var RESTHooksApi = function () { /** * Constructs a new RESTHooksApi. * @alias module:api/RESTHooksApi * @class * @param {module:ApiClient} apiClient Optional API client implementation to use, * default to {@link module:ApiClient#instance} if unspecified. */ function RESTHooksApi(apiClient) { _classCallCheck(this, RESTHooksApi); this.apiClient = apiClient || _ApiClient2.default.instance; } /** * Callback function to receive the result of the createAHookSubscription operation. * @callback module:api/RESTHooksApi~createAHookSubscriptionCallback * @param {String} error Error message, if any. * @param {module:model/RestHook} data The data returned by the service call. * @param {String} response The complete HTTP response. */ /** * Create a Hook Subscription * To receive hooks, you&#39;ll first need to subscribe to events one at a time *and* individually verify each subscription. This operation is used to create hook subscriptions. During this process, Infusionsoft will attempt to verify your subscription. Continue reading to learn how that works. To verify or reactivate a hook subscription, Infusionsoft will make a &#x60;POST&#x60; request with a temporary secret to the &#x60;hookUrl&#x60; you provided during creation. The secret is passed as the value of a header named &#x60;X-Hook-Secret&#x60;. Your response to that &#x60;POST&#x60; *must* have a status code of &#x60;200&#x60; and return the same &#x60;X-Hook-Secret&#x60; header and value pair. Once you&#39;ve done that, you&#39;ll begin receiving hooks. Don&#39;t worry if verification fails; you can always [request another verification attempt](#!/REST_Hooks/verify_a_hook_subscription). NB: You will not receive events until the subscription is verified. If the verification process seems confusing, head over to [RESTHooks.org](http://resthooks.org/docs/security/) for more on the concept. * @param {module:model/RestHookRequest} restHookRequest restHookRequest * @param {module:api/RESTHooksApi~createAHookSubscriptionCallback} callback The callback function, accepting three arguments: error, data, response * data is of type: {@link module:model/RestHook} */ _createClass(RESTHooksApi, [{ key: 'createAHookSubscription', value: function createAHookSubscription(restHookRequest, callback) { var postBody = restHookRequest; // verify the required parameter 'restHookRequest' is set if (restHookRequest === undefined || restHookRequest === null) { throw new _Error2.default("Missing the required parameter 'restHookRequest' when calling createAHookSubscription"); } var pathParams = {}; var queryParams = {}; var headerParams = {}; var formParams = {}; var authNames = []; var contentTypes = ['application/json']; var accepts = ['application/json']; var returnType = _RestHook2.default; return this.apiClient.callApi('/hooks', 'POST', pathParams, queryParams, headerParams, formParams, postBody, authNames, contentTypes, accepts, returnType, callback); } /** * Callback function to receive the result of the deleteAHookSubscription operation. * @callback module:api/RESTHooksApi~deleteAHookSubscriptionCallback * @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 Hook Subscription * Stop receiving hooks by deleting an existing hook subscription. * @param {String} key key * @param {module:api/RESTHooksApi~deleteAHookSubscriptionCallback} callback The callback function, accepting three arguments: error, data, response */ }, { key: 'deleteAHookSubscription', value: function deleteAHookSubscription(key, callback) { var postBody = null; // verify the required parameter 'key' is set if (key === undefined || key === null) { throw new _Error2.default("Missing the required parameter 'key' when calling deleteAHookSubscription"); } var pathParams = { 'key': key }; var queryParams = {}; var headerParams = {}; var formParams = {}; var authNames = []; var contentTypes = ['application/json']; var accepts = ['application/json']; var returnType = null; return this.apiClient.callApi('/hooks/{key}', 'DELETE', pathParams, queryParams, headerParams, formParams, postBody, authNames, contentTypes, accepts, returnType, callback); } /** * Callback function to receive the result of the listHookEventTypes operation. * @callback module:api/RESTHooksApi~listHookEventTypesCallback * @param {String} error Error message, if any. * @param {Array.<'String'>} data The data returned by the service call. * @param {String} response The complete HTTP response. */ /** * List Hook Event Types * ### _What are REST Hooks?_ _REST Hooks itself is not a specification, it is a collection of patterns that treat webhooks like subscriptions. These subscriptions are manipulated via a REST API just like any other resource._ _With most modern REST APIs, polling is the only way to detect changes. But it doesn&#39;t have to be. On average, 98.5% of polls are wasted. There is a better way. REST Hooks enable real-time communication and eliminate polling._ -- [RESTHooks.org](http://RESTHooks.org) Infusionsoft offers a growing set of REST Hooks to keep you notified of changes in your data. To get started, use [List Hook Event Types](#!/REST_Hooks/list_hook_event_types) to discover event types. Event types are identified using _noun.verb dot syntax_, e.g.: &#x60;contact.add&#x60; or &#x60;invoice.delete&#x60;. Once you&#39;ve chosen the events you&#39;re interested in, subscribe to them via [Create a Hook Subscription](#!/REST_Hooks/create_a_hook_subscription). * @param {module:api/RESTHooksApi~listHookEventTypesCallback} callback The callback function, accepting three arguments: error, data, response * data is of type: {@link Array.<'String'>} */ }, { key: 'listHookEventTypes', value: function listHookEventTypes(callback) { var postBody = null; var pathParams = {}; var queryParams = {}; var headerParams = {}; var formParams = {}; var authNames = []; var contentTypes = ['application/json']; var accepts = ['application/json']; var returnType = ['String']; return this.apiClient.callApi('/hooks/event_keys', 'GET', pathParams, queryParams, headerParams, formParams, postBody, authNames, contentTypes, accepts, returnType, callback); } /** * Callback function to receive the result of the listStoredHookSubscriptions operation. * @callback module:api/RESTHooksApi~listStoredHookSubscriptionsCallback * @param {String} error Error message, if any. * @param {Array.<module:model/RestHook>} data The data returned by the service call. * @param {String} response The complete HTTP response. */ /** * List Stored Hook Subscriptions * Lists your hook subscriptions. * @param {module:api/RESTHooksApi~listStoredHookSubscriptionsCallback} callback The callback function, accepting three arguments: error, data, response * data is of type: {@link Array.<module:model/RestHook>} */ }, { key: 'listStoredHookSubscriptions', value: function listStoredHookSubscriptions(callback) { var postBody = null; var pathParams = {}; var queryParams = {}; var headerParams = {}; var formParams = {}; var authNames = []; var contentTypes = ['application/json']; var accepts = ['application/json']; var returnType = [_RestHook2.default]; return this.apiClient.callApi('/hooks', 'GET', pathParams, queryParams, headerParams, formParams, postBody, authNames, contentTypes, accepts, returnType, callback); } /** * Callback function to receive the result of the retrieveAHookSubscription operation. * @callback module:api/RESTHooksApi~retrieveAHookSubscriptionCallback * @param {String} error Error message, if any. * @param {module:model/RestHook} data The data returned by the service call. * @param {String} response The complete HTTP response. */ /** * Retrieve a Hook Subscription * Retrieves an existing hook subscription and its status. If your hook subscription becomes inactive, you may request an activation attempt via [Verify a Hook Subscription](#!/REST_Hooks/verify_a_hook_subscription). * @param {String} key key * @param {module:api/RESTHooksApi~retrieveAHookSubscriptionCallback} callback The callback function, accepting three arguments: error, data, response * data is of type: {@link module:model/RestHook} */ }, { key: 'retrieveAHookSubscription', value: function retrieveAHookSubscription(key, callback) { var postBody = null; // verify the required parameter 'key' is set if (key === undefined || key === null) { throw new _Error2.default("Missing the required parameter 'key' when calling retrieveAHookSubscription"); } var pathParams = { 'key': key }; var queryParams = {}; var headerParams = {}; var formParams = {}; var authNames = []; var contentTypes = ['application/json']; var accepts = ['application/json']; var returnType = _RestHook2.default; return this.apiClient.callApi('/hooks/{key}', 'GET', pathParams, queryParams, headerParams, formParams, postBody, authNames, contentTypes, accepts, returnType, callback); } /** * Callback function to receive the result of the updateAHookSubscription operation. * @callback module:api/RESTHooksApi~updateAHookSubscriptionCallback * @param {String} error Error message, if any. * @param {module:model/RestHook} data The data returned by the service call. * @param {String} response The complete HTTP response. */ /** * Update a Hook Subscription * Modify an existing hook subscription using the provided values. * @param {String} key key * @param {module:model/RestHookRequest} restHookRequest restHookRequest * @param {module:api/RESTHooksApi~updateAHookSubscriptionCallback} callback The callback function, accepting three arguments: error, data, response * data is of type: {@link module:model/RestHook} */ }, { key: 'updateAHookSubscription', value: function updateAHookSubscription(key, restHookRequest, callback) { var postBody = restHookRequest; // verify the required parameter 'key' is set if (key === undefined || key === null) { throw new _Error2.default("Missing the required parameter 'key' when calling updateAHookSubscription"); } // verify the required parameter 'restHookRequest' is set if (restHookRequest === undefined || restHookRequest === null) { throw new _Error2.default("Missing the required parameter 'restHookRequest' when calling updateAHookSubscription"); } var pathParams = { 'key': key }; var queryParams = {}; var headerParams = {}; var formParams = {}; var authNames = []; var contentTypes = ['application/json']; var accepts = ['application/json']; var returnType = _RestHook2.default; return this.apiClient.callApi('/hooks/{key}', 'PUT', pathParams, queryParams, headerParams, formParams, postBody, authNames, contentTypes, accepts, returnType, callback); } /** * Callback function to receive the result of the verifyAHookSubscription operation. * @callback module:api/RESTHooksApi~verifyAHookSubscriptionCallback * @param {String} error Error message, if any. * @param {module:model/RestHook} data The data returned by the service call. * @param {String} response The complete HTTP response. */ /** * Verify a Hook Subscription * This operation is used to verify or reactivate a hook subscription. To verify or reactivate a hook subscription, Infusionsoft will make a &#x60;POST&#x60; request with a temporary secret to the &#x60;hookUrl&#x60; you provided during creation. The secret is passed as the value of a header named &#x60;X-Hook-Secret&#x60;. Your response to that &#x60;POST&#x60; *must* have a status code of &#x60;200&#x60; and return the same &#x60;X-Hook-Secret&#x60; header and value pair. Once you&#39;ve done that, you&#39;ll begin receiving hooks. Don&#39;t worry if verification fails; you can always [request another verification attempt](#!/REST_Hooks/verify_a_hook_subscription). NB: You will not receive events until the subscription is verified. If the verification process seems confusing, head over to [RESTHooks.org](http://resthooks.org/docs/security/) for more on the concept. * @param {String} key key * @param {module:api/RESTHooksApi~verifyAHookSubscriptionCallback} callback The callback function, accepting three arguments: error, data, response * data is of type: {@link module:model/RestHook} */ }, { key: 'verifyAHookSubscription', value: function verifyAHookSubscription(key, callback) { var postBody = null; // verify the required parameter 'key' is set if (key === undefined || key === null) { throw new _Error2.default("Missing the required parameter 'key' when calling verifyAHookSubscription"); } var pathParams = { 'key': key }; var queryParams = {}; var headerParams = {}; var formParams = {}; var authNames = []; var contentTypes = ['application/json']; var accepts = ['application/json']; var returnType = _RestHook2.default; return this.apiClient.callApi('/hooks/{key}/verify', 'POST', pathParams, queryParams, headerParams, formParams, postBody, authNames, contentTypes, accepts, returnType, callback); } }]); return RESTHooksApi; }(); exports.default = RESTHooksApi;