diff --git a/packages/client/src/client.d.ts b/packages/client/src/client.d.ts index d8d7b532e..fb84f7cb1 100644 --- a/packages/client/src/client.d.ts +++ b/packages/client/src/client.d.ts @@ -46,5 +46,8 @@ declare class Client { request(data: ClientRequest, cb?: (err: ResponseError, response: [ClientResponse, any]) => void): Promise<[ClientResponse, any]>; } -declare const client: Client & { Client: typeof Client }; +declare const client: Client; +// @ts-ignore export = client + +export {Client}; diff --git a/packages/helpers/classes/request.d.ts b/packages/helpers/classes/request.d.ts index 7b13383b9..f2145cfb7 100644 --- a/packages/helpers/classes/request.d.ts +++ b/packages/helpers/classes/request.d.ts @@ -1,3 +1,5 @@ +import * as https from 'https'; + type HttpMethod = 'get'|'GET'|'post'|'POST'|'put'|'PUT'|'patch'|'PATCH'|'delete'|'DELETE'; export default interface RequestOptions { @@ -7,4 +9,5 @@ export default interface RequestOptions { qs?: TParams; body?: TData; headers?: object; + httpsAgent?: https.Agent; } diff --git a/packages/mail/src/mail.d.ts b/packages/mail/src/mail.d.ts index 496ea7fd7..8a61c2b76 100644 --- a/packages/mail/src/mail.d.ts +++ b/packages/mail/src/mail.d.ts @@ -1,3 +1,4 @@ +import {Client} from "@sendgrid/client"; import {ClientResponse} from "@sendgrid/client/src/response"; import {ResponseError} from "@sendgrid/helpers/classes"; import {MailDataRequired} from "@sendgrid/helpers/classes/mail"; @@ -8,6 +9,11 @@ declare class MailService { */ setApiKey(apiKey: string): void; + /** + * Client to use for invoking underlying API + */ + setClient(client: Client): void; + /** * Twilio Email Auth passthrough for convenience. */ diff --git a/test/typescript/client.ts b/test/typescript/client.ts index f0ccf8689..c0fb0d781 100644 --- a/test/typescript/client.ts +++ b/test/typescript/client.ts @@ -1,4 +1,5 @@ import Client = require("@sendgrid/client"); +import * as https from 'https'; // Test setApiKey() method Client.setApiKey("MY_SENDGRID_API_KEY"); @@ -11,7 +12,8 @@ Client.setDefaultHeader({ // Test setDefaultRequest() method Client.setDefaultRequest({ url: "/test", -}).setDefaultRequest("method", "POST"); +}).setDefaultRequest("method", "POST") + .setDefaultRequest('httpsAgent', new https.Agent()) // Test createHeaders() method Client.createHeaders({ diff --git a/test/typescript/mail.ts b/test/typescript/mail.ts index 126663585..681b29e9a 100644 --- a/test/typescript/mail.ts +++ b/test/typescript/mail.ts @@ -1,8 +1,12 @@ +import { Client } from "@sendgrid/client"; import sgMail = require("@sendgrid/mail"); // Test setApiKey() method sgMail.setApiKey("MY_SENDGRID_API_KEY"); +// Test setClient() method +sgMail.setClient(new Client()); + // Test setSubstitutionWrappers() method sgMail.setSubstitutionWrappers("{{", "}}")