@bentonow/bento-node-sdk 0.1.14 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +37 -4
- package/dist/bento-node-sdk.cjs.development.js +99 -0
- package/dist/bento-node-sdk.cjs.development.js.map +1 -1
- package/dist/bento-node-sdk.cjs.production.min.js +1 -1
- package/dist/bento-node-sdk.cjs.production.min.js.map +1 -1
- package/dist/bento-node-sdk.esm.js +99 -0
- package/dist/bento-node-sdk.esm.js.map +1 -1
- package/dist/sdk/batch/errors.d.ts +6 -0
- package/dist/sdk/batch/index.d.ts +17 -1
- package/dist/sdk/batch/types.d.ts +16 -0
- package/package.json +1 -7
- package/src/sdk/batch/errors.ts +14 -0
- package/src/sdk/batch/index.ts +41 -0
- package/src/sdk/batch/types.ts +19 -0
package/README.md
CHANGED
|
@@ -271,8 +271,8 @@ bento.V1.track({
|
|
|
271
271
|
email: 'test@bentonow.com',
|
|
272
272
|
type: '$custom.event',
|
|
273
273
|
fields: {
|
|
274
|
-
|
|
275
|
-
|
|
274
|
+
firstName: 'Custom Name',
|
|
275
|
+
lastName: 'Custom Name',
|
|
276
276
|
},
|
|
277
277
|
details: {
|
|
278
278
|
fromCustomEvent: true,
|
|
@@ -286,7 +286,7 @@ bento.V1.track({
|
|
|
286
286
|
|
|
287
287
|
### `Batch.importSubscribers(parameters: BatchImportSubscribersParameter<S>): Promise<number>`
|
|
288
288
|
|
|
289
|
-
**This does not trigger automations!** - If you wish to trigger automations, please batch import events
|
|
289
|
+
**This does not trigger automations!** - If you wish to trigger automations, please batch import events.
|
|
290
290
|
|
|
291
291
|
Creates a batch job to import subscribers into the system. You can pass in between 1 and 1,000 subscribers to import. Each subscriber must have an email, and may optionally have any additional fields. The additional fields are added as custom fields on the subscriber.
|
|
292
292
|
|
|
@@ -305,6 +305,8 @@ bento.V1.Batch.importSubscribers({
|
|
|
305
305
|
},
|
|
306
306
|
{
|
|
307
307
|
email: 'test2@bentonow.com',
|
|
308
|
+
some_custom_variable: 'tester-123',
|
|
309
|
+
primary_user: true,
|
|
308
310
|
},
|
|
309
311
|
{
|
|
310
312
|
email: 'test3@bentonow.com',
|
|
@@ -320,7 +322,7 @@ bento.V1.Batch.importSubscribers({
|
|
|
320
322
|
|
|
321
323
|
### `Batch.importEvents(parameters: BatchImportEventsParameter<S, E>): Promise<number>`
|
|
322
324
|
|
|
323
|
-
Creates a batch job to import events into the system. You can pass in between 1 and
|
|
325
|
+
Creates a batch job to import events into the system. You can pass in between 1 and 100 events to import. Each event must have an email and a type. In addition to this, you my pass in additional data in the `details` property,
|
|
324
326
|
|
|
325
327
|
Returns the number of events that were imported.
|
|
326
328
|
|
|
@@ -364,6 +366,37 @@ bento.V1.Batch.importEvents({
|
|
|
364
366
|
.catch(error => console.error(error));
|
|
365
367
|
```
|
|
366
368
|
|
|
369
|
+
---
|
|
370
|
+
|
|
371
|
+
### `Batch.sendTransactionalEmails(parameters: BatchsendTransactionalEmailsParameter<S, E>): Promise<number>`
|
|
372
|
+
|
|
373
|
+
Creates a batch job to send transactional emails from Bento's infrastructure. You can pass in between 1 and 100 emails to send. Each email must have a `to` address, a `from` address, a `subject`, an `html_body` and `transactional: true`.
|
|
374
|
+
|
|
375
|
+
In addition you can add a `personalizations` object to provide liquid tags that will be injected into the email.
|
|
376
|
+
|
|
377
|
+
Requests are instant and queued into a priority queue. Most requests will be processed within 30 seconds. We currently limit this endpoint to 60 emails per minute.
|
|
378
|
+
|
|
379
|
+
Returns the number of emails that were imported.
|
|
380
|
+
|
|
381
|
+
```ts
|
|
382
|
+
bento.V1.Batch.sendTransactionalEmails({
|
|
383
|
+
emails: [
|
|
384
|
+
{
|
|
385
|
+
to: 'test@bentonow.com', // required — if no user with this email exists in your account they will be created.
|
|
386
|
+
from: 'jesse@bentonow.com', // required — must be an email author in your account.
|
|
387
|
+
subject: 'Reset Password', // required
|
|
388
|
+
html_body: '<p>Here is a link to reset your password ... {{ link }}</p>', // required - can also use text_body if you want to use our plain text theme.
|
|
389
|
+
transactional: true, // IMPORTANT — this bypasses the subscription status of a user. Abuse will lead to account shutdown.
|
|
390
|
+
personalizations: {
|
|
391
|
+
link: 'https://example.com/test',
|
|
392
|
+
}, // optional — provide your own Liquid tags to be injected into the email.
|
|
393
|
+
},
|
|
394
|
+
],
|
|
395
|
+
})
|
|
396
|
+
.then(result => console.log(result))
|
|
397
|
+
.catch(error => console.error(error));
|
|
398
|
+
```
|
|
399
|
+
|
|
367
400
|
## Commands
|
|
368
401
|
|
|
369
402
|
### `Commands.addTag(parameters: AddTagParameters): Promise<Subscriber<S> | null>`
|
|
@@ -979,10 +979,45 @@ var TooManyEventsError = /*#__PURE__*/function (_Error4) {
|
|
|
979
979
|
|
|
980
980
|
return TooManyEventsError;
|
|
981
981
|
}( /*#__PURE__*/_wrapNativeSuper(Error));
|
|
982
|
+
var TooFewEmailsError = /*#__PURE__*/function (_Error5) {
|
|
983
|
+
_inheritsLoose(TooFewEmailsError, _Error5);
|
|
984
|
+
|
|
985
|
+
function TooFewEmailsError(message) {
|
|
986
|
+
var _this5;
|
|
987
|
+
|
|
988
|
+
if (message === void 0) {
|
|
989
|
+
message = 'Too few emails';
|
|
990
|
+
}
|
|
991
|
+
|
|
992
|
+
_this5 = _Error5.call(this, message) || this;
|
|
993
|
+
_this5.name = 'TooFewEmailsError';
|
|
994
|
+
return _this5;
|
|
995
|
+
}
|
|
996
|
+
|
|
997
|
+
return TooFewEmailsError;
|
|
998
|
+
}( /*#__PURE__*/_wrapNativeSuper(Error));
|
|
999
|
+
var TooManyEmailsError = /*#__PURE__*/function (_Error6) {
|
|
1000
|
+
_inheritsLoose(TooManyEmailsError, _Error6);
|
|
1001
|
+
|
|
1002
|
+
function TooManyEmailsError(message) {
|
|
1003
|
+
var _this6;
|
|
1004
|
+
|
|
1005
|
+
if (message === void 0) {
|
|
1006
|
+
message = 'Too many emails';
|
|
1007
|
+
}
|
|
1008
|
+
|
|
1009
|
+
_this6 = _Error6.call(this, message) || this;
|
|
1010
|
+
_this6.name = 'TooManyEmailsError';
|
|
1011
|
+
return _this6;
|
|
1012
|
+
}
|
|
1013
|
+
|
|
1014
|
+
return TooManyEmailsError;
|
|
1015
|
+
}( /*#__PURE__*/_wrapNativeSuper(Error));
|
|
982
1016
|
|
|
983
1017
|
var BentoBatch = /*#__PURE__*/function () {
|
|
984
1018
|
function BentoBatch(_client) {
|
|
985
1019
|
this._client = void 0;
|
|
1020
|
+
this._maxEmailBatchSize = 100;
|
|
986
1021
|
this._maxBatchSize = 1000;
|
|
987
1022
|
this._url = '/batch';
|
|
988
1023
|
this._client = _client;
|
|
@@ -1117,6 +1152,70 @@ var BentoBatch = /*#__PURE__*/function () {
|
|
|
1117
1152
|
}
|
|
1118
1153
|
|
|
1119
1154
|
return importEvents;
|
|
1155
|
+
}()
|
|
1156
|
+
/**
|
|
1157
|
+
* Creates a batch job to send transactional emails from Bento's infrastructure. You can pass in
|
|
1158
|
+
* between 1 and 100 emails to send.
|
|
1159
|
+
*
|
|
1160
|
+
* Each email must have a `to` address, a `from` address, a `subject`, an `html_body`
|
|
1161
|
+
* and `transactional: true`.
|
|
1162
|
+
* In addition you can add a `personalizations` object to provide
|
|
1163
|
+
* liquid tsags that will be injected into the email.
|
|
1164
|
+
*
|
|
1165
|
+
* Returns the number of events that were imported.
|
|
1166
|
+
*
|
|
1167
|
+
* @param parameters
|
|
1168
|
+
* @returns Promise\<number\>
|
|
1169
|
+
*/
|
|
1170
|
+
;
|
|
1171
|
+
|
|
1172
|
+
_proto.sendTransactionalEmails =
|
|
1173
|
+
/*#__PURE__*/
|
|
1174
|
+
function () {
|
|
1175
|
+
var _sendTransactionalEmails = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee3(parameters) {
|
|
1176
|
+
var result;
|
|
1177
|
+
return runtime_1.wrap(function _callee3$(_context3) {
|
|
1178
|
+
while (1) {
|
|
1179
|
+
switch (_context3.prev = _context3.next) {
|
|
1180
|
+
case 0:
|
|
1181
|
+
if (!(parameters.emails.length === 0)) {
|
|
1182
|
+
_context3.next = 2;
|
|
1183
|
+
break;
|
|
1184
|
+
}
|
|
1185
|
+
|
|
1186
|
+
throw new TooFewEmailsError("You must send between 1 and 100 emails.");
|
|
1187
|
+
|
|
1188
|
+
case 2:
|
|
1189
|
+
if (!(parameters.emails.length > this._maxEmailBatchSize)) {
|
|
1190
|
+
_context3.next = 4;
|
|
1191
|
+
break;
|
|
1192
|
+
}
|
|
1193
|
+
|
|
1194
|
+
throw new TooManyEmailsError("You must send between 1 and 100 emails.");
|
|
1195
|
+
|
|
1196
|
+
case 4:
|
|
1197
|
+
_context3.next = 6;
|
|
1198
|
+
return this._client.post(this._url + "/emails", {
|
|
1199
|
+
emails: parameters.emails
|
|
1200
|
+
});
|
|
1201
|
+
|
|
1202
|
+
case 6:
|
|
1203
|
+
result = _context3.sent;
|
|
1204
|
+
return _context3.abrupt("return", result.results);
|
|
1205
|
+
|
|
1206
|
+
case 8:
|
|
1207
|
+
case "end":
|
|
1208
|
+
return _context3.stop();
|
|
1209
|
+
}
|
|
1210
|
+
}
|
|
1211
|
+
}, _callee3, this);
|
|
1212
|
+
}));
|
|
1213
|
+
|
|
1214
|
+
function sendTransactionalEmails(_x3) {
|
|
1215
|
+
return _sendTransactionalEmails.apply(this, arguments);
|
|
1216
|
+
}
|
|
1217
|
+
|
|
1218
|
+
return sendTransactionalEmails;
|
|
1120
1219
|
}();
|
|
1121
1220
|
|
|
1122
1221
|
return BentoBatch;
|