/* tslint:disable */ /* eslint-disable */ /** * Tuix Email Service * Service to manage Tuix Email * * The version of the OpenAPI document: 0.0.1 * * * 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 { type AccountDTO, AccountDTOFromJSON, AccountDTOToJSON, } from '../models/AccountDTO'; import { type ApplicationDTO, ApplicationDTOFromJSON, ApplicationDTOToJSON, } from '../models/ApplicationDTO'; import { type CreateAPIKeyRequestDTO, CreateAPIKeyRequestDTOFromJSON, CreateAPIKeyRequestDTOToJSON, } from '../models/CreateAPIKeyRequestDTO'; import { type CreateAPIKeyResponseDTO, CreateAPIKeyResponseDTOFromJSON, CreateAPIKeyResponseDTOToJSON, } from '../models/CreateAPIKeyResponseDTO'; import { type CreateAccountDTO, CreateAccountDTOFromJSON, CreateAccountDTOToJSON, } from '../models/CreateAccountDTO'; import { type CreateApplicationDTO, CreateApplicationDTOFromJSON, CreateApplicationDTOToJSON, } from '../models/CreateApplicationDTO'; import { type EmailTemplateContentDTO, EmailTemplateContentDTOFromJSON, EmailTemplateContentDTOToJSON, } from '../models/EmailTemplateContentDTO'; import { type EmailTemplateDTO, EmailTemplateDTOFromJSON, EmailTemplateDTOToJSON, } from '../models/EmailTemplateDTO'; import { type ErrorDTO, ErrorDTOFromJSON, ErrorDTOToJSON, } from '../models/ErrorDTO'; import { type GetAPIKeysResponseDTO, GetAPIKeysResponseDTOFromJSON, GetAPIKeysResponseDTOToJSON, } from '../models/GetAPIKeysResponseDTO'; import { type PaginatedApplicationsDTO, PaginatedApplicationsDTOFromJSON, PaginatedApplicationsDTOToJSON, } from '../models/PaginatedApplicationsDTO'; import { type PaginatedEmailTemplateDTO, PaginatedEmailTemplateDTOFromJSON, PaginatedEmailTemplateDTOToJSON, } from '../models/PaginatedEmailTemplateDTO'; import { type UpdateApplicationDTO, UpdateApplicationDTOFromJSON, UpdateApplicationDTOToJSON, } from '../models/UpdateApplicationDTO'; import { type UpdateEmailTemplateDTO, UpdateEmailTemplateDTOFromJSON, UpdateEmailTemplateDTOToJSON, } from '../models/UpdateEmailTemplateDTO'; export interface ApiKeysGetRequest { page?: number; pageSize?: number; } export interface ApiKeysIdDeleteRequest { id: string; } export interface ApiKeysPostRequest { createAPIKeyRequestDTO: CreateAPIKeyRequestDTO; } export interface ApiSendEmailRequest { applicationId: string; templateUUID: string; to: string; body?: string; data?: string; file?: Blob; } export interface CreateAccountRequest { createAccountDTO: CreateAccountDTO; } export interface CreateApplicationRequest { createApplicationDTO: CreateApplicationDTO; } export interface DeleteApplicationRequest { applicationId: string; } export interface DeleteTemplateRequest { id: string; applicationId: string; } export interface GetApplicationByIDRequest { applicationId: string; } export interface GetApplicationsRequest { page?: number; pageSize?: number; search?: string; sortBy?: GetApplicationsSortByEnum; sortDirection?: GetApplicationsSortDirectionEnum; } export interface GetTemplateRequest { id: string; applicationId: string; } export interface GetTemplatesRequest { applicationId: string; page?: number; pageSize?: number; search?: string; sortBy?: GetTemplatesSortByEnum; sortDirection?: GetTemplatesSortDirectionEnum; } export interface SendEmailRequest { applicationId: string; templateUUID: string; to: string; body?: string; data?: string; file?: Blob; } export interface UpdateApplicationRequest { applicationId: string; updateApplicationDTO: UpdateApplicationDTO; } export interface UpdateTemplateRequest { applicationId: string; id: string; file?: Blob; fromEmail?: string; name?: string; subject?: string; toEmail?: string; } export interface UploadTemplateRequest { applicationId: string; file: Blob; fromEmail: string; name: string; subject: string; toEmail?: string; } /** * */ export class ClientApi extends runtime.BaseAPI { /** * Creates request options for apiKeysGet without sending the request */ async apiKeysGetRequestOpts(requestParameters: ApiKeysGetRequest): Promise { const queryParameters: any = {}; if (requestParameters['page'] != null) { queryParameters['page'] = requestParameters['page']; } if (requestParameters['pageSize'] != null) { queryParameters['page_size'] = requestParameters['pageSize']; } const headerParameters: runtime.HTTPHeaders = {}; if (this.configuration && this.configuration.apiKey) { headerParameters["Authorization"] = await this.configuration.apiKey("Authorization"); // auth0JWT authentication } let urlPath = `/api-keys`; return { path: urlPath, method: 'GET', headers: headerParameters, query: queryParameters, }; } /** * Retrieve all API keys associated with the authenticated user\'s account with pagination. * Get all API keys for the authenticated user */ async apiKeysGetRaw(requestParameters: ApiKeysGetRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise> { const requestOptions = await this.apiKeysGetRequestOpts(requestParameters); const response = await this.request(requestOptions, initOverrides); return new runtime.JSONApiResponse(response, (jsonValue) => GetAPIKeysResponseDTOFromJSON(jsonValue)); } /** * Retrieve all API keys associated with the authenticated user\'s account with pagination. * Get all API keys for the authenticated user */ async apiKeysGet(requestParameters: ApiKeysGetRequest = {}, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise { const response = await this.apiKeysGetRaw(requestParameters, initOverrides); return await response.value(); } /** * Creates request options for apiKeysIdDelete without sending the request */ async apiKeysIdDeleteRequestOpts(requestParameters: ApiKeysIdDeleteRequest): Promise { if (requestParameters['id'] == null) { throw new runtime.RequiredError( 'id', 'Required parameter "id" was null or undefined when calling apiKeysIdDelete().' ); } const queryParameters: any = {}; const headerParameters: runtime.HTTPHeaders = {}; if (this.configuration && this.configuration.apiKey) { headerParameters["Authorization"] = await this.configuration.apiKey("Authorization"); // auth0JWT authentication } let urlPath = `/api-keys/{id}`; urlPath = urlPath.replace('{id}', encodeURIComponent(String(requestParameters['id']))); return { path: urlPath, method: 'DELETE', headers: headerParameters, query: queryParameters, }; } /** * Delete a specific API key belonging to the authenticated user. * Delete an API key */ async apiKeysIdDeleteRaw(requestParameters: ApiKeysIdDeleteRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise> { const requestOptions = await this.apiKeysIdDeleteRequestOpts(requestParameters); const response = await this.request(requestOptions, initOverrides); return new runtime.VoidApiResponse(response); } /** * Delete a specific API key belonging to the authenticated user. * Delete an API key */ async apiKeysIdDelete(requestParameters: ApiKeysIdDeleteRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise { await this.apiKeysIdDeleteRaw(requestParameters, initOverrides); } /** * Creates request options for apiKeysPost without sending the request */ async apiKeysPostRequestOpts(requestParameters: ApiKeysPostRequest): Promise { if (requestParameters['createAPIKeyRequestDTO'] == null) { throw new runtime.RequiredError( 'createAPIKeyRequestDTO', 'Required parameter "createAPIKeyRequestDTO" was null or undefined when calling apiKeysPost().' ); } const queryParameters: any = {}; const headerParameters: runtime.HTTPHeaders = {}; headerParameters['Content-Type'] = 'application/json'; if (this.configuration && this.configuration.apiKey) { headerParameters["Authorization"] = await this.configuration.apiKey("Authorization"); // auth0JWT authentication } let urlPath = `/api-keys`; return { path: urlPath, method: 'POST', headers: headerParameters, query: queryParameters, body: CreateAPIKeyRequestDTOToJSON(requestParameters['createAPIKeyRequestDTO']), }; } /** * Create a new API key for accessing the RAG service. * Create a new API key */ async apiKeysPostRaw(requestParameters: ApiKeysPostRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise> { const requestOptions = await this.apiKeysPostRequestOpts(requestParameters); const response = await this.request(requestOptions, initOverrides); return new runtime.JSONApiResponse(response, (jsonValue) => CreateAPIKeyResponseDTOFromJSON(jsonValue)); } /** * Create a new API key for accessing the RAG service. * Create a new API key */ async apiKeysPost(requestParameters: ApiKeysPostRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise { const response = await this.apiKeysPostRaw(requestParameters, initOverrides); return await response.value(); } /** * Creates request options for apiSendEmail without sending the request */ async apiSendEmailRequestOpts(requestParameters: ApiSendEmailRequest): Promise { if (requestParameters['applicationId'] == null) { throw new runtime.RequiredError( 'applicationId', 'Required parameter "applicationId" was null or undefined when calling apiSendEmail().' ); } if (requestParameters['templateUUID'] == null) { throw new runtime.RequiredError( 'templateUUID', 'Required parameter "templateUUID" was null or undefined when calling apiSendEmail().' ); } if (requestParameters['to'] == null) { throw new runtime.RequiredError( 'to', 'Required parameter "to" was null or undefined when calling apiSendEmail().' ); } const queryParameters: any = {}; const headerParameters: runtime.HTTPHeaders = {}; if (this.configuration && this.configuration.apiKey) { headerParameters["x-api-key"] = await this.configuration.apiKey("x-api-key"); // api_key authentication } const consumes: runtime.Consume[] = [ { contentType: 'multipart/form-data' }, ]; // @ts-ignore: canConsumeForm may be unused const canConsumeForm = runtime.canConsumeForm(consumes); let formParams: { append(param: string, value: any): any }; let useForm = false; // use FormData to transmit files using content-type "multipart/form-data" useForm = canConsumeForm; if (useForm) { formParams = new FormData(); } else { formParams = new URLSearchParams(); } if (requestParameters['body'] != null) { formParams.append('body', requestParameters['body'] as any); } if (requestParameters['data'] != null) { formParams.append('data', requestParameters['data'] as any); } if (requestParameters['file'] != null) { formParams.append('file', requestParameters['file'] as any); } if (requestParameters['templateUUID'] != null) { formParams.append('templateUUID', requestParameters['templateUUID'] as any); } if (requestParameters['to'] != null) { formParams.append('to', requestParameters['to'] as any); } let urlPath = `/api/applications/{applicationId}/emails/send`; urlPath = urlPath.replace('{applicationId}', encodeURIComponent(String(requestParameters['applicationId']))); return { path: urlPath, method: 'POST', headers: headerParameters, query: queryParameters, body: formParams, }; } /** * Send an email * Send an email */ async apiSendEmailRaw(requestParameters: ApiSendEmailRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise> { const requestOptions = await this.apiSendEmailRequestOpts(requestParameters); const response = await this.request(requestOptions, initOverrides); return new runtime.VoidApiResponse(response); } /** * Send an email * Send an email */ async apiSendEmail(requestParameters: ApiSendEmailRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise { await this.apiSendEmailRaw(requestParameters, initOverrides); } /** * Creates request options for createAccount without sending the request */ async createAccountRequestOpts(requestParameters: CreateAccountRequest): Promise { if (requestParameters['createAccountDTO'] == null) { throw new runtime.RequiredError( 'createAccountDTO', 'Required parameter "createAccountDTO" was null or undefined when calling createAccount().' ); } const queryParameters: any = {}; const headerParameters: runtime.HTTPHeaders = {}; headerParameters['Content-Type'] = 'application/json'; if (this.configuration && this.configuration.apiKey) { headerParameters["Authorization"] = await this.configuration.apiKey("Authorization"); // auth0JWT authentication } let urlPath = `/accounts`; return { path: urlPath, method: 'POST', headers: headerParameters, query: queryParameters, body: CreateAccountDTOToJSON(requestParameters['createAccountDTO']), }; } /** * Create an account * Creates a new account */ async createAccountRaw(requestParameters: CreateAccountRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise> { const requestOptions = await this.createAccountRequestOpts(requestParameters); const response = await this.request(requestOptions, initOverrides); return new runtime.JSONApiResponse(response, (jsonValue) => AccountDTOFromJSON(jsonValue)); } /** * Create an account * Creates a new account */ async createAccount(requestParameters: CreateAccountRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise { const response = await this.createAccountRaw(requestParameters, initOverrides); return await response.value(); } /** * Creates request options for createApplication without sending the request */ async createApplicationRequestOpts(requestParameters: CreateApplicationRequest): Promise { if (requestParameters['createApplicationDTO'] == null) { throw new runtime.RequiredError( 'createApplicationDTO', 'Required parameter "createApplicationDTO" was null or undefined when calling createApplication().' ); } const queryParameters: any = {}; const headerParameters: runtime.HTTPHeaders = {}; headerParameters['Content-Type'] = 'application/json'; if (this.configuration && this.configuration.apiKey) { headerParameters["Authorization"] = await this.configuration.apiKey("Authorization"); // auth0JWT authentication } let urlPath = `/applications`; return { path: urlPath, method: 'POST', headers: headerParameters, query: queryParameters, body: CreateApplicationDTOToJSON(requestParameters['createApplicationDTO']), }; } /** * Create a new application for the authenticated account. It accepts a smtpConfiguration object to create the SMTP configuration in the same request. * Create a new application */ async createApplicationRaw(requestParameters: CreateApplicationRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise> { const requestOptions = await this.createApplicationRequestOpts(requestParameters); const response = await this.request(requestOptions, initOverrides); return new runtime.JSONApiResponse(response, (jsonValue) => ApplicationDTOFromJSON(jsonValue)); } /** * Create a new application for the authenticated account. It accepts a smtpConfiguration object to create the SMTP configuration in the same request. * Create a new application */ async createApplication(requestParameters: CreateApplicationRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise { const response = await this.createApplicationRaw(requestParameters, initOverrides); return await response.value(); } /** * Creates request options for deleteApplication without sending the request */ async deleteApplicationRequestOpts(requestParameters: DeleteApplicationRequest): Promise { if (requestParameters['applicationId'] == null) { throw new runtime.RequiredError( 'applicationId', 'Required parameter "applicationId" was null or undefined when calling deleteApplication().' ); } const queryParameters: any = {}; const headerParameters: runtime.HTTPHeaders = {}; if (this.configuration && this.configuration.apiKey) { headerParameters["Authorization"] = await this.configuration.apiKey("Authorization"); // auth0JWT authentication } let urlPath = `/applications/{applicationId}`; urlPath = urlPath.replace('{applicationId}', encodeURIComponent(String(requestParameters['applicationId']))); return { path: urlPath, method: 'DELETE', headers: headerParameters, query: queryParameters, }; } /** * Delete an application belonging to the authenticated account * Delete an application */ async deleteApplicationRaw(requestParameters: DeleteApplicationRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise> { const requestOptions = await this.deleteApplicationRequestOpts(requestParameters); const response = await this.request(requestOptions, initOverrides); return new runtime.VoidApiResponse(response); } /** * Delete an application belonging to the authenticated account * Delete an application */ async deleteApplication(requestParameters: DeleteApplicationRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise { await this.deleteApplicationRaw(requestParameters, initOverrides); } /** * Creates request options for deleteTemplate without sending the request */ async deleteTemplateRequestOpts(requestParameters: DeleteTemplateRequest): Promise { if (requestParameters['id'] == null) { throw new runtime.RequiredError( 'id', 'Required parameter "id" was null or undefined when calling deleteTemplate().' ); } if (requestParameters['applicationId'] == null) { throw new runtime.RequiredError( 'applicationId', 'Required parameter "applicationId" was null or undefined when calling deleteTemplate().' ); } const queryParameters: any = {}; const headerParameters: runtime.HTTPHeaders = {}; if (this.configuration && this.configuration.apiKey) { headerParameters["Authorization"] = await this.configuration.apiKey("Authorization"); // auth0JWT authentication } let urlPath = `/applications/{applicationId}/templates/{id}`; urlPath = urlPath.replace('{id}', encodeURIComponent(String(requestParameters['id']))); urlPath = urlPath.replace('{applicationId}', encodeURIComponent(String(requestParameters['applicationId']))); return { path: urlPath, method: 'DELETE', headers: headerParameters, query: queryParameters, }; } /** * Delete an template * Delete an template */ async deleteTemplateRaw(requestParameters: DeleteTemplateRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise> { const requestOptions = await this.deleteTemplateRequestOpts(requestParameters); const response = await this.request(requestOptions, initOverrides); return new runtime.VoidApiResponse(response); } /** * Delete an template * Delete an template */ async deleteTemplate(requestParameters: DeleteTemplateRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise { await this.deleteTemplateRaw(requestParameters, initOverrides); } /** * Creates request options for getApplicationByID without sending the request */ async getApplicationByIDRequestOpts(requestParameters: GetApplicationByIDRequest): Promise { if (requestParameters['applicationId'] == null) { throw new runtime.RequiredError( 'applicationId', 'Required parameter "applicationId" was null or undefined when calling getApplicationByID().' ); } const queryParameters: any = {}; const headerParameters: runtime.HTTPHeaders = {}; if (this.configuration && this.configuration.apiKey) { headerParameters["Authorization"] = await this.configuration.apiKey("Authorization"); // auth0JWT authentication } let urlPath = `/applications/{applicationId}`; urlPath = urlPath.replace('{applicationId}', encodeURIComponent(String(requestParameters['applicationId']))); return { path: urlPath, method: 'GET', headers: headerParameters, query: queryParameters, }; } /** * Get a specific application belonging to the authenticated account, including its SMTP configuration when one exists * Get an application by applicationId */ async getApplicationByIDRaw(requestParameters: GetApplicationByIDRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise> { const requestOptions = await this.getApplicationByIDRequestOpts(requestParameters); const response = await this.request(requestOptions, initOverrides); return new runtime.JSONApiResponse(response, (jsonValue) => ApplicationDTOFromJSON(jsonValue)); } /** * Get a specific application belonging to the authenticated account, including its SMTP configuration when one exists * Get an application by applicationId */ async getApplicationByID(requestParameters: GetApplicationByIDRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise { const response = await this.getApplicationByIDRaw(requestParameters, initOverrides); return await response.value(); } /** * Creates request options for getApplications without sending the request */ async getApplicationsRequestOpts(requestParameters: GetApplicationsRequest): Promise { const queryParameters: any = {}; if (requestParameters['page'] != null) { queryParameters['page'] = requestParameters['page']; } if (requestParameters['pageSize'] != null) { queryParameters['pageSize'] = requestParameters['pageSize']; } if (requestParameters['search'] != null) { queryParameters['search'] = requestParameters['search']; } if (requestParameters['sortBy'] != null) { queryParameters['sortBy'] = requestParameters['sortBy']; } if (requestParameters['sortDirection'] != null) { queryParameters['sortDirection'] = requestParameters['sortDirection']; } const headerParameters: runtime.HTTPHeaders = {}; if (this.configuration && this.configuration.apiKey) { headerParameters["Authorization"] = await this.configuration.apiKey("Authorization"); // auth0JWT authentication } let urlPath = `/applications`; return { path: urlPath, method: 'GET', headers: headerParameters, query: queryParameters, }; } /** * Get all applications belonging to the authenticated account * Get all applications for the account */ async getApplicationsRaw(requestParameters: GetApplicationsRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise> { const requestOptions = await this.getApplicationsRequestOpts(requestParameters); const response = await this.request(requestOptions, initOverrides); return new runtime.JSONApiResponse(response, (jsonValue) => PaginatedApplicationsDTOFromJSON(jsonValue)); } /** * Get all applications belonging to the authenticated account * Get all applications for the account */ async getApplications(requestParameters: GetApplicationsRequest = {}, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise { const response = await this.getApplicationsRaw(requestParameters, initOverrides); return await response.value(); } /** * Creates request options for getTemplate without sending the request */ async getTemplateRequestOpts(requestParameters: GetTemplateRequest): Promise { if (requestParameters['id'] == null) { throw new runtime.RequiredError( 'id', 'Required parameter "id" was null or undefined when calling getTemplate().' ); } if (requestParameters['applicationId'] == null) { throw new runtime.RequiredError( 'applicationId', 'Required parameter "applicationId" was null or undefined when calling getTemplate().' ); } const queryParameters: any = {}; const headerParameters: runtime.HTTPHeaders = {}; if (this.configuration && this.configuration.apiKey) { headerParameters["Authorization"] = await this.configuration.apiKey("Authorization"); // auth0JWT authentication } let urlPath = `/applications/{applicationId}/templates/{id}`; urlPath = urlPath.replace('{id}', encodeURIComponent(String(requestParameters['id']))); urlPath = urlPath.replace('{applicationId}', encodeURIComponent(String(requestParameters['applicationId']))); return { path: urlPath, method: 'GET', headers: headerParameters, query: queryParameters, }; } /** * Return a template with all its properties, including the content * Return a template */ async getTemplateRaw(requestParameters: GetTemplateRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise> { const requestOptions = await this.getTemplateRequestOpts(requestParameters); const response = await this.request(requestOptions, initOverrides); return new runtime.JSONApiResponse(response, (jsonValue) => EmailTemplateContentDTOFromJSON(jsonValue)); } /** * Return a template with all its properties, including the content * Return a template */ async getTemplate(requestParameters: GetTemplateRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise { const response = await this.getTemplateRaw(requestParameters, initOverrides); return await response.value(); } /** * Creates request options for getTemplates without sending the request */ async getTemplatesRequestOpts(requestParameters: GetTemplatesRequest): Promise { if (requestParameters['applicationId'] == null) { throw new runtime.RequiredError( 'applicationId', 'Required parameter "applicationId" was null or undefined when calling getTemplates().' ); } const queryParameters: any = {}; if (requestParameters['page'] != null) { queryParameters['page'] = requestParameters['page']; } if (requestParameters['pageSize'] != null) { queryParameters['pageSize'] = requestParameters['pageSize']; } if (requestParameters['search'] != null) { queryParameters['search'] = requestParameters['search']; } if (requestParameters['sortBy'] != null) { queryParameters['sortBy'] = requestParameters['sortBy']; } if (requestParameters['sortDirection'] != null) { queryParameters['sortDirection'] = requestParameters['sortDirection']; } const headerParameters: runtime.HTTPHeaders = {}; if (this.configuration && this.configuration.apiKey) { headerParameters["Authorization"] = await this.configuration.apiKey("Authorization"); // auth0JWT authentication } let urlPath = `/applications/{applicationId}/templates`; urlPath = urlPath.replace('{applicationId}', encodeURIComponent(String(requestParameters['applicationId']))); return { path: urlPath, method: 'GET', headers: headerParameters, query: queryParameters, }; } /** * Return all templates * Return all templates */ async getTemplatesRaw(requestParameters: GetTemplatesRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise> { const requestOptions = await this.getTemplatesRequestOpts(requestParameters); const response = await this.request(requestOptions, initOverrides); return new runtime.JSONApiResponse(response, (jsonValue) => PaginatedEmailTemplateDTOFromJSON(jsonValue)); } /** * Return all templates * Return all templates */ async getTemplates(requestParameters: GetTemplatesRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise { const response = await this.getTemplatesRaw(requestParameters, initOverrides); return await response.value(); } /** * Creates request options for sendEmail without sending the request */ async sendEmailRequestOpts(requestParameters: SendEmailRequest): Promise { if (requestParameters['applicationId'] == null) { throw new runtime.RequiredError( 'applicationId', 'Required parameter "applicationId" was null or undefined when calling sendEmail().' ); } if (requestParameters['templateUUID'] == null) { throw new runtime.RequiredError( 'templateUUID', 'Required parameter "templateUUID" was null or undefined when calling sendEmail().' ); } if (requestParameters['to'] == null) { throw new runtime.RequiredError( 'to', 'Required parameter "to" was null or undefined when calling sendEmail().' ); } const queryParameters: any = {}; const headerParameters: runtime.HTTPHeaders = {}; if (this.configuration && this.configuration.apiKey) { headerParameters["Authorization"] = await this.configuration.apiKey("Authorization"); // auth0JWT authentication } const consumes: runtime.Consume[] = [ { contentType: 'multipart/form-data' }, ]; // @ts-ignore: canConsumeForm may be unused const canConsumeForm = runtime.canConsumeForm(consumes); let formParams: { append(param: string, value: any): any }; let useForm = false; // use FormData to transmit files using content-type "multipart/form-data" useForm = canConsumeForm; if (useForm) { formParams = new FormData(); } else { formParams = new URLSearchParams(); } if (requestParameters['body'] != null) { formParams.append('body', requestParameters['body'] as any); } if (requestParameters['data'] != null) { formParams.append('data', requestParameters['data'] as any); } if (requestParameters['file'] != null) { formParams.append('file', requestParameters['file'] as any); } if (requestParameters['templateUUID'] != null) { formParams.append('templateUUID', requestParameters['templateUUID'] as any); } if (requestParameters['to'] != null) { formParams.append('to', requestParameters['to'] as any); } let urlPath = `/applications/{applicationId}/emails/send`; urlPath = urlPath.replace('{applicationId}', encodeURIComponent(String(requestParameters['applicationId']))); return { path: urlPath, method: 'POST', headers: headerParameters, query: queryParameters, body: formParams, }; } /** * Send an email * Send an email */ async sendEmailRaw(requestParameters: SendEmailRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise> { const requestOptions = await this.sendEmailRequestOpts(requestParameters); const response = await this.request(requestOptions, initOverrides); return new runtime.VoidApiResponse(response); } /** * Send an email * Send an email */ async sendEmail(requestParameters: SendEmailRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise { await this.sendEmailRaw(requestParameters, initOverrides); } /** * Creates request options for updateApplication without sending the request */ async updateApplicationRequestOpts(requestParameters: UpdateApplicationRequest): Promise { if (requestParameters['applicationId'] == null) { throw new runtime.RequiredError( 'applicationId', 'Required parameter "applicationId" was null or undefined when calling updateApplication().' ); } if (requestParameters['updateApplicationDTO'] == null) { throw new runtime.RequiredError( 'updateApplicationDTO', 'Required parameter "updateApplicationDTO" was null or undefined when calling updateApplication().' ); } const queryParameters: any = {}; const headerParameters: runtime.HTTPHeaders = {}; headerParameters['Content-Type'] = 'application/json'; if (this.configuration && this.configuration.apiKey) { headerParameters["Authorization"] = await this.configuration.apiKey("Authorization"); // auth0JWT authentication } let urlPath = `/applications/{applicationId}`; urlPath = urlPath.replace('{applicationId}', encodeURIComponent(String(requestParameters['applicationId']))); return { path: urlPath, method: 'PATCH', headers: headerParameters, query: queryParameters, body: UpdateApplicationDTOToJSON(requestParameters['updateApplicationDTO']), }; } /** * Update an application belonging to the authenticated account. Optionally accepts a smtpConfiguration object to create or update the SMTP configuration in the same request; when omitted or null the SMTP configuration is left untouched. * Update an application */ async updateApplicationRaw(requestParameters: UpdateApplicationRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise> { const requestOptions = await this.updateApplicationRequestOpts(requestParameters); const response = await this.request(requestOptions, initOverrides); return new runtime.JSONApiResponse(response, (jsonValue) => ApplicationDTOFromJSON(jsonValue)); } /** * Update an application belonging to the authenticated account. Optionally accepts a smtpConfiguration object to create or update the SMTP configuration in the same request; when omitted or null the SMTP configuration is left untouched. * Update an application */ async updateApplication(requestParameters: UpdateApplicationRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise { const response = await this.updateApplicationRaw(requestParameters, initOverrides); return await response.value(); } /** * Creates request options for updateTemplate without sending the request */ async updateTemplateRequestOpts(requestParameters: UpdateTemplateRequest): Promise { if (requestParameters['applicationId'] == null) { throw new runtime.RequiredError( 'applicationId', 'Required parameter "applicationId" was null or undefined when calling updateTemplate().' ); } if (requestParameters['id'] == null) { throw new runtime.RequiredError( 'id', 'Required parameter "id" was null or undefined when calling updateTemplate().' ); } const queryParameters: any = {}; const headerParameters: runtime.HTTPHeaders = {}; if (this.configuration && this.configuration.apiKey) { headerParameters["Authorization"] = await this.configuration.apiKey("Authorization"); // auth0JWT authentication } const consumes: runtime.Consume[] = [ { contentType: 'multipart/form-data' }, ]; // @ts-ignore: canConsumeForm may be unused const canConsumeForm = runtime.canConsumeForm(consumes); let formParams: { append(param: string, value: any): any }; let useForm = false; // use FormData to transmit files using content-type "multipart/form-data" useForm = canConsumeForm; if (useForm) { formParams = new FormData(); } else { formParams = new URLSearchParams(); } if (requestParameters['file'] != null) { formParams.append('file', requestParameters['file'] as any); } if (requestParameters['fromEmail'] != null) { formParams.append('fromEmail', requestParameters['fromEmail'] as any); } if (requestParameters['name'] != null) { formParams.append('name', requestParameters['name'] as any); } if (requestParameters['subject'] != null) { formParams.append('subject', requestParameters['subject'] as any); } if (requestParameters['toEmail'] != null) { formParams.append('toEmail', requestParameters['toEmail'] as any); } let urlPath = `/applications/{applicationId}/templates/{id}`; urlPath = urlPath.replace('{applicationId}', encodeURIComponent(String(requestParameters['applicationId']))); urlPath = urlPath.replace('{id}', encodeURIComponent(String(requestParameters['id']))); return { path: urlPath, method: 'PATCH', headers: headerParameters, query: queryParameters, body: formParams, }; } /** * Update a template * Update a template */ async updateTemplateRaw(requestParameters: UpdateTemplateRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise> { const requestOptions = await this.updateTemplateRequestOpts(requestParameters); const response = await this.request(requestOptions, initOverrides); return new runtime.JSONApiResponse(response, (jsonValue) => UpdateEmailTemplateDTOFromJSON(jsonValue)); } /** * Update a template * Update a template */ async updateTemplate(requestParameters: UpdateTemplateRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise { const response = await this.updateTemplateRaw(requestParameters, initOverrides); return await response.value(); } /** * Creates request options for uploadTemplate without sending the request */ async uploadTemplateRequestOpts(requestParameters: UploadTemplateRequest): Promise { if (requestParameters['applicationId'] == null) { throw new runtime.RequiredError( 'applicationId', 'Required parameter "applicationId" was null or undefined when calling uploadTemplate().' ); } if (requestParameters['file'] == null) { throw new runtime.RequiredError( 'file', 'Required parameter "file" was null or undefined when calling uploadTemplate().' ); } if (requestParameters['fromEmail'] == null) { throw new runtime.RequiredError( 'fromEmail', 'Required parameter "fromEmail" was null or undefined when calling uploadTemplate().' ); } if (requestParameters['name'] == null) { throw new runtime.RequiredError( 'name', 'Required parameter "name" was null or undefined when calling uploadTemplate().' ); } if (requestParameters['subject'] == null) { throw new runtime.RequiredError( 'subject', 'Required parameter "subject" was null or undefined when calling uploadTemplate().' ); } const queryParameters: any = {}; const headerParameters: runtime.HTTPHeaders = {}; if (this.configuration && this.configuration.apiKey) { headerParameters["Authorization"] = await this.configuration.apiKey("Authorization"); // auth0JWT authentication } const consumes: runtime.Consume[] = [ { contentType: 'multipart/form-data' }, ]; // @ts-ignore: canConsumeForm may be unused const canConsumeForm = runtime.canConsumeForm(consumes); let formParams: { append(param: string, value: any): any }; let useForm = false; // use FormData to transmit files using content-type "multipart/form-data" useForm = canConsumeForm; if (useForm) { formParams = new FormData(); } else { formParams = new URLSearchParams(); } if (requestParameters['file'] != null) { formParams.append('file', requestParameters['file'] as any); } if (requestParameters['fromEmail'] != null) { formParams.append('fromEmail', requestParameters['fromEmail'] as any); } if (requestParameters['name'] != null) { formParams.append('name', requestParameters['name'] as any); } if (requestParameters['subject'] != null) { formParams.append('subject', requestParameters['subject'] as any); } if (requestParameters['toEmail'] != null) { formParams.append('toEmail', requestParameters['toEmail'] as any); } let urlPath = `/applications/{applicationId}/templates`; urlPath = urlPath.replace('{applicationId}', encodeURIComponent(String(requestParameters['applicationId']))); return { path: urlPath, method: 'POST', headers: headerParameters, query: queryParameters, body: formParams, }; } /** * Upload a template * Upload a template */ async uploadTemplateRaw(requestParameters: UploadTemplateRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise> { const requestOptions = await this.uploadTemplateRequestOpts(requestParameters); const response = await this.request(requestOptions, initOverrides); return new runtime.JSONApiResponse(response, (jsonValue) => EmailTemplateDTOFromJSON(jsonValue)); } /** * Upload a template * Upload a template */ async uploadTemplate(requestParameters: UploadTemplateRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise { const response = await this.uploadTemplateRaw(requestParameters, initOverrides); return await response.value(); } } /** * @export */ export const GetApplicationsSortByEnum = { Name: 'name', CreatedAt: 'createdAt', UpdatedAt: 'updatedAt' } as const; export type GetApplicationsSortByEnum = typeof GetApplicationsSortByEnum[keyof typeof GetApplicationsSortByEnum]; /** * @export */ export const GetApplicationsSortDirectionEnum = { Asc: 'asc', Desc: 'desc' } as const; export type GetApplicationsSortDirectionEnum = typeof GetApplicationsSortDirectionEnum[keyof typeof GetApplicationsSortDirectionEnum]; /** * @export */ export const GetTemplatesSortByEnum = { Name: 'name', UpdatedAt: 'updatedAt', CreatedAt: 'createdAt' } as const; export type GetTemplatesSortByEnum = typeof GetTemplatesSortByEnum[keyof typeof GetTemplatesSortByEnum]; /** * @export */ export const GetTemplatesSortDirectionEnum = { Asc: 'asc', Desc: 'desc' } as const; export type GetTemplatesSortDirectionEnum = typeof GetTemplatesSortDirectionEnum[keyof typeof GetTemplatesSortDirectionEnum];