mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2026-10-06 15:57:13 +00:00
update transmissions
This commit is contained in:
Vendored
+73
-9
@@ -550,31 +550,81 @@ declare class SparkPost {
|
||||
transmissions: {
|
||||
/**
|
||||
* List an overview of all transmissions in the account
|
||||
*
|
||||
* @param callback The request callback with Transmission results array
|
||||
*/
|
||||
all(callback: SparkPost.ResultsCallback<SparkPost.TransmissionSummary[]>): void;
|
||||
list(callback: SparkPost.ResultsCallback<SparkPost.TransmissionSummary[]>): void;
|
||||
/**
|
||||
* List an overview of all transmissions in the account, with added filters
|
||||
* @param options The search options { campaign_id?, template_id? }
|
||||
* @param callback The request callback with Transmission results array
|
||||
* List an overview of all transmissions in the account
|
||||
*
|
||||
* @param {{ campaign_id?: string, template_id: string }} options
|
||||
* @param {SparkPost.ResultsCallback<SparkPost.TransmissionSummary[]>} callback The request callback with Transmission results array
|
||||
*/
|
||||
all(options: { campaign_id?: string, template_id?: string }, callback: SparkPost.ResultsCallback<SparkPost.TransmissionSummary[]>): void;
|
||||
list(options: { campaign_id?: string, template_id?: string }, callback: SparkPost.ResultsCallback<SparkPost.TransmissionSummary[]>): void;
|
||||
/**
|
||||
* List an overview of all transmissions in the account
|
||||
*
|
||||
* @param {{ campaign_id?: string, template_id: string }} [options]
|
||||
* @returns {SparkPost.ResultsPromise<SparkPost.TransmissionSummary[]>} The Transmission results array
|
||||
*/
|
||||
list(options?: { campaign_id?: string, template_id?: string }): SparkPost.ResultsPromise<SparkPost.TransmissionSummary[]>;
|
||||
/**
|
||||
* Retrieve the details about a transmission by its ID
|
||||
* @param transmissionID The transmission id
|
||||
*
|
||||
* @param id The id of the transmission you want to look up
|
||||
* @param callback The request callback with Transmission results
|
||||
*/
|
||||
find(transmissionID: string, callback: SparkPost.ResultsCallback<SparkPost.Transmission>): void;
|
||||
get(transmissionID: string, callback: SparkPost.ResultsCallback<SparkPost.Transmission>): void;
|
||||
/**
|
||||
* Retrieve the details about a transmission by its ID
|
||||
*
|
||||
* @param {string} id The id of the transmission you want to look up
|
||||
* @returns {SparkPost.ResultsPromise<SparkPost.Transmission>} The Transmission results
|
||||
*/
|
||||
get(id: string): SparkPost.ResultsPromise<SparkPost.Transmission>;
|
||||
/**
|
||||
* Sends a message by creating a new transmission
|
||||
* @param options The create options
|
||||
*
|
||||
* @param transmission an object of [transmission attributes]{@link https://developers.sparkpost.com/api/transmissions#header-transmission-attributes}
|
||||
* @param options The create options. Specify maximum number of recipient errors returned
|
||||
* @param callback The request callback with metadata and id results
|
||||
*/
|
||||
send(options: { transmissionBody: SparkPost.CreateTransmission, num_rcpt_errors?: number }, callback: SparkPost.ResultsCallback<{
|
||||
send(transmission: SparkPost.CreateTransmission, options: { num_rcpt_errors?: number }, callback: SparkPost.ResultsCallback<{
|
||||
total_rejected_recipients: number;
|
||||
total_accepted_recipients: number;
|
||||
id: string;
|
||||
}>): void;
|
||||
/**
|
||||
*
|
||||
*
|
||||
* @param {SparkPost.CreateTransmission} transmission an object of [transmission attributes]{@link https://developers.sparkpost.com/api/transmissions#header-transmission-attributes}
|
||||
* @param {SparkPost.ResultsCallback<{
|
||||
* total_rejected_recipients: number;
|
||||
* total_accepted_recipients: number;
|
||||
* id: string;
|
||||
* }>} callback The request callback with metadata and id results
|
||||
*/
|
||||
send(transmission: SparkPost.CreateTransmission, callback: SparkPost.ResultsCallback<{
|
||||
total_rejected_recipients: number;
|
||||
total_accepted_recipients: number;
|
||||
id: string;
|
||||
}>): void;
|
||||
/**
|
||||
* Sends a message by creating a new transmission
|
||||
*
|
||||
* @param {SparkPost.CreateTransmission} transmission an object of [transmission attributes]{@link https://developers.sparkpost.com/api/transmissions#header-transmission-attributes}
|
||||
* @param {{ num_rcpt_errors?: number }} [options] specify maximum number of recipient errors returned
|
||||
* @returns {SparkPost.ResultsPromise<{
|
||||
* total_rejected_recipients: number;
|
||||
* total_accepted_recipients: number;
|
||||
* id: string;
|
||||
* }>} The metadata and id results
|
||||
*/
|
||||
send(transmission: SparkPost.CreateTransmission, options?: { num_rcpt_errors?: number }): SparkPost.ResultsPromise<{
|
||||
total_rejected_recipients: number;
|
||||
total_accepted_recipients: number;
|
||||
id: string;
|
||||
}>;
|
||||
};
|
||||
webhooks: {
|
||||
/**
|
||||
@@ -1345,6 +1395,20 @@ declare namespace SparkPost {
|
||||
export interface CreateTransmission {
|
||||
/** JSON object in which transmission options are defined */
|
||||
options?: TransmissionOptions;
|
||||
/**
|
||||
* Recipients to receive a carbon copy of the transmission
|
||||
*
|
||||
* @type {Recipient[]}
|
||||
* @memberOf CreateTransmission
|
||||
*/
|
||||
cc?: Recipient[];
|
||||
/**
|
||||
* Recipients to discreetly receive a carbon copy of the transmission
|
||||
*
|
||||
* @type {Recipient[]}
|
||||
* @memberOf CreateTransmission
|
||||
*/
|
||||
bcc?: Recipient[];
|
||||
/** Inline recipient objects or object containing stored recipient list ID */
|
||||
recipients?: Recipient[] | { list_id: string };
|
||||
/** Name of the campaign */
|
||||
|
||||
+148
-29
@@ -1139,8 +1139,8 @@ client.templates.update('TEST_ID', {
|
||||
console.log(err);
|
||||
});
|
||||
|
||||
|
||||
client.transmissions.all(function(err, res) {
|
||||
// Callback
|
||||
client.transmissions.list(function(err, res) {
|
||||
if (err) {
|
||||
console.log(err);
|
||||
} else {
|
||||
@@ -1149,16 +1149,17 @@ client.transmissions.all(function(err, res) {
|
||||
}
|
||||
});
|
||||
|
||||
client.transmissions.find("YOUR-TRANSMISSION-KEY", function(err, res) {
|
||||
if (err) {
|
||||
// Promise
|
||||
client.transmissions.list()
|
||||
.then(data => {
|
||||
console.log(data);
|
||||
console.log('Congrats you can use our client library!');
|
||||
})
|
||||
.catch(err => {
|
||||
console.log(err);
|
||||
} else {
|
||||
console.log(res.body);
|
||||
console.log("Congrats you can use our SDK!");
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
client.transmissions.all({
|
||||
client.transmissions.list({
|
||||
campaign_id: "my_campaign"
|
||||
}, function(err, res) {
|
||||
if (err) {
|
||||
@@ -1169,7 +1170,7 @@ client.transmissions.all({
|
||||
}
|
||||
});
|
||||
|
||||
client.transmissions.all({
|
||||
client.transmissions.list({
|
||||
template_id: "my_template"
|
||||
}, function(err, res) {
|
||||
if (err) {
|
||||
@@ -1180,8 +1181,29 @@ client.transmissions.all({
|
||||
}
|
||||
});
|
||||
|
||||
// Callback
|
||||
client.transmissions.get("YOUR-TRANSMISSION-KEY", function(err, res) {
|
||||
if (err) {
|
||||
console.log(err);
|
||||
} else {
|
||||
console.log(res.body);
|
||||
console.log("Congrats you can use our SDK!");
|
||||
}
|
||||
});
|
||||
|
||||
// Promise
|
||||
client.transmissions.get('YOUR-TRANSMISSION-KEY')
|
||||
.then(data => {
|
||||
console.log('Congrats you can use our client library!');
|
||||
console.log(data);
|
||||
})
|
||||
.catch(err => {
|
||||
console.log('Whoops! Something went wrong');
|
||||
console.log(err);
|
||||
});
|
||||
|
||||
// Callback
|
||||
client.transmissions.send({
|
||||
transmissionBody: {
|
||||
recipients: [{ address: { email: "john.doe@example.com" } }],
|
||||
content: {
|
||||
from: "From Envelope <from@example.com>",
|
||||
@@ -1193,7 +1215,6 @@ client.transmissions.send({
|
||||
open_tracking: true,
|
||||
click_tracking: true
|
||||
}
|
||||
}
|
||||
}, function(err, res) {
|
||||
if (err) {
|
||||
console.log(err);
|
||||
@@ -1203,13 +1224,12 @@ client.transmissions.send({
|
||||
}
|
||||
});
|
||||
|
||||
// Callback
|
||||
client.transmissions.send({
|
||||
transmissionBody: {
|
||||
recipients: [{address: {email: "john.doe@example.com"}}],
|
||||
content: {
|
||||
email_rfc822: "Content-Type: text/plain\nFrom: From Envelope <from@example.com>\nSubject: Example Email\n\nHello World"
|
||||
}
|
||||
}
|
||||
}, function(err, res) {
|
||||
if (err) {
|
||||
console.log(err);
|
||||
@@ -1219,8 +1239,8 @@ client.transmissions.send({
|
||||
}
|
||||
});
|
||||
|
||||
// Callback
|
||||
client.transmissions.send({
|
||||
transmissionBody: {
|
||||
options: {
|
||||
open_tracking: true,
|
||||
click_tracking: true
|
||||
@@ -1266,8 +1286,7 @@ client.transmissions.send({
|
||||
},
|
||||
text: "Hi {{address.name}} \nSave big this Christmas in your area {{place}}! \nClick http://www.mysite.com and get huge discount\n Hurry, this offer is only to {{customer_type}}\n {{sender}}",
|
||||
html: "<p>Hi {{address.name}} \nSave big this Christmas in your area {{place}}! \nClick http://www.mysite.com and get huge discount\n</p><p>Hurry, this offer is only to {{customer_type}}\n</p><p>{{sender}}</p>"
|
||||
}
|
||||
}
|
||||
}
|
||||
}, function(err, res) {
|
||||
if (err) {
|
||||
console.log(err);
|
||||
@@ -1277,8 +1296,8 @@ client.transmissions.send({
|
||||
}
|
||||
});
|
||||
|
||||
// Callback
|
||||
client.transmissions.send({
|
||||
transmissionBody: {
|
||||
recipients: [
|
||||
{
|
||||
address: {
|
||||
@@ -1308,7 +1327,6 @@ client.transmissions.send({
|
||||
text: "An example email using bcc with SparkPost to the {{recipient_type}} recipient.",
|
||||
html: "<p>An example email using bcc with SparkPost to the {{recipient_type}} recipient.</p>"
|
||||
}
|
||||
}
|
||||
}, function(err, res) {
|
||||
if (err) {
|
||||
console.log(err);
|
||||
@@ -1318,8 +1336,8 @@ client.transmissions.send({
|
||||
}
|
||||
});
|
||||
|
||||
// Callback
|
||||
client.transmissions.send({
|
||||
transmissionBody: {
|
||||
recipients: [
|
||||
{
|
||||
address: {
|
||||
@@ -1353,7 +1371,6 @@ client.transmissions.send({
|
||||
text: "An example email using cc with SparkPost to the {{recipient_type}} recipient.",
|
||||
html: "<p>An example email using cc with SparkPost to the {{recipient_type}} recipient.</p>"
|
||||
}
|
||||
}
|
||||
}, function(err, res) {
|
||||
if (err) {
|
||||
console.log(err);
|
||||
@@ -1363,8 +1380,8 @@ client.transmissions.send({
|
||||
}
|
||||
});
|
||||
|
||||
// Callback
|
||||
client.transmissions.send({
|
||||
transmissionBody: {
|
||||
recipients: {
|
||||
list_id: "example-list"
|
||||
},
|
||||
@@ -1374,7 +1391,6 @@ client.transmissions.send({
|
||||
html: "<html><body><p>Hello World</p></body></html>",
|
||||
text: "Hello World!"
|
||||
}
|
||||
}
|
||||
}, function(err, res) {
|
||||
if (err) {
|
||||
console.log(err);
|
||||
@@ -1384,8 +1400,8 @@ client.transmissions.send({
|
||||
}
|
||||
});
|
||||
|
||||
// Callback
|
||||
client.transmissions.send({
|
||||
transmissionBody: {
|
||||
recipients: {
|
||||
list_id: "example-list"
|
||||
},
|
||||
@@ -1394,7 +1410,6 @@ client.transmissions.send({
|
||||
subject: "Example Email for Stored List and Template",
|
||||
template_id: "my-template"
|
||||
}
|
||||
}
|
||||
}, function(err, res) {
|
||||
if (err) {
|
||||
console.log(err);
|
||||
@@ -1404,15 +1419,15 @@ client.transmissions.send({
|
||||
}
|
||||
});
|
||||
|
||||
// Callback
|
||||
client.transmissions.send({
|
||||
num_rcpt_errors: 3,
|
||||
transmissionBody: {
|
||||
campaign_id: "ricks-campaign",
|
||||
content: {
|
||||
template_id: "ricks-template"
|
||||
},
|
||||
recipients: [{ address: { email: "rick.sanchez@rickandmorty100years.com", name: "Rick Sanchez" } }]
|
||||
}
|
||||
}, {
|
||||
num_rcpt_errors: 3
|
||||
}, function(err, res) {
|
||||
if (err) {
|
||||
console.log(err);
|
||||
@@ -1422,6 +1437,110 @@ client.transmissions.send({
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
// Promise
|
||||
client.transmissions.send({
|
||||
options: {
|
||||
open_tracking: true,
|
||||
click_tracking: true
|
||||
},
|
||||
campaign_id: 'christmas_campaign',
|
||||
metadata: {
|
||||
user_type: 'students'
|
||||
},
|
||||
substitution_data: {
|
||||
sender: 'Big Store Team'
|
||||
},
|
||||
cc: [],
|
||||
bcc: [],
|
||||
recipients: [
|
||||
{
|
||||
address: {
|
||||
email: 'wilma@flintstone.com',
|
||||
name: 'Wilma Flintstone'
|
||||
},
|
||||
tags: [
|
||||
'greeting',
|
||||
'prehistoric',
|
||||
'fred',
|
||||
'flintstone'
|
||||
],
|
||||
metadata: {
|
||||
place: 'Bedrock'
|
||||
},
|
||||
substitution_data: {
|
||||
customer_type: 'Platinum'
|
||||
}
|
||||
}
|
||||
],
|
||||
content: {
|
||||
from: {
|
||||
name: 'Fred Flintstone',
|
||||
email: 'fred@flintstone.com'
|
||||
},
|
||||
subject: 'Big Christmas savings!',
|
||||
reply_to: 'Christmas Sales <sales@flintstone.com>',
|
||||
headers: {
|
||||
'X-Customer-Campaign-ID': 'christmas_campaign'
|
||||
},
|
||||
text: 'Hi {{address.name}} \nSave big this Christmas in your area {{place}}! \nClick http://www.mysite.com and get huge discount\n Hurry, this offer is only to {{customer_type}}\n {{sender}}',
|
||||
html: '<p>Hi {{address.name}} \nSave big this Christmas in your area {{place}}! \nClick http://www.mysite.com and get huge discount\n</p><p>Hurry, this offer is only to {{customer_type}}\n</p><p>{{sender}}</p>'
|
||||
}
|
||||
})
|
||||
.then(data => {
|
||||
console.log('Congrats you can use our client library!');
|
||||
console.log(data);
|
||||
})
|
||||
.catch(err => {
|
||||
console.log('Whoops! Something went wrong');
|
||||
console.log(err);
|
||||
});
|
||||
|
||||
// Promise
|
||||
client.transmissions.send({
|
||||
recipients: [
|
||||
{
|
||||
address: {
|
||||
email: 'original.recipient@example.com',
|
||||
name: 'Original Recipient'
|
||||
},
|
||||
substitution_data: {
|
||||
recipient_type: 'Original'
|
||||
}
|
||||
},
|
||||
{
|
||||
address: {
|
||||
email: 'cc.recipient@example.com',
|
||||
name: 'Carbon Copy Recipient',
|
||||
header_to: '"Original Recipient" <original.recipient@example.com>'
|
||||
},
|
||||
substitution_data: {
|
||||
recipient_type: 'CC'
|
||||
}
|
||||
}
|
||||
],
|
||||
content: {
|
||||
from: {
|
||||
name: 'Node CC Test',
|
||||
email: 'from@example.com'
|
||||
},
|
||||
headers: {
|
||||
'CC': '"Carbon Copy Recipient" <cc.recipient@example.com>'
|
||||
},
|
||||
subject: 'Example email using cc',
|
||||
text: 'An example email using cc with SparkPost to the {{recipient_type}} recipient.',
|
||||
html: '<p>An example email using cc with SparkPost to the {{recipient_type}} recipient.</p>'
|
||||
}
|
||||
})
|
||||
.then(data => {
|
||||
console.log('Congrats! You sent an email with cc using SparkPost!');
|
||||
console.log(data);
|
||||
})
|
||||
.catch(err => {
|
||||
console.log('Whoops! Something went wrong');
|
||||
console.log(err);
|
||||
});
|
||||
|
||||
client.webhooks.create({
|
||||
name: "Test webhook",
|
||||
target: "http://client.test.com/test-webhook",
|
||||
|
||||
Reference in New Issue
Block a user