mailslurp-client
Version:
Official client for MailSlurp Email and SMS API. Create email addresses and phone numbers in Javascript without a mail server. Send and receive real emails in applications or tests.
1,759 lines (1,511 loc) • 64.9 kB
text/typescript
/* tslint:disable */
/* eslint-disable */
/**
* MailSlurp API
* MailSlurp is an API for sending and receiving emails from dynamically allocated email addresses. It\'s designed for developers and QA teams to test applications, process inbound emails, send templated notifications, attachments, and more. ## Resources - [Homepage](https://www.mailslurp.com) - Get an [API KEY](https://app.mailslurp.com/sign-up/) - Generated [SDK Clients](https://docs.mailslurp.com/) - [Examples](https://github.com/mailslurp/examples) repository
*
* The version of the OpenAPI document: 6.5.2
* Contact: contact@mailslurp.dev
*
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
* https://openapi-generator.tech
* Do not edit the class manually.
*/
import * as runtime from '../runtime';
import {
AbstractWebhookPayload,
AbstractWebhookPayloadFromJSON,
AbstractWebhookPayloadToJSON,
CreateWebhookOptions,
CreateWebhookOptionsFromJSON,
CreateWebhookOptionsToJSON,
JSONSchemaDto,
JSONSchemaDtoFromJSON,
JSONSchemaDtoToJSON,
PageWebhookProjection,
PageWebhookProjectionFromJSON,
PageWebhookProjectionToJSON,
PageWebhookResult,
PageWebhookResultFromJSON,
PageWebhookResultToJSON,
UnseenErrorCountDto,
UnseenErrorCountDtoFromJSON,
UnseenErrorCountDtoToJSON,
VerifyWebhookSignatureOptions,
VerifyWebhookSignatureOptionsFromJSON,
VerifyWebhookSignatureOptionsToJSON,
VerifyWebhookSignatureResults,
VerifyWebhookSignatureResultsFromJSON,
VerifyWebhookSignatureResultsToJSON,
WebhookBouncePayload,
WebhookBouncePayloadFromJSON,
WebhookBouncePayloadToJSON,
WebhookBounceRecipientPayload,
WebhookBounceRecipientPayloadFromJSON,
WebhookBounceRecipientPayloadToJSON,
WebhookDeliveryStatusPayload,
WebhookDeliveryStatusPayloadFromJSON,
WebhookDeliveryStatusPayloadToJSON,
WebhookDto,
WebhookDtoFromJSON,
WebhookDtoToJSON,
WebhookEmailOpenedPayload,
WebhookEmailOpenedPayloadFromJSON,
WebhookEmailOpenedPayloadToJSON,
WebhookEmailReadPayload,
WebhookEmailReadPayloadFromJSON,
WebhookEmailReadPayloadToJSON,
WebhookHeaders,
WebhookHeadersFromJSON,
WebhookHeadersToJSON,
WebhookNewAttachmentPayload,
WebhookNewAttachmentPayloadFromJSON,
WebhookNewAttachmentPayloadToJSON,
WebhookNewContactPayload,
WebhookNewContactPayloadFromJSON,
WebhookNewContactPayloadToJSON,
WebhookNewEmailPayload,
WebhookNewEmailPayloadFromJSON,
WebhookNewEmailPayloadToJSON,
WebhookNewSmsPayload,
WebhookNewSmsPayloadFromJSON,
WebhookNewSmsPayloadToJSON,
WebhookRedriveResult,
WebhookRedriveResultFromJSON,
WebhookRedriveResultToJSON,
WebhookResultDto,
WebhookResultDtoFromJSON,
WebhookResultDtoToJSON,
WebhookTestResult,
WebhookTestResultFromJSON,
WebhookTestResultToJSON,
} from '../models';
export interface CreateAccountWebhookRequest {
createWebhookOptions: CreateWebhookOptions;
}
export interface CreateWebhookRequest {
inboxId: string;
createWebhookOptions: CreateWebhookOptions;
}
export interface CreateWebhookForPhoneNumberRequest {
phoneNumberId: string;
createWebhookOptions: CreateWebhookOptions;
}
export interface DeleteAllWebhooksRequest {
before?: Date;
}
export interface DeleteWebhookRequest {
inboxId: string;
webhookId: string;
}
export interface DeleteWebhookByIdRequest {
webhookId: string;
}
export interface GetAllAccountWebhooksRequest {
page?: number;
size?: number;
sort?: GetAllAccountWebhooksSortEnum;
eventType?: GetAllAccountWebhooksEventTypeEnum;
since?: Date;
before?: Date;
}
export interface GetAllWebhookResultsRequest {
page?: number;
size?: number;
sort?: GetAllWebhookResultsSortEnum;
searchFilter?: string;
since?: Date;
before?: Date;
unseenOnly?: boolean;
}
export interface GetAllWebhooksRequest {
page?: number;
size?: number;
sort?: GetAllWebhooksSortEnum;
searchFilter?: string;
since?: Date;
inboxId?: string;
phoneId?: string;
before?: Date;
}
export interface GetInboxWebhooksPaginatedRequest {
inboxId: string;
page?: number;
size?: number;
sort?: GetInboxWebhooksPaginatedSortEnum;
searchFilter?: string;
since?: Date;
before?: Date;
}
export interface GetJsonSchemaForWebhookEventRequest {
event: GetJsonSchemaForWebhookEventEventEnum;
}
export interface GetJsonSchemaForWebhookPayloadRequest {
webhookId: string;
}
export interface GetPhoneNumberWebhooksPaginatedRequest {
phoneId: string;
page?: number;
size?: number;
sort?: GetPhoneNumberWebhooksPaginatedSortEnum;
since?: Date;
before?: Date;
}
export interface GetTestWebhookPayloadRequest {
eventName?: GetTestWebhookPayloadEventNameEnum;
}
export interface GetTestWebhookPayloadForWebhookRequest {
webhookId: string;
}
export interface GetWebhookRequest {
webhookId: string;
}
export interface GetWebhookResultRequest {
webhookResultId: string;
}
export interface GetWebhookResultsRequest {
webhookId: string;
page?: number;
size?: number;
sort?: GetWebhookResultsSortEnum;
searchFilter?: string;
since?: Date;
before?: Date;
unseenOnly?: boolean;
}
export interface GetWebhooksRequest {
inboxId: string;
}
export interface RedriveWebhookResultRequest {
webhookResultId: string;
}
export interface SendTestDataRequest {
webhookId: string;
}
export interface UpdateWebhookHeadersRequest {
webhookId: string;
webhookHeaders: WebhookHeaders;
}
export interface VerifyWebhookSignatureRequest {
verifyWebhookSignatureOptions: VerifyWebhookSignatureOptions;
}
export interface WaitForWebhookResultsRequest {
webhookId: string;
expectedCount: number;
timeout: number;
}
/**
*
*/
export class WebhookControllerApi extends runtime.BaseAPI {
/**
* Get notified of account level events such as bounce and bounce recipient.
* Attach a WebHook URL to an inbox
*/
async createAccountWebhookRaw(
requestParameters: CreateAccountWebhookRequest,
initOverrides?: RequestInit
): Promise<runtime.ApiResponse<WebhookDto>> {
if (
requestParameters.createWebhookOptions === null ||
requestParameters.createWebhookOptions === undefined
) {
throw new runtime.RequiredError(
'createWebhookOptions',
'Required parameter requestParameters.createWebhookOptions was null or undefined when calling createAccountWebhook.'
);
}
const queryParameters: any = {};
const headerParameters: runtime.HTTPHeaders = {};
headerParameters['Content-Type'] = 'application/json';
if (this.configuration && this.configuration.apiKey) {
headerParameters['x-api-key'] = this.configuration.apiKey('x-api-key'); // API_KEY authentication
}
const response = await this.request(
{
path: `/webhooks`,
method: 'POST',
headers: headerParameters,
query: queryParameters,
body: CreateWebhookOptionsToJSON(
requestParameters.createWebhookOptions
),
},
initOverrides
);
return new runtime.JSONApiResponse(response, (jsonValue) =>
WebhookDtoFromJSON(jsonValue)
);
}
/**
* Get notified of account level events such as bounce and bounce recipient.
* Attach a WebHook URL to an inbox
*/
async createAccountWebhook(
requestParameters: CreateAccountWebhookRequest,
initOverrides?: RequestInit
): Promise<WebhookDto> {
const response = await this.createAccountWebhookRaw(
requestParameters,
initOverrides
);
return await response.value();
}
/**
* Get notified whenever an inbox receives an email via a WebHook URL. An emailID will be posted to this URL every time an email is received for this inbox. The URL must be publicly reachable by the MailSlurp server. You can provide basicAuth values if you wish to secure this endpoint.
* Attach a WebHook URL to an inbox
*/
async createWebhookRaw(
requestParameters: CreateWebhookRequest,
initOverrides?: RequestInit
): Promise<runtime.ApiResponse<WebhookDto>> {
if (
requestParameters.inboxId === null ||
requestParameters.inboxId === undefined
) {
throw new runtime.RequiredError(
'inboxId',
'Required parameter requestParameters.inboxId was null or undefined when calling createWebhook.'
);
}
if (
requestParameters.createWebhookOptions === null ||
requestParameters.createWebhookOptions === undefined
) {
throw new runtime.RequiredError(
'createWebhookOptions',
'Required parameter requestParameters.createWebhookOptions was null or undefined when calling createWebhook.'
);
}
const queryParameters: any = {};
const headerParameters: runtime.HTTPHeaders = {};
headerParameters['Content-Type'] = 'application/json';
if (this.configuration && this.configuration.apiKey) {
headerParameters['x-api-key'] = this.configuration.apiKey('x-api-key'); // API_KEY authentication
}
const response = await this.request(
{
path: `/inboxes/{inboxId}/webhooks`.replace(
`{${'inboxId'}}`,
encodeURIComponent(String(requestParameters.inboxId))
),
method: 'POST',
headers: headerParameters,
query: queryParameters,
body: CreateWebhookOptionsToJSON(
requestParameters.createWebhookOptions
),
},
initOverrides
);
return new runtime.JSONApiResponse(response, (jsonValue) =>
WebhookDtoFromJSON(jsonValue)
);
}
/**
* Get notified whenever an inbox receives an email via a WebHook URL. An emailID will be posted to this URL every time an email is received for this inbox. The URL must be publicly reachable by the MailSlurp server. You can provide basicAuth values if you wish to secure this endpoint.
* Attach a WebHook URL to an inbox
*/
async createWebhook(
requestParameters: CreateWebhookRequest,
initOverrides?: RequestInit
): Promise<WebhookDto> {
const response = await this.createWebhookRaw(
requestParameters,
initOverrides
);
return await response.value();
}
/**
* Get notified whenever a phone number receives an SMS via a WebHook URL.
* Attach a WebHook URL to a phone number
*/
async createWebhookForPhoneNumberRaw(
requestParameters: CreateWebhookForPhoneNumberRequest,
initOverrides?: RequestInit
): Promise<runtime.ApiResponse<WebhookDto>> {
if (
requestParameters.phoneNumberId === null ||
requestParameters.phoneNumberId === undefined
) {
throw new runtime.RequiredError(
'phoneNumberId',
'Required parameter requestParameters.phoneNumberId was null or undefined when calling createWebhookForPhoneNumber.'
);
}
if (
requestParameters.createWebhookOptions === null ||
requestParameters.createWebhookOptions === undefined
) {
throw new runtime.RequiredError(
'createWebhookOptions',
'Required parameter requestParameters.createWebhookOptions was null or undefined when calling createWebhookForPhoneNumber.'
);
}
const queryParameters: any = {};
const headerParameters: runtime.HTTPHeaders = {};
headerParameters['Content-Type'] = 'application/json';
if (this.configuration && this.configuration.apiKey) {
headerParameters['x-api-key'] = this.configuration.apiKey('x-api-key'); // API_KEY authentication
}
const response = await this.request(
{
path: `/phone/numbers/{phoneNumberId}/webhooks`.replace(
`{${'phoneNumberId'}}`,
encodeURIComponent(String(requestParameters.phoneNumberId))
),
method: 'POST',
headers: headerParameters,
query: queryParameters,
body: CreateWebhookOptionsToJSON(
requestParameters.createWebhookOptions
),
},
initOverrides
);
return new runtime.JSONApiResponse(response, (jsonValue) =>
WebhookDtoFromJSON(jsonValue)
);
}
/**
* Get notified whenever a phone number receives an SMS via a WebHook URL.
* Attach a WebHook URL to a phone number
*/
async createWebhookForPhoneNumber(
requestParameters: CreateWebhookForPhoneNumberRequest,
initOverrides?: RequestInit
): Promise<WebhookDto> {
const response = await this.createWebhookForPhoneNumberRaw(
requestParameters,
initOverrides
);
return await response.value();
}
/**
* Delete all webhooks
*/
async deleteAllWebhooksRaw(
requestParameters: DeleteAllWebhooksRequest,
initOverrides?: RequestInit
): Promise<runtime.ApiResponse<void>> {
const queryParameters: any = {};
if (requestParameters.before !== undefined) {
queryParameters['before'] = (
requestParameters.before as any
).toISOString();
}
const headerParameters: runtime.HTTPHeaders = {};
if (this.configuration && this.configuration.apiKey) {
headerParameters['x-api-key'] = this.configuration.apiKey('x-api-key'); // API_KEY authentication
}
const response = await this.request(
{
path: `/webhooks`,
method: 'DELETE',
headers: headerParameters,
query: queryParameters,
},
initOverrides
);
return new runtime.VoidApiResponse(response);
}
/**
* Delete all webhooks
*/
async deleteAllWebhooks(
requestParameters: DeleteAllWebhooksRequest,
initOverrides?: RequestInit
): Promise<void> {
await this.deleteAllWebhooksRaw(requestParameters, initOverrides);
}
/**
* Delete and disable a Webhook for an Inbox
*/
async deleteWebhookRaw(
requestParameters: DeleteWebhookRequest,
initOverrides?: RequestInit
): Promise<runtime.ApiResponse<void>> {
if (
requestParameters.inboxId === null ||
requestParameters.inboxId === undefined
) {
throw new runtime.RequiredError(
'inboxId',
'Required parameter requestParameters.inboxId was null or undefined when calling deleteWebhook.'
);
}
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: any = {};
const headerParameters: runtime.HTTPHeaders = {};
if (this.configuration && this.configuration.apiKey) {
headerParameters['x-api-key'] = this.configuration.apiKey('x-api-key'); // API_KEY authentication
}
const response = await this.request(
{
path: `/inboxes/{inboxId}/webhooks/{webhookId}`
.replace(
`{${'inboxId'}}`,
encodeURIComponent(String(requestParameters.inboxId))
)
.replace(
`{${'webhookId'}}`,
encodeURIComponent(String(requestParameters.webhookId))
),
method: 'DELETE',
headers: headerParameters,
query: queryParameters,
},
initOverrides
);
return new runtime.VoidApiResponse(response);
}
/**
* Delete and disable a Webhook for an Inbox
*/
async deleteWebhook(
requestParameters: DeleteWebhookRequest,
initOverrides?: RequestInit
): Promise<void> {
await this.deleteWebhookRaw(requestParameters, initOverrides);
}
/**
* Delete a webhook
*/
async deleteWebhookByIdRaw(
requestParameters: DeleteWebhookByIdRequest,
initOverrides?: RequestInit
): Promise<runtime.ApiResponse<void>> {
if (
requestParameters.webhookId === null ||
requestParameters.webhookId === undefined
) {
throw new runtime.RequiredError(
'webhookId',
'Required parameter requestParameters.webhookId was null or undefined when calling deleteWebhookById.'
);
}
const queryParameters: any = {};
const headerParameters: runtime.HTTPHeaders = {};
if (this.configuration && this.configuration.apiKey) {
headerParameters['x-api-key'] = this.configuration.apiKey('x-api-key'); // API_KEY authentication
}
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);
}
/**
* Delete a webhook
*/
async deleteWebhookById(
requestParameters: DeleteWebhookByIdRequest,
initOverrides?: RequestInit
): Promise<void> {
await this.deleteWebhookByIdRaw(requestParameters, initOverrides);
}
/**
* List account webhooks in paginated form. Allows for page index, page size, and sort direction.
* List account webhooks Paginated
*/
async getAllAccountWebhooksRaw(
requestParameters: GetAllAccountWebhooksRequest,
initOverrides?: RequestInit
): Promise<runtime.ApiResponse<PageWebhookProjection>> {
const queryParameters: any = {};
if (requestParameters.page !== undefined) {
queryParameters['page'] = requestParameters.page;
}
if (requestParameters.size !== undefined) {
queryParameters['size'] = requestParameters.size;
}
if (requestParameters.sort !== undefined) {
queryParameters['sort'] = requestParameters.sort;
}
if (requestParameters.eventType !== undefined) {
queryParameters['eventType'] = requestParameters.eventType;
}
if (requestParameters.since !== undefined) {
queryParameters['since'] = (requestParameters.since as any).toISOString();
}
if (requestParameters.before !== undefined) {
queryParameters['before'] = (
requestParameters.before as any
).toISOString();
}
const headerParameters: runtime.HTTPHeaders = {};
if (this.configuration && this.configuration.apiKey) {
headerParameters['x-api-key'] = this.configuration.apiKey('x-api-key'); // API_KEY authentication
}
const response = await this.request(
{
path: `/webhooks/account/paginated`,
method: 'GET',
headers: headerParameters,
query: queryParameters,
},
initOverrides
);
return new runtime.JSONApiResponse(response, (jsonValue) =>
PageWebhookProjectionFromJSON(jsonValue)
);
}
/**
* List account webhooks in paginated form. Allows for page index, page size, and sort direction.
* List account webhooks Paginated
*/
async getAllAccountWebhooks(
requestParameters: GetAllAccountWebhooksRequest,
initOverrides?: RequestInit
): Promise<PageWebhookProjection> {
const response = await this.getAllAccountWebhooksRaw(
requestParameters,
initOverrides
);
return await response.value();
}
/**
* Get results for all webhooks
*/
async getAllWebhookResultsRaw(
requestParameters: GetAllWebhookResultsRequest,
initOverrides?: RequestInit
): Promise<runtime.ApiResponse<PageWebhookResult>> {
const queryParameters: any = {};
if (requestParameters.page !== undefined) {
queryParameters['page'] = requestParameters.page;
}
if (requestParameters.size !== undefined) {
queryParameters['size'] = requestParameters.size;
}
if (requestParameters.sort !== undefined) {
queryParameters['sort'] = requestParameters.sort;
}
if (requestParameters.searchFilter !== undefined) {
queryParameters['searchFilter'] = requestParameters.searchFilter;
}
if (requestParameters.since !== undefined) {
queryParameters['since'] = (requestParameters.since as any).toISOString();
}
if (requestParameters.before !== undefined) {
queryParameters['before'] = (
requestParameters.before as any
).toISOString();
}
if (requestParameters.unseenOnly !== undefined) {
queryParameters['unseenOnly'] = requestParameters.unseenOnly;
}
const headerParameters: runtime.HTTPHeaders = {};
if (this.configuration && this.configuration.apiKey) {
headerParameters['x-api-key'] = this.configuration.apiKey('x-api-key'); // API_KEY authentication
}
const response = await this.request(
{
path: `/webhooks/results`,
method: 'GET',
headers: headerParameters,
query: queryParameters,
},
initOverrides
);
return new runtime.JSONApiResponse(response, (jsonValue) =>
PageWebhookResultFromJSON(jsonValue)
);
}
/**
* Get results for all webhooks
*/
async getAllWebhookResults(
requestParameters: GetAllWebhookResultsRequest,
initOverrides?: RequestInit
): Promise<PageWebhookResult> {
const response = await this.getAllWebhookResultsRaw(
requestParameters,
initOverrides
);
return await response.value();
}
/**
* List webhooks in paginated form. Allows for page index, page size, and sort direction.
* List Webhooks Paginated
*/
async getAllWebhooksRaw(
requestParameters: GetAllWebhooksRequest,
initOverrides?: RequestInit
): Promise<runtime.ApiResponse<PageWebhookProjection>> {
const queryParameters: any = {};
if (requestParameters.page !== undefined) {
queryParameters['page'] = requestParameters.page;
}
if (requestParameters.size !== undefined) {
queryParameters['size'] = requestParameters.size;
}
if (requestParameters.sort !== undefined) {
queryParameters['sort'] = requestParameters.sort;
}
if (requestParameters.searchFilter !== undefined) {
queryParameters['searchFilter'] = requestParameters.searchFilter;
}
if (requestParameters.since !== undefined) {
queryParameters['since'] = (requestParameters.since as any).toISOString();
}
if (requestParameters.inboxId !== undefined) {
queryParameters['inboxId'] = requestParameters.inboxId;
}
if (requestParameters.phoneId !== undefined) {
queryParameters['phoneId'] = requestParameters.phoneId;
}
if (requestParameters.before !== undefined) {
queryParameters['before'] = (
requestParameters.before as any
).toISOString();
}
const headerParameters: runtime.HTTPHeaders = {};
if (this.configuration && this.configuration.apiKey) {
headerParameters['x-api-key'] = this.configuration.apiKey('x-api-key'); // API_KEY authentication
}
const response = await this.request(
{
path: `/webhooks/paginated`,
method: 'GET',
headers: headerParameters,
query: queryParameters,
},
initOverrides
);
return new runtime.JSONApiResponse(response, (jsonValue) =>
PageWebhookProjectionFromJSON(jsonValue)
);
}
/**
* List webhooks in paginated form. Allows for page index, page size, and sort direction.
* List Webhooks Paginated
*/
async getAllWebhooks(
requestParameters: GetAllWebhooksRequest,
initOverrides?: RequestInit
): Promise<PageWebhookProjection> {
const response = await this.getAllWebhooksRaw(
requestParameters,
initOverrides
);
return await response.value();
}
/**
* Get paginated webhooks for an Inbox
*/
async getInboxWebhooksPaginatedRaw(
requestParameters: GetInboxWebhooksPaginatedRequest,
initOverrides?: RequestInit
): Promise<runtime.ApiResponse<PageWebhookProjection>> {
if (
requestParameters.inboxId === null ||
requestParameters.inboxId === undefined
) {
throw new runtime.RequiredError(
'inboxId',
'Required parameter requestParameters.inboxId was null or undefined when calling getInboxWebhooksPaginated.'
);
}
const queryParameters: any = {};
if (requestParameters.page !== undefined) {
queryParameters['page'] = requestParameters.page;
}
if (requestParameters.size !== undefined) {
queryParameters['size'] = requestParameters.size;
}
if (requestParameters.sort !== undefined) {
queryParameters['sort'] = requestParameters.sort;
}
if (requestParameters.searchFilter !== undefined) {
queryParameters['searchFilter'] = requestParameters.searchFilter;
}
if (requestParameters.since !== undefined) {
queryParameters['since'] = (requestParameters.since as any).toISOString();
}
if (requestParameters.before !== undefined) {
queryParameters['before'] = (
requestParameters.before as any
).toISOString();
}
const headerParameters: runtime.HTTPHeaders = {};
if (this.configuration && this.configuration.apiKey) {
headerParameters['x-api-key'] = this.configuration.apiKey('x-api-key'); // API_KEY authentication
}
const response = await this.request(
{
path: `/inboxes/{inboxId}/webhooks/paginated`.replace(
`{${'inboxId'}}`,
encodeURIComponent(String(requestParameters.inboxId))
),
method: 'GET',
headers: headerParameters,
query: queryParameters,
},
initOverrides
);
return new runtime.JSONApiResponse(response, (jsonValue) =>
PageWebhookProjectionFromJSON(jsonValue)
);
}
/**
* Get paginated webhooks for an Inbox
*/
async getInboxWebhooksPaginated(
requestParameters: GetInboxWebhooksPaginatedRequest,
initOverrides?: RequestInit
): Promise<PageWebhookProjection> {
const response = await this.getInboxWebhooksPaginatedRaw(
requestParameters,
initOverrides
);
return await response.value();
}
/**
* Get JSON Schema definition for webhook payload by event
*/
async getJsonSchemaForWebhookEventRaw(
requestParameters: GetJsonSchemaForWebhookEventRequest,
initOverrides?: RequestInit
): Promise<runtime.ApiResponse<JSONSchemaDto>> {
if (
requestParameters.event === null ||
requestParameters.event === undefined
) {
throw new runtime.RequiredError(
'event',
'Required parameter requestParameters.event was null or undefined when calling getJsonSchemaForWebhookEvent.'
);
}
const queryParameters: any = {};
if (requestParameters.event !== undefined) {
queryParameters['event'] = requestParameters.event;
}
const headerParameters: runtime.HTTPHeaders = {};
if (this.configuration && this.configuration.apiKey) {
headerParameters['x-api-key'] = this.configuration.apiKey('x-api-key'); // API_KEY authentication
}
const response = await this.request(
{
path: `/webhooks/schema`,
method: 'POST',
headers: headerParameters,
query: queryParameters,
},
initOverrides
);
return new runtime.JSONApiResponse(response, (jsonValue) =>
JSONSchemaDtoFromJSON(jsonValue)
);
}
/**
* Get JSON Schema definition for webhook payload by event
*/
async getJsonSchemaForWebhookEvent(
requestParameters: GetJsonSchemaForWebhookEventRequest,
initOverrides?: RequestInit
): Promise<JSONSchemaDto> {
const response = await this.getJsonSchemaForWebhookEventRaw(
requestParameters,
initOverrides
);
return await response.value();
}
/**
* Get JSON Schema definition for webhook payload
*/
async getJsonSchemaForWebhookPayloadRaw(
requestParameters: GetJsonSchemaForWebhookPayloadRequest,
initOverrides?: RequestInit
): Promise<runtime.ApiResponse<JSONSchemaDto>> {
if (
requestParameters.webhookId === null ||
requestParameters.webhookId === undefined
) {
throw new runtime.RequiredError(
'webhookId',
'Required parameter requestParameters.webhookId was null or undefined when calling getJsonSchemaForWebhookPayload.'
);
}
const queryParameters: any = {};
const headerParameters: runtime.HTTPHeaders = {};
if (this.configuration && this.configuration.apiKey) {
headerParameters['x-api-key'] = this.configuration.apiKey('x-api-key'); // API_KEY authentication
}
const response = await this.request(
{
path: `/webhooks/{webhookId}/schema`.replace(
`{${'webhookId'}}`,
encodeURIComponent(String(requestParameters.webhookId))
),
method: 'POST',
headers: headerParameters,
query: queryParameters,
},
initOverrides
);
return new runtime.JSONApiResponse(response, (jsonValue) =>
JSONSchemaDtoFromJSON(jsonValue)
);
}
/**
* Get JSON Schema definition for webhook payload
*/
async getJsonSchemaForWebhookPayload(
requestParameters: GetJsonSchemaForWebhookPayloadRequest,
initOverrides?: RequestInit
): Promise<JSONSchemaDto> {
const response = await this.getJsonSchemaForWebhookPayloadRaw(
requestParameters,
initOverrides
);
return await response.value();
}
/**
* Get paginated webhooks for a phone number
*/
async getPhoneNumberWebhooksPaginatedRaw(
requestParameters: GetPhoneNumberWebhooksPaginatedRequest,
initOverrides?: RequestInit
): Promise<runtime.ApiResponse<PageWebhookProjection>> {
if (
requestParameters.phoneId === null ||
requestParameters.phoneId === undefined
) {
throw new runtime.RequiredError(
'phoneId',
'Required parameter requestParameters.phoneId was null or undefined when calling getPhoneNumberWebhooksPaginated.'
);
}
const queryParameters: any = {};
if (requestParameters.page !== undefined) {
queryParameters['page'] = requestParameters.page;
}
if (requestParameters.size !== undefined) {
queryParameters['size'] = requestParameters.size;
}
if (requestParameters.sort !== undefined) {
queryParameters['sort'] = requestParameters.sort;
}
if (requestParameters.since !== undefined) {
queryParameters['since'] = (requestParameters.since as any).toISOString();
}
if (requestParameters.before !== undefined) {
queryParameters['before'] = (
requestParameters.before as any
).toISOString();
}
const headerParameters: runtime.HTTPHeaders = {};
if (this.configuration && this.configuration.apiKey) {
headerParameters['x-api-key'] = this.configuration.apiKey('x-api-key'); // API_KEY authentication
}
const response = await this.request(
{
path: `/phone/numbers/{phoneId}/webhooks/paginated`.replace(
`{${'phoneId'}}`,
encodeURIComponent(String(requestParameters.phoneId))
),
method: 'GET',
headers: headerParameters,
query: queryParameters,
},
initOverrides
);
return new runtime.JSONApiResponse(response, (jsonValue) =>
PageWebhookProjectionFromJSON(jsonValue)
);
}
/**
* Get paginated webhooks for a phone number
*/
async getPhoneNumberWebhooksPaginated(
requestParameters: GetPhoneNumberWebhooksPaginatedRequest,
initOverrides?: RequestInit
): Promise<PageWebhookProjection> {
const response = await this.getPhoneNumberWebhooksPaginatedRaw(
requestParameters,
initOverrides
);
return await response.value();
}
/**
* Get test webhook payload example. Response content depends on eventName passed. Uses `EMAIL_RECEIVED` as default.
*/
async getTestWebhookPayloadRaw(
requestParameters: GetTestWebhookPayloadRequest,
initOverrides?: RequestInit
): Promise<runtime.ApiResponse<AbstractWebhookPayload>> {
const queryParameters: any = {};
if (requestParameters.eventName !== undefined) {
queryParameters['eventName'] = requestParameters.eventName;
}
const headerParameters: runtime.HTTPHeaders = {};
if (this.configuration && this.configuration.apiKey) {
headerParameters['x-api-key'] = this.configuration.apiKey('x-api-key'); // API_KEY authentication
}
const response = await this.request(
{
path: `/webhooks/test`,
method: 'GET',
headers: headerParameters,
query: queryParameters,
},
initOverrides
);
return new runtime.JSONApiResponse(response, (jsonValue) =>
AbstractWebhookPayloadFromJSON(jsonValue)
);
}
/**
* Get test webhook payload example. Response content depends on eventName passed. Uses `EMAIL_RECEIVED` as default.
*/
async getTestWebhookPayload(
requestParameters: GetTestWebhookPayloadRequest,
initOverrides?: RequestInit
): Promise<AbstractWebhookPayload> {
const response = await this.getTestWebhookPayloadRaw(
requestParameters,
initOverrides
);
return await response.value();
}
/**
* Get webhook test payload for bounce
*/
async getTestWebhookPayloadBounceRaw(
initOverrides?: RequestInit
): Promise<runtime.ApiResponse<WebhookBouncePayload>> {
const queryParameters: any = {};
const headerParameters: runtime.HTTPHeaders = {};
if (this.configuration && this.configuration.apiKey) {
headerParameters['x-api-key'] = this.configuration.apiKey('x-api-key'); // API_KEY authentication
}
const response = await this.request(
{
path: `/webhooks/test/email-bounce-payload`,
method: 'GET',
headers: headerParameters,
query: queryParameters,
},
initOverrides
);
return new runtime.JSONApiResponse(response, (jsonValue) =>
WebhookBouncePayloadFromJSON(jsonValue)
);
}
/**
* Get webhook test payload for bounce
*/
async getTestWebhookPayloadBounce(
initOverrides?: RequestInit
): Promise<WebhookBouncePayload> {
const response = await this.getTestWebhookPayloadBounceRaw(initOverrides);
return await response.value();
}
/**
* Get webhook test payload for bounce recipient
*/
async getTestWebhookPayloadBounceRecipientRaw(
initOverrides?: RequestInit
): Promise<runtime.ApiResponse<WebhookBounceRecipientPayload>> {
const queryParameters: any = {};
const headerParameters: runtime.HTTPHeaders = {};
if (this.configuration && this.configuration.apiKey) {
headerParameters['x-api-key'] = this.configuration.apiKey('x-api-key'); // API_KEY authentication
}
const response = await this.request(
{
path: `/webhooks/test/email-bounce-recipient-payload`,
method: 'GET',
headers: headerParameters,
query: queryParameters,
},
initOverrides
);
return new runtime.JSONApiResponse(response, (jsonValue) =>
WebhookBounceRecipientPayloadFromJSON(jsonValue)
);
}
/**
* Get webhook test payload for bounce recipient
*/
async getTestWebhookPayloadBounceRecipient(
initOverrides?: RequestInit
): Promise<WebhookBounceRecipientPayload> {
const response = await this.getTestWebhookPayloadBounceRecipientRaw(
initOverrides
);
return await response.value();
}
/**
* Get webhook test payload for delivery status event
*/
async getTestWebhookPayloadDeliveryStatusRaw(
initOverrides?: RequestInit
): Promise<runtime.ApiResponse<WebhookDeliveryStatusPayload>> {
const queryParameters: any = {};
const headerParameters: runtime.HTTPHeaders = {};
if (this.configuration && this.configuration.apiKey) {
headerParameters['x-api-key'] = this.configuration.apiKey('x-api-key'); // API_KEY authentication
}
const response = await this.request(
{
path: `/webhooks/test/delivery-status-payload`,
method: 'GET',
headers: headerParameters,
query: queryParameters,
},
initOverrides
);
return new runtime.JSONApiResponse(response, (jsonValue) =>
WebhookDeliveryStatusPayloadFromJSON(jsonValue)
);
}
/**
* Get webhook test payload for delivery status event
*/
async getTestWebhookPayloadDeliveryStatus(
initOverrides?: RequestInit
): Promise<WebhookDeliveryStatusPayload> {
const response = await this.getTestWebhookPayloadDeliveryStatusRaw(
initOverrides
);
return await response.value();
}
/**
* Get webhook test payload for email opened event
*/
async getTestWebhookPayloadEmailOpenedRaw(
initOverrides?: RequestInit
): Promise<runtime.ApiResponse<WebhookEmailOpenedPayload>> {
const queryParameters: any = {};
const headerParameters: runtime.HTTPHeaders = {};
if (this.configuration && this.configuration.apiKey) {
headerParameters['x-api-key'] = this.configuration.apiKey('x-api-key'); // API_KEY authentication
}
const response = await this.request(
{
path: `/webhooks/test/email-opened-payload`,
method: 'GET',
headers: headerParameters,
query: queryParameters,
},
initOverrides
);
return new runtime.JSONApiResponse(response, (jsonValue) =>
WebhookEmailOpenedPayloadFromJSON(jsonValue)
);
}
/**
* Get webhook test payload for email opened event
*/
async getTestWebhookPayloadEmailOpened(
initOverrides?: RequestInit
): Promise<WebhookEmailOpenedPayload> {
const response = await this.getTestWebhookPayloadEmailOpenedRaw(
initOverrides
);
return await response.value();
}
/**
* Get webhook test payload for email opened event
*/
async getTestWebhookPayloadEmailReadRaw(
initOverrides?: RequestInit
): Promise<runtime.ApiResponse<WebhookEmailReadPayload>> {
const queryParameters: any = {};
const headerParameters: runtime.HTTPHeaders = {};
if (this.configuration && this.configuration.apiKey) {
headerParameters['x-api-key'] = this.configuration.apiKey('x-api-key'); // API_KEY authentication
}
const response = await this.request(
{
path: `/webhooks/test/email-read-payload`,
method: 'GET',
headers: headerParameters,
query: queryParameters,
},
initOverrides
);
return new runtime.JSONApiResponse(response, (jsonValue) =>
WebhookEmailReadPayloadFromJSON(jsonValue)
);
}
/**
* Get webhook test payload for email opened event
*/
async getTestWebhookPayloadEmailRead(
initOverrides?: RequestInit
): Promise<WebhookEmailReadPayload> {
const response = await this.getTestWebhookPayloadEmailReadRaw(
initOverrides
);
return await response.value();
}
/**
* Get example payload for webhook
*/
async getTestWebhookPayloadForWebhookRaw(
requestParameters: GetTestWebhookPayloadForWebhookRequest,
initOverrides?: RequestInit
): Promise<runtime.ApiResponse<AbstractWebhookPayload>> {
if (
requestParameters.webhookId === null ||
requestParameters.webhookId === undefined
) {
throw new runtime.RequiredError(
'webhookId',
'Required parameter requestParameters.webhookId was null or undefined when calling getTestWebhookPayloadForWebhook.'
);
}
const queryParameters: any = {};
const headerParameters: runtime.HTTPHeaders = {};
if (this.configuration && this.configuration.apiKey) {
headerParameters['x-api-key'] = this.configuration.apiKey('x-api-key'); // API_KEY authentication
}
const response = await this.request(
{
path: `/webhooks/{webhookId}/example`.replace(
`{${'webhookId'}}`,
encodeURIComponent(String(requestParameters.webhookId))
),
method: 'POST',
headers: headerParameters,
query: queryParameters,
},
initOverrides
);
return new runtime.JSONApiResponse(response, (jsonValue) =>
AbstractWebhookPayloadFromJSON(jsonValue)
);
}
/**
* Get example payload for webhook
*/
async getTestWebhookPayloadForWebhook(
requestParameters: GetTestWebhookPayloadForWebhookRequest,
initOverrides?: RequestInit
): Promise<AbstractWebhookPayload> {
const response = await this.getTestWebhookPayloadForWebhookRaw(
requestParameters,
initOverrides
);
return await response.value();
}
/**
* Get webhook test payload for new attachment event
*/
async getTestWebhookPayloadNewAttachmentRaw(
initOverrides?: RequestInit
): Promise<runtime.ApiResponse<WebhookNewAttachmentPayload>> {
const queryParameters: any = {};
const headerParameters: runtime.HTTPHeaders = {};
if (this.configuration && this.configuration.apiKey) {
headerParameters['x-api-key'] = this.configuration.apiKey('x-api-key'); // API_KEY authentication
}
const response = await this.request(
{
path: `/webhooks/test/new-attachment-payload`,
method: 'GET',
headers: headerParameters,
query: queryParameters,
},
initOverrides
);
return new runtime.JSONApiResponse(response, (jsonValue) =>
WebhookNewAttachmentPayloadFromJSON(jsonValue)
);
}
/**
* Get webhook test payload for new attachment event
*/
async getTestWebhookPayloadNewAttachment(
initOverrides?: RequestInit
): Promise<WebhookNewAttachmentPayload> {
const response = await this.getTestWebhookPayloadNewAttachmentRaw(
initOverrides
);
return await response.value();
}
/**
* Get webhook test payload for new contact event
*/
async getTestWebhookPayloadNewContactRaw(
initOverrides?: RequestInit
): Promise<runtime.ApiResponse<WebhookNewContactPayload>> {
const queryParameters: any = {};
const headerParameters: runtime.HTTPHeaders = {};
if (this.configuration && this.configuration.apiKey) {
headerParameters['x-api-key'] = this.configuration.apiKey('x-api-key'); // API_KEY authentication
}
const response = await this.request(
{
path: `/webhooks/test/new-contact-payload`,
method: 'GET',
headers: headerParameters,
query: queryParameters,
},
initOverrides
);
return new runtime.JSONApiResponse(response, (jsonValue) =>
WebhookNewContactPayloadFromJSON(jsonValue)
);
}
/**
* Get webhook test payload for new contact event
*/
async getTestWebhookPayloadNewContact(
initOverrides?: RequestInit
): Promise<WebhookNewContactPayload> {
const response = await this.getTestWebhookPayloadNewContactRaw(
initOverrides
);
return await response.value();
}
/**
* Get webhook test payload for new email event
*/
async getTestWebhookPayloadNewEmailRaw(
initOverrides?: RequestInit
): Promise<runtime.ApiResponse<WebhookNewEmailPayload>> {
const queryParameters: any = {};
const headerParameters: runtime.HTTPHeaders = {};
if (this.configuration && this.configuration.apiKey) {
headerParameters['x-api-key'] = this.configuration.apiKey('x-api-key'); // API_KEY authentication
}
const response = await this.request(
{
path: `/webhooks/test/new-email-payload`,
method: 'GET',
headers: headerParameters,
query: queryParameters,
},
initOverrides
);
return new runtime.JSONApiResponse(response, (jsonValue) =>
WebhookNewEmailPayloadFromJSON(jsonValue)
);
}
/**
* Get webhook test payload for new email event
*/
async getTestWebhookPayloadNewEmail(
initOverrides?: RequestInit
): Promise<WebhookNewEmailPayload> {
const response = await this.getTestWebhookPayloadNewEmailRaw(initOverrides);
return await response.value();
}
/**
* Get webhook test payload for new sms event
*/
async getTestWebhookPayloadNewSmsRaw(
initOverrides?: RequestInit
): Promise<runtime.ApiResponse<WebhookNewSmsPayload>> {
const queryParameters: any = {};
const headerParameters: runtime.HTTPHeaders = {};
if (this.configuration && this.configuration.apiKey) {
headerParameters['x-api-key'] = this.configuration.apiKey('x-api-key'); // API_KEY authentication
}
const response = await this.request(
{
path: `/webhooks/test/new-sms-payload`,
method: 'GET',
headers: headerParameters,
query: queryParameters,
},
initOverrides
);
return new runtime.JSONApiResponse(response, (jsonValue) =>
WebhookNewSmsPayloadFromJSON(jsonValue)
);
}
/**
* Get webhook test payload for new sms event
*/
async getTestWebhookPayloadNewSms(
initOverrides?: RequestInit
): Promise<WebhookNewSmsPayload> {
const response = await this.getTestWebhookPayloadNewSmsRaw(initOverrides);
return await response.value();
}
/**
* Get a webhook
*/
async getWebhookRaw(
requestParameters: GetWebhookRequest,
initOverrides?: RequestInit
): Promise<runtime.ApiResponse<WebhookDto>> {
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: any = {};
const headerParameters: runtime.HTTPHeaders = {};
if (this.configuration && this.configuration.apiKey) {
headerParameters['x-api-key'] = this.configuration.apiKey('x-api-key'); // API_KEY authentication
}
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) =>
WebhookDtoFromJSON(jsonValue)
);
}
/**
* Get a webhook
*/
async getWebhook(
requestParameters: GetWebhookRequest,
initOverrides?: RequestInit
): Promise<WebhookDto> {
const response = await this.getWebhookRaw(requestParameters, initOverrides);
return await response.value();
}
/**
* Get a webhook result for a webhook
*/
async getWebhookResultRaw(
requestParameters: GetWebhookResultRequest,
initOverrides?: RequestInit
): Promise<runtime.ApiResponse<WebhookResultDto>> {
if (
requestParameters.webhookResultId === null ||
requestParameters.webhookResultId === undefined
) {
throw new runtime.RequiredError(
'webhookResultId',
'Required parameter requestParameters.webhookResultId was null or undefined when calling getWebhookResult.'
);
}
const queryParameters: any = {};
const headerParameters: runtime.HTTPHeaders = {};
if (this.configuration && this.configuration.apiKey) {
headerParameters['x-api-key'] = this.configuration.apiKey('x-api-key'); // API_KEY authentication
}
const response = await this.request(
{
path: `/webhooks/results/{webhookResultId}`.replace(
`{${'webhookResultId'}}`,
encodeURIComponent(String(requestParameters.webhookResultId))
),
method: 'GET',
headers: headerParameters,
query: queryParameters,
},
initOverrides
);
return new runtime.JSONApiResponse(response, (jsonValue) =>
WebhookResultDtoFromJSON(jsonValue)
);
}
/**
* Get a webhook result for a webhook
*/
async getWebhookResult(
requestParameters: GetWebhookResultRequest,
initOverrides?: RequestInit
): Promise<WebhookResultDto> {
const response = await this.getWebhookResultRaw(
requestParameters,
initOverrides
);
return await response.value();
}
/**
* Get a webhook results for a webhook
*/
async getWebhookResultsRaw(
requestParameters: GetWebhookResultsRequest,
initOverrides?: RequestInit
): Promise<runtime.ApiResponse<PageWebhookResult>> {
if (
requestParameters.webhookId === null ||
requestParameters.webhookId === undefined
) {
throw new runtime.RequiredError(
'webhookId',
'Required parameter requestParameters.webhookId was null or undefined when calling getWebhookResults.'
);
}
const queryParameters: any = {};
if (requestParameters.page !== undefined) {
queryParameters['page'] = requestParameters.page;
}
if (requestParameters.size !== undefined) {
queryParameters['size'] = requestParameters.size;
}
if (requestParameters.sort !== undefined) {
queryParameters['sort'] = requestParameters.sort;
}
if (requestParameters.searchFilter !== undefined) {
queryParameters['searchFilter'] = requestParameters.searchFilter;
}
if (requestParameters.since !== undefined) {
queryParameters['since'] = (requestParameters.since as any).toISOString();
}
if (requestParameters.before !== undefined) {
queryParameters['before'] = (
requestParameters.before as any
).toISOString();
}
if (requestParameters.unseenOnly !== undefined) {
queryParameters['unseenOnly'] = requestParameters.unseenOnly;
}
const headerParameters: runtime.HTTPHeaders = {};
if (this.configuration && this.configuration.apiKey) {
headerParameters['x-api-key'] = this.configuration.apiKey('x-api-key'); // API_KEY authentication
}
const response = await this.request(
{
path: `/webhooks/{webhookId}/results`.replace(
`{${'webhookId'}}`,
encodeURIComponent(String(requestParameters.webhookId))
),
method: 'GET',
headers: headerParameters,
query: queryParameters,
},
initOverrides
);
return new runtime.JSONApiResponse(response, (jsonValue) =>
PageWebhookResultFromJSON(jsonValue)
);
}
/**
* Get a webhook results for a webhook
*/
async getWebhookResults(
requestParameters: GetWebhookResultsRequest,
initOverrides?: RequestInit
): Promise<PageWebhookResult> {
const response = await thi