UNPKG

infusionsoft-sdk

Version:

A NodeJS SDK automatically generated from Infusionsoft API Swagger definitions.

353 lines (297 loc) 14.5 kB
/** * 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. * */ import ApiClient from "../ApiClient"; import Error from '../model/Error'; import RestHook from '../model/RestHook'; import RestHookRequest from '../model/RestHookRequest'; /** * RESTHooks service. * @module api/RESTHooksApi * @version V1.0 */ export default class RESTHooksApi { /** * 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. */ constructor(apiClient) { this.apiClient = apiClient || ApiClient.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} */ createAHookSubscription(restHookRequest, callback) { let postBody = restHookRequest; // verify the required parameter 'restHookRequest' is set if (restHookRequest === undefined || restHookRequest === null) { throw new Error("Missing the required parameter 'restHookRequest' when calling createAHookSubscription"); } let pathParams = { }; let queryParams = { }; let headerParams = { }; let formParams = { }; let authNames = []; let contentTypes = ['application/json']; let accepts = ['application/json']; let returnType = RestHook; 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 */ deleteAHookSubscription(key, callback) { let postBody = null; // verify the required parameter 'key' is set if (key === undefined || key === null) { throw new Error("Missing the required parameter 'key' when calling deleteAHookSubscription"); } let pathParams = { 'key': key }; let queryParams = { }; let headerParams = { }; let formParams = { }; let authNames = []; let contentTypes = ['application/json']; let accepts = ['application/json']; let 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'>} */ listHookEventTypes(callback) { let postBody = null; let pathParams = { }; let queryParams = { }; let headerParams = { }; let formParams = { }; let authNames = []; let contentTypes = ['application/json']; let accepts = ['application/json']; let 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>} */ listStoredHookSubscriptions(callback) { let postBody = null; let pathParams = { }; let queryParams = { }; let headerParams = { }; let formParams = { }; let authNames = []; let contentTypes = ['application/json']; let accepts = ['application/json']; let returnType = [RestHook]; 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} */ retrieveAHookSubscription(key, callback) { let postBody = null; // verify the required parameter 'key' is set if (key === undefined || key === null) { throw new Error("Missing the required parameter 'key' when calling retrieveAHookSubscription"); } let pathParams = { 'key': key }; let queryParams = { }; let headerParams = { }; let formParams = { }; let authNames = []; let contentTypes = ['application/json']; let accepts = ['application/json']; let returnType = RestHook; 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} */ updateAHookSubscription(key, restHookRequest, callback) { let postBody = restHookRequest; // verify the required parameter 'key' is set if (key === undefined || key === null) { throw new Error("Missing the required parameter 'key' when calling updateAHookSubscription"); } // verify the required parameter 'restHookRequest' is set if (restHookRequest === undefined || restHookRequest === null) { throw new Error("Missing the required parameter 'restHookRequest' when calling updateAHookSubscription"); } let pathParams = { 'key': key }; let queryParams = { }; let headerParams = { }; let formParams = { }; let authNames = []; let contentTypes = ['application/json']; let accepts = ['application/json']; let returnType = RestHook; 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} */ verifyAHookSubscription(key, callback) { let postBody = null; // verify the required parameter 'key' is set if (key === undefined || key === null) { throw new Error("Missing the required parameter 'key' when calling verifyAHookSubscription"); } let pathParams = { 'key': key }; let queryParams = { }; let headerParams = { }; let formParams = { }; let authNames = []; let contentTypes = ['application/json']; let accepts = ['application/json']; let returnType = RestHook; return this.apiClient.callApi( '/hooks/{key}/verify', 'POST', pathParams, queryParams, headerParams, formParams, postBody, authNames, contentTypes, accepts, returnType, callback ); } }