From 8295ee65d76ed45dea0c6d75d68c84f70104e340 Mon Sep 17 00:00:00 2001 From: Akinmade Bond Date: Sun, 19 Mar 2017 04:28:28 +0100 Subject: [PATCH] update Constructor --- sparkpost/index.d.ts | 5 +++++ sparkpost/sparkpost-tests.ts | 12 ++++++++++++ 2 files changed, 17 insertions(+) diff --git a/sparkpost/index.d.ts b/sparkpost/index.d.ts index 63c0d83bb2..4bd777f933 100644 --- a/sparkpost/index.d.ts +++ b/sparkpost/index.d.ts @@ -834,10 +834,15 @@ declare class SparkPost { constructor(apiKey?: string, options?: SparkPost.ConstructorOptions); request(options: Request.Options, callback: SparkPost.Callback): void; + request(options: Request.Options): Promise>; get(options: Request.Options, callback: SparkPost.Callback): void; + get(options: Request.Options): Promise>; post(options: Request.Options, callback: SparkPost.Callback): void; + post(options: Request.Options): Promise>; put(options: Request.Options, callback: SparkPost.Callback): void; + put(options: Request.Options): Promise>; delete(options: Request.Options, callback: SparkPost.Callback): void; + delete(options: Request.Options): Promise>; } declare namespace SparkPost { diff --git a/sparkpost/sparkpost-tests.ts b/sparkpost/sparkpost-tests.ts index de025997b5..0f43e41832 100644 --- a/sparkpost/sparkpost-tests.ts +++ b/sparkpost/sparkpost-tests.ts @@ -3,6 +3,7 @@ import * as SparkPost from "sparkpost"; let key = "YOURAPIKEY"; let client = new SparkPost(key); +// Callback client.get({ uri: "metrics/domains" }, function(err, data) { @@ -14,6 +15,17 @@ client.get({ console.log(data.body); }); +// Promise +client.get({ + uri: 'metrics/domains' +}) + .then(data => { + console.log(data); + }) + .catch(err => { + console.log(err); + }); + // Callback client.inboundDomains.create({ domain: 'example1.com' }, function(err, res) { if (err) {