/** * Sparks OpenAPI * Generated documentation for the Logicdrop Sparks API and OpenAPI clients. Logicdrop Sparks lets users build rules, analyze data, and automate documents. Use it to make decisions faster, generate documents better, and learn from your data. ### Documentation - [User Documentation](https://docs.logicdrop.com) ### Modules - [Sparks Compute](https://docs.logicdrop.com/rules/introduction) - [Sparks Decision Tables](https://docs.logicdrop.com/rules/authoring-decision-tables) - [Sparks Documents](https://docs.logicdrop.com/documents/introduction) ### Clients - [OpenAPI Clients](https://docs.logicdrop.com/development/sample-clients) ### Security - [Authorizing API Requests](https://docs.logicdrop.com/development/authorization) * * The version of the OpenAPI document: v_VERSION_, build# _BUILD_ * Contact: support@logicdrop.com * * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). * https://openapi-generator.tech * Do not edit the class manually. */ import localVarRequest = require('request'); import http = require('http'); /* tslint:disable:no-unused-locals */ import { EmailMessage } from '../model/emailMessage'; import { EmailResult } from '../model/emailResult'; import { EmailWithAttachment } from '../model/emailWithAttachment'; import { ObjectSerializer, Authentication, VoidAuth } from '../model/models'; import { HttpBasicAuth, ApiKeyAuth, OAuth } from '../model/models'; import { HttpError, RequestFile } from './apis'; let defaultBasePath = 'https://api.staging.com'; // =============================================== // This file is autogenerated - Please do not edit // =============================================== export enum EmailServicesApiApiKeys { api, } export class EmailServicesApi { protected _basePath = defaultBasePath; protected defaultHeaders : any = {}; protected _useQuerystring : boolean = false; protected authentications = { 'default': new VoidAuth(), 'jwt': new HttpBasicAuth(), 'api': new ApiKeyAuth('header', 'X-Logicdrop-ApiKey'), 'oauth2': new OAuth(), } constructor(oAuth?: OAuth); constructor(oAuth: OAuth, basePath?: string) { if (oAuth) { this.oAuth = oAuth; } if (basePath) { this.basePath = basePath; } } set useQuerystring(value: boolean) { this._useQuerystring = value; } set basePath(basePath: string) { this._basePath = basePath; } get basePath() { return this._basePath; } public setDefaultAuthentication(auth: Authentication) { this.authentications.default = auth; } public setApiKey(key: EmailServicesApiApiKeys, value: string) { (this.authentications as any)[EmailServicesApiApiKeys[key]].apiKey = value; } set oAuth(oAuth: OAuth) { this.authentications.oauth2 = oAuth; } set tokenUrl(tokenUrl: string) { this.authentications.oauth2.tokenUrl = tokenUrl; } set clientId(clientId: string) { this.authentications.oauth2.clientId = clientId; } set clientSecret(clientSecret: string) { this.authentications.oauth2.clientSecret = clientSecret; } /** * Send an email * @summary Send email * @param client Client name * @param emailMessage Email payload */ public async sendEmail (client: string, emailMessage: EmailMessage, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.ClientResponse; body: EmailResult; }> { const localVarPath = this.basePath + '/email/{client}' .replace('{' + 'client' + '}', encodeURIComponent(String(client))); let localVarQueryParameters: any = {}; let localVarHeaderParams: any = (Object).assign({}, this.defaultHeaders); const produces = ['application/json']; // give precedence to 'application/json' if (produces.indexOf('application/json') >= 0) { localVarHeaderParams.Accept = 'application/json'; } else { localVarHeaderParams.Accept = produces.join(','); } let localVarFormParams: any = {}; // verify required parameter 'client' is not null or undefined if (client === null || client === undefined) { throw new Error('Required parameter client was null or undefined when calling sendEmail.'); } // verify required parameter 'emailMessage' is not null or undefined if (emailMessage === null || emailMessage === undefined) { throw new Error('Required parameter emailMessage was null or undefined when calling sendEmail.'); } (Object).assign(localVarHeaderParams, options.headers); let localVarUseFormData = false; let localVarRequestOptions: localVarRequest.Options = { method: 'POST', qs: localVarQueryParameters, headers: localVarHeaderParams, uri: localVarPath, useQuerystring: this._useQuerystring, json: true, body: ObjectSerializer.serialize(emailMessage, "EmailMessage") }; let authenticationPromise = Promise.resolve(); authenticationPromise = authenticationPromise.then(async () => await this.authentications.oauth2.applyToRequest(localVarRequestOptions)); authenticationPromise = authenticationPromise.then(() => this.authentications.default.applyToRequest(localVarRequestOptions)); return authenticationPromise.then(() => { if (Object.keys(localVarFormParams).length) { if (localVarUseFormData) { (localVarRequestOptions).formData = localVarFormParams; } else { localVarRequestOptions.form = localVarFormParams; } } return new Promise<{ response: http.ClientResponse; body: EmailResult; }>((resolve, reject) => { localVarRequest(localVarRequestOptions, (error, response, body) => { if (error) { reject(error); } else { body = ObjectSerializer.deserialize(body, "EmailResult"); if (response.statusCode && response.statusCode >= 200 && response.statusCode <= 299) { resolve({ response: response, body: body }); } else { reject(new HttpError(response, body, response.statusCode)); } } }); }); }); } /** * Send an email with an attachment * @summary Send email with attachments * @param client Client name * @param emailWithAttachment Email with attachment */ public async sendWithAttachment (client: string, emailWithAttachment: EmailWithAttachment, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.ClientResponse; body: EmailResult; }> { const localVarPath = this.basePath + '/email/{client}/send' .replace('{' + 'client' + '}', encodeURIComponent(String(client))); let localVarQueryParameters: any = {}; let localVarHeaderParams: any = (Object).assign({}, this.defaultHeaders); const produces = ['application/json']; // give precedence to 'application/json' if (produces.indexOf('application/json') >= 0) { localVarHeaderParams.Accept = 'application/json'; } else { localVarHeaderParams.Accept = produces.join(','); } let localVarFormParams: any = {}; // verify required parameter 'client' is not null or undefined if (client === null || client === undefined) { throw new Error('Required parameter client was null or undefined when calling sendWithAttachment.'); } // verify required parameter 'emailWithAttachment' is not null or undefined if (emailWithAttachment === null || emailWithAttachment === undefined) { throw new Error('Required parameter emailWithAttachment was null or undefined when calling sendWithAttachment.'); } (Object).assign(localVarHeaderParams, options.headers); let localVarUseFormData = false; let localVarRequestOptions: localVarRequest.Options = { method: 'POST', qs: localVarQueryParameters, headers: localVarHeaderParams, uri: localVarPath, useQuerystring: this._useQuerystring, json: true, body: ObjectSerializer.serialize(emailWithAttachment, "EmailWithAttachment") }; let authenticationPromise = Promise.resolve(); authenticationPromise = authenticationPromise.then(async () => await this.authentications.oauth2.applyToRequest(localVarRequestOptions)); authenticationPromise = authenticationPromise.then(() => this.authentications.default.applyToRequest(localVarRequestOptions)); return authenticationPromise.then(() => { if (Object.keys(localVarFormParams).length) { if (localVarUseFormData) { (localVarRequestOptions).formData = localVarFormParams; } else { localVarRequestOptions.form = localVarFormParams; } } return new Promise<{ response: http.ClientResponse; body: EmailResult; }>((resolve, reject) => { localVarRequest(localVarRequestOptions, (error, response, body) => { if (error) { reject(error); } else { body = ObjectSerializer.deserialize(body, "EmailResult"); if (response.statusCode && response.statusCode >= 200 && response.statusCode <= 299) { resolve({ response: response, body: body }); } else { reject(new HttpError(response, body, response.statusCode)); } } }); }); }); } }