[mailgun-js] add testMode and testModeLogger to Mailgun constr… (#36542)

* add testMode and testModeLogger to Mailgun constructor for version 0.22.0

* increase typescript version to match form-data as new dependency

* remove patch version in definitions

* revert of the formatting changes

* cleanup formatting
This commit is contained in:
Jiří Balcar
2019-07-01 12:45:59 -07:00
committed by Ryan Cavanaugh
parent faf2054aa9
commit 75b0473d21
2 changed files with 33 additions and 3 deletions
+20 -3
View File
@@ -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 <https://github.com/sampsonjoliver>
// Andi Pätzold <https://github.com/andipaetzold>
// Jiri Balcar <https://github.com/JiriBalcar>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TypeScript Version: 2.2
// TypeScript Version: 2.3
/// <reference types="node" />
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 {
+13
View File
@@ -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"