UNPKG

@bitblit/ratchet-misc

Version:

Ratchet miscellaneous tooling that requires smallish dependant libraries

128 lines 6.67 kB
import * as runtime from '../runtime.js'; import { CreateModelFromJSON, CreateWebhookToJSON, GetWebhookFromJSON, GetWebhooksFromJSON, UpdateWebhookToJSON } from '../models/index.js'; export class WebhooksApi extends runtime.BaseAPI { async createWebhookRaw(requestParameters, initOverrides) { if (requestParameters.createWebhook === null || requestParameters.createWebhook === undefined) { throw new runtime.RequiredError('createWebhook', 'Required parameter requestParameters.createWebhook was null or undefined when calling createWebhook.'); } const queryParameters = {}; const headerParameters = {}; headerParameters['Content-Type'] = 'application/json'; if (this.configuration && this.configuration.apiKey) { headerParameters['api-key'] = await this.configuration.apiKey('api-key'); } const response = await this.request({ path: `/webhooks`, method: 'POST', headers: headerParameters, query: queryParameters, body: CreateWebhookToJSON(requestParameters.createWebhook), }, initOverrides); return new runtime.JSONApiResponse(response, (jsonValue) => CreateModelFromJSON(jsonValue)); } async createWebhook(requestParameters, initOverrides) { const response = await this.createWebhookRaw(requestParameters, initOverrides); return await response.value(); } async deleteWebhookRaw(requestParameters, initOverrides) { if (requestParameters.webhookId === null || requestParameters.webhookId === undefined) { throw new runtime.RequiredError('webhookId', 'Required parameter requestParameters.webhookId was null or undefined when calling deleteWebhook.'); } const queryParameters = {}; const headerParameters = {}; if (this.configuration && this.configuration.apiKey) { headerParameters['api-key'] = await this.configuration.apiKey('api-key'); } const response = await this.request({ path: `/webhooks/{webhookId}`.replace(`{${'webhookId'}}`, encodeURIComponent(String(requestParameters.webhookId))), method: 'DELETE', headers: headerParameters, query: queryParameters, }, initOverrides); return new runtime.VoidApiResponse(response); } async deleteWebhook(requestParameters, initOverrides) { await this.deleteWebhookRaw(requestParameters, initOverrides); } async getWebhookRaw(requestParameters, initOverrides) { if (requestParameters.webhookId === null || requestParameters.webhookId === undefined) { throw new runtime.RequiredError('webhookId', 'Required parameter requestParameters.webhookId was null or undefined when calling getWebhook.'); } const queryParameters = {}; const headerParameters = {}; if (this.configuration && this.configuration.apiKey) { headerParameters['api-key'] = await this.configuration.apiKey('api-key'); } const response = await this.request({ path: `/webhooks/{webhookId}`.replace(`{${'webhookId'}}`, encodeURIComponent(String(requestParameters.webhookId))), method: 'GET', headers: headerParameters, query: queryParameters, }, initOverrides); return new runtime.JSONApiResponse(response, (jsonValue) => GetWebhookFromJSON(jsonValue)); } async getWebhook(requestParameters, initOverrides) { const response = await this.getWebhookRaw(requestParameters, initOverrides); return await response.value(); } async getWebhooksRaw(requestParameters, initOverrides) { const queryParameters = {}; if (requestParameters.type !== undefined) { queryParameters['type'] = requestParameters.type; } if (requestParameters.sort !== undefined) { queryParameters['sort'] = requestParameters.sort; } const headerParameters = {}; if (this.configuration && this.configuration.apiKey) { headerParameters['api-key'] = await this.configuration.apiKey('api-key'); } const response = await this.request({ path: `/webhooks`, method: 'GET', headers: headerParameters, query: queryParameters, }, initOverrides); return new runtime.JSONApiResponse(response, (jsonValue) => GetWebhooksFromJSON(jsonValue)); } async getWebhooks(requestParameters = {}, initOverrides) { const response = await this.getWebhooksRaw(requestParameters, initOverrides); return await response.value(); } async updateWebhookRaw(requestParameters, initOverrides) { if (requestParameters.webhookId === null || requestParameters.webhookId === undefined) { throw new runtime.RequiredError('webhookId', 'Required parameter requestParameters.webhookId was null or undefined when calling updateWebhook.'); } if (requestParameters.updateWebhook === null || requestParameters.updateWebhook === undefined) { throw new runtime.RequiredError('updateWebhook', 'Required parameter requestParameters.updateWebhook was null or undefined when calling updateWebhook.'); } const queryParameters = {}; const headerParameters = {}; headerParameters['Content-Type'] = 'application/json'; if (this.configuration && this.configuration.apiKey) { headerParameters['api-key'] = await this.configuration.apiKey('api-key'); } const response = await this.request({ path: `/webhooks/{webhookId}`.replace(`{${'webhookId'}}`, encodeURIComponent(String(requestParameters.webhookId))), method: 'PUT', headers: headerParameters, query: queryParameters, body: UpdateWebhookToJSON(requestParameters.updateWebhook), }, initOverrides); return new runtime.VoidApiResponse(response); } async updateWebhook(requestParameters, initOverrides) { await this.updateWebhookRaw(requestParameters, initOverrides); } } export var GetWebhooksTypeEnum; (function (GetWebhooksTypeEnum) { GetWebhooksTypeEnum["Marketing"] = "marketing"; GetWebhooksTypeEnum["Transactional"] = "transactional"; })(GetWebhooksTypeEnum || (GetWebhooksTypeEnum = {})); export var GetWebhooksSortEnum; (function (GetWebhooksSortEnum) { GetWebhooksSortEnum["Asc"] = "asc"; GetWebhooksSortEnum["Desc"] = "desc"; })(GetWebhooksSortEnum || (GetWebhooksSortEnum = {})); //# sourceMappingURL=WebhooksApi.js.map