UNPKG

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.

287 lines (247 loc) 8.5 kB
/* tslint:disable */ /* eslint-disable */ /** * MailSlurp API * MailSlurp is an API for sending and receiving emails and SMS from dynamically allocated email addresses and phone numbers. 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 { OptInConsentOptions, OptInConsentOptionsFromJSON, OptInConsentOptionsToJSON, OptInConsentSendResult, OptInConsentSendResultFromJSON, OptInConsentSendResultToJSON, OptInSendingConsentDto, OptInSendingConsentDtoFromJSON, OptInSendingConsentDtoToJSON, PageOptInIdentityProjection, PageOptInIdentityProjectionFromJSON, PageOptInIdentityProjectionToJSON, } from '../models'; export interface CheckSendingConsentForEmailAddressRequest { emailAddress: string; } export interface GetOptInIdentitiesRequest { page?: number; size?: number; sort?: GetOptInIdentitiesSortEnum; } export interface RevokeOptInConsentForEmailAddressRequest { emailAddress: string; } export interface SendOptInConsentForEmailAddressRequest { optInConsentOptions: OptInConsentOptions; } /** * */ export class ConsentControllerApi extends runtime.BaseAPI { /** */ async checkSendingConsentForEmailAddressRaw( requestParameters: CheckSendingConsentForEmailAddressRequest, initOverrides?: RequestInit ): Promise<runtime.ApiResponse<OptInSendingConsentDto>> { if ( requestParameters.emailAddress === null || requestParameters.emailAddress === undefined ) { throw new runtime.RequiredError( 'emailAddress', 'Required parameter requestParameters.emailAddress was null or undefined when calling checkSendingConsentForEmailAddress.' ); } const queryParameters: any = {}; if (requestParameters.emailAddress !== undefined) { queryParameters['emailAddress'] = requestParameters.emailAddress; } 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: `/consent/opt-in/sending-consent`, method: 'GET', headers: headerParameters, query: queryParameters, }, initOverrides ); return new runtime.JSONApiResponse(response, (jsonValue) => OptInSendingConsentDtoFromJSON(jsonValue) ); } /** */ async checkSendingConsentForEmailAddress( requestParameters: CheckSendingConsentForEmailAddressRequest, initOverrides?: RequestInit ): Promise<OptInSendingConsentDto> { const response = await this.checkSendingConsentForEmailAddressRaw( requestParameters, initOverrides ); return await response.value(); } /** */ async getOptInIdentitiesRaw( requestParameters: GetOptInIdentitiesRequest, initOverrides?: RequestInit ): Promise<runtime.ApiResponse<PageOptInIdentityProjection>> { 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; } 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: `/consent/opt-in`, method: 'GET', headers: headerParameters, query: queryParameters, }, initOverrides ); return new runtime.JSONApiResponse(response, (jsonValue) => PageOptInIdentityProjectionFromJSON(jsonValue) ); } /** */ async getOptInIdentities( requestParameters: GetOptInIdentitiesRequest, initOverrides?: RequestInit ): Promise<PageOptInIdentityProjection> { const response = await this.getOptInIdentitiesRaw( requestParameters, initOverrides ); return await response.value(); } /** */ async revokeOptInConsentForEmailAddressRaw( requestParameters: RevokeOptInConsentForEmailAddressRequest, initOverrides?: RequestInit ): Promise<runtime.ApiResponse<OptInSendingConsentDto>> { if ( requestParameters.emailAddress === null || requestParameters.emailAddress === undefined ) { throw new runtime.RequiredError( 'emailAddress', 'Required parameter requestParameters.emailAddress was null or undefined when calling revokeOptInConsentForEmailAddress.' ); } const queryParameters: any = {}; if (requestParameters.emailAddress !== undefined) { queryParameters['emailAddress'] = requestParameters.emailAddress; } 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: `/consent/opt-in`, method: 'DELETE', headers: headerParameters, query: queryParameters, }, initOverrides ); return new runtime.JSONApiResponse(response, (jsonValue) => OptInSendingConsentDtoFromJSON(jsonValue) ); } /** */ async revokeOptInConsentForEmailAddress( requestParameters: RevokeOptInConsentForEmailAddressRequest, initOverrides?: RequestInit ): Promise<OptInSendingConsentDto> { const response = await this.revokeOptInConsentForEmailAddressRaw( requestParameters, initOverrides ); return await response.value(); } /** * Send double-opt in consent for an email address * Send a verification code to a user once they have explicitly submitted their email address */ async sendOptInConsentForEmailAddressRaw( requestParameters: SendOptInConsentForEmailAddressRequest, initOverrides?: RequestInit ): Promise<runtime.ApiResponse<OptInConsentSendResult>> { if ( requestParameters.optInConsentOptions === null || requestParameters.optInConsentOptions === undefined ) { throw new runtime.RequiredError( 'optInConsentOptions', 'Required parameter requestParameters.optInConsentOptions was null or undefined when calling sendOptInConsentForEmailAddress.' ); } 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: `/consent/opt-in/send`, method: 'POST', headers: headerParameters, query: queryParameters, body: OptInConsentOptionsToJSON(requestParameters.optInConsentOptions), }, initOverrides ); return new runtime.JSONApiResponse(response, (jsonValue) => OptInConsentSendResultFromJSON(jsonValue) ); } /** * Send double-opt in consent for an email address * Send a verification code to a user once they have explicitly submitted their email address */ async sendOptInConsentForEmailAddress( requestParameters: SendOptInConsentForEmailAddressRequest, initOverrides?: RequestInit ): Promise<OptInConsentSendResult> { const response = await this.sendOptInConsentForEmailAddressRaw( requestParameters, initOverrides ); return await response.value(); } } /** * @export * @enum {string} */ export enum GetOptInIdentitiesSortEnum { ASC = 'ASC', DESC = 'DESC', }