diff --git a/types/mailgun-js/index.d.ts b/types/mailgun-js/index.d.ts index 7efac1326a..540f91bddf 100644 --- a/types/mailgun-js/index.d.ts +++ b/types/mailgun-js/index.d.ts @@ -1,12 +1,15 @@ -// Type definitions for mailgun-js 0.16 +// Type definitions for mailgun-js 0.22 // Project: https://github.com/bojand/mailgun-js // Definitions by: Sampson Oliver // Andi Pätzold +// Jiri Balcar // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -// TypeScript Version: 2.2 +// TypeScript Version: 2.3 /// +import * as FormData from 'form-data'; + declare const Mailgun: Mailgun.MailgunExport; export = Mailgun; @@ -28,6 +31,20 @@ declare namespace Mailgun { interval: number; }; proxy?: string; + testMode?: boolean; + testModeLogger?: (httpOptions: LoggerHttpOptions, payload: string, form: FormData) => void; + } + + interface LoggerHttpOptions { + hostname: string; + port: number; + protocol: string; + path: string; + method: string; + headers: any; + auth: string; + agent: false; + timeout: number; } interface Error { @@ -88,7 +105,7 @@ declare namespace Mailgun { } interface BatchData extends SendData { - "recipient-variables"?: BatchSendRecipientVars; + 'recipient-variables'?: BatchSendRecipientVars; } interface BatchSendRecipientVars { diff --git a/types/mailgun-js/mailgun-js-tests.ts b/types/mailgun-js/mailgun-js-tests.ts index 16693c1bb6..14b7368bff 100644 --- a/types/mailgun-js/mailgun-js-tests.ts +++ b/types/mailgun-js/mailgun-js-tests.ts @@ -1,6 +1,8 @@ import * as mailgunFactory from "mailgun-js"; import mailgunFactory2 = require('mailgun-js'); +import * as FormData from 'form-data'; + const mailgun = new mailgunFactory({ apiKey: "auth.api_key", domain: "auth.domain" @@ -11,6 +13,17 @@ const mailgun2 = new mailgunFactory2({ domain: "auth.domain" }); +const logger = (httpOptions: mailgunFactory.LoggerHttpOptions, payload: string, form: FormData) => {}; + +const mailgun3 = new mailgunFactory2({ + apiKey: 'auth.api_key', + domain: 'auth.domain', + + testMode: true, + + testModeLogger: logger, +}); + mailgun.messages().send( { to: "fixture.message.to"