@bentonow/bento-node-sdk 0.2.1 → 1.0.4
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/{LICENSE → LICENSE.md} +1 -1
- package/README.md +494 -1077
- package/dist/index.d.ts +9 -9
- package/dist/index.js +1273 -5
- package/dist/sdk/batch/enums.d.ts +8 -8
- package/dist/sdk/batch/errors.d.ts +18 -18
- package/dist/sdk/batch/events.d.ts +71 -71
- package/dist/sdk/batch/index.d.ts +55 -55
- package/dist/sdk/batch/types.d.ts +37 -37
- package/dist/sdk/broadcasts/index.d.ts +25 -0
- package/dist/sdk/broadcasts/types.d.ts +28 -0
- package/dist/sdk/client/errors.d.ts +9 -6
- package/dist/sdk/client/index.d.ts +74 -64
- package/dist/sdk/client/types.d.ts +3 -3
- package/dist/sdk/commands/enums.d.ts +12 -12
- package/dist/sdk/commands/index.d.ts +79 -79
- package/dist/sdk/commands/types.d.ts +32 -32
- package/dist/sdk/email-templates/index.d.ts +21 -0
- package/dist/sdk/email-templates/types.d.ts +23 -0
- package/dist/sdk/enums.d.ts +12 -9
- package/dist/sdk/errors.d.ts +2 -2
- package/dist/sdk/experimental/index.d.ts +75 -57
- package/dist/sdk/experimental/types.d.ts +71 -41
- package/dist/sdk/fields/index.d.ts +29 -29
- package/dist/sdk/fields/types.d.ts +17 -17
- package/dist/sdk/forms/index.d.ts +14 -14
- package/dist/sdk/forms/types.d.ts +28 -28
- package/dist/sdk/index.d.ts +11 -8
- package/dist/sdk/interfaces.d.ts +13 -13
- package/dist/sdk/sequences/index.d.ts +13 -0
- package/dist/sdk/sequences/types.d.ts +18 -0
- package/dist/sdk/stats/index.d.ts +24 -0
- package/dist/sdk/stats/types.d.ts +26 -0
- package/dist/sdk/subscribers/index.d.ts +20 -20
- package/dist/sdk/subscribers/types.d.ts +25 -25
- package/dist/sdk/tags/index.d.ts +20 -20
- package/dist/sdk/tags/types.d.ts +17 -17
- package/dist/sdk/types.d.ts +41 -41
- package/dist/sdk/workflows/index.d.ts +13 -0
- package/dist/sdk/workflows/types.d.ts +18 -0
- package/dist/versions/v1/index.d.ts +164 -132
- package/dist/versions/v1/types.d.ts +31 -31
- package/package.json +31 -44
- package/src/sdk/batch/events.ts +1 -1
- package/src/sdk/batch/index.ts +13 -25
- package/src/sdk/broadcasts/index.ts +43 -0
- package/src/sdk/broadcasts/types.ts +34 -0
- package/src/sdk/client/errors.ts +7 -0
- package/src/sdk/client/index.ts +113 -30
- package/src/sdk/commands/index.ts +54 -89
- package/src/sdk/email-templates/index.ts +39 -0
- package/src/sdk/email-templates/types.ts +27 -0
- package/src/sdk/enums.ts +3 -0
- package/src/sdk/experimental/index.ts +44 -26
- package/src/sdk/experimental/types.ts +35 -0
- package/src/sdk/fields/index.ts +1 -3
- package/src/sdk/forms/index.ts +4 -9
- package/src/sdk/forms/types.ts +1 -7
- package/src/sdk/index.ts +3 -0
- package/src/sdk/sequences/index.ts +21 -0
- package/src/sdk/sequences/types.ts +21 -0
- package/src/sdk/stats/index.ts +37 -0
- package/src/sdk/stats/types.ts +28 -0
- package/src/sdk/subscribers/index.ts +5 -15
- package/src/sdk/tags/index.ts +1 -3
- package/src/sdk/types.ts +1 -1
- package/src/sdk/workflows/index.ts +21 -0
- package/src/sdk/workflows/types.ts +21 -0
- package/src/versions/v1/index.ts +59 -10
- package/dist/bento-node-sdk.cjs.development.js +0 -2071
- package/dist/bento-node-sdk.cjs.development.js.map +0 -1
- package/dist/bento-node-sdk.cjs.production.min.js +0 -2
- package/dist/bento-node-sdk.cjs.production.min.js.map +0 -1
- package/dist/bento-node-sdk.esm.js +0 -2063
- package/dist/bento-node-sdk.esm.js.map +0 -1
|
@@ -1,2071 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
-
|
|
5
|
-
function _interopDefault (ex) { return (ex && (typeof ex === 'object') && 'default' in ex) ? ex['default'] : ex; }
|
|
6
|
-
|
|
7
|
-
var fetch = _interopDefault(require('cross-fetch'));
|
|
8
|
-
|
|
9
|
-
function asyncGeneratorStep(n, t, e, r, o, a, c) {
|
|
10
|
-
try {
|
|
11
|
-
var i = n[a](c),
|
|
12
|
-
u = i.value;
|
|
13
|
-
} catch (n) {
|
|
14
|
-
return void e(n);
|
|
15
|
-
}
|
|
16
|
-
i.done ? t(u) : Promise.resolve(u).then(r, o);
|
|
17
|
-
}
|
|
18
|
-
function _asyncToGenerator(n) {
|
|
19
|
-
return function () {
|
|
20
|
-
var t = this,
|
|
21
|
-
e = arguments;
|
|
22
|
-
return new Promise(function (r, o) {
|
|
23
|
-
var a = n.apply(t, e);
|
|
24
|
-
function _next(n) {
|
|
25
|
-
asyncGeneratorStep(a, r, o, _next, _throw, "next", n);
|
|
26
|
-
}
|
|
27
|
-
function _throw(n) {
|
|
28
|
-
asyncGeneratorStep(a, r, o, _next, _throw, "throw", n);
|
|
29
|
-
}
|
|
30
|
-
_next(void 0);
|
|
31
|
-
});
|
|
32
|
-
};
|
|
33
|
-
}
|
|
34
|
-
function _construct(t, e, r) {
|
|
35
|
-
if (_isNativeReflectConstruct()) return Reflect.construct.apply(null, arguments);
|
|
36
|
-
var o = [null];
|
|
37
|
-
o.push.apply(o, e);
|
|
38
|
-
var p = new (t.bind.apply(t, o))();
|
|
39
|
-
return r && _setPrototypeOf(p, r.prototype), p;
|
|
40
|
-
}
|
|
41
|
-
function _extends() {
|
|
42
|
-
return _extends = Object.assign ? Object.assign.bind() : function (n) {
|
|
43
|
-
for (var e = 1; e < arguments.length; e++) {
|
|
44
|
-
var t = arguments[e];
|
|
45
|
-
for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]);
|
|
46
|
-
}
|
|
47
|
-
return n;
|
|
48
|
-
}, _extends.apply(null, arguments);
|
|
49
|
-
}
|
|
50
|
-
function _getPrototypeOf(t) {
|
|
51
|
-
return _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function (t) {
|
|
52
|
-
return t.__proto__ || Object.getPrototypeOf(t);
|
|
53
|
-
}, _getPrototypeOf(t);
|
|
54
|
-
}
|
|
55
|
-
function _inheritsLoose(t, o) {
|
|
56
|
-
t.prototype = Object.create(o.prototype), t.prototype.constructor = t, _setPrototypeOf(t, o);
|
|
57
|
-
}
|
|
58
|
-
function _isNativeFunction(t) {
|
|
59
|
-
try {
|
|
60
|
-
return -1 !== Function.toString.call(t).indexOf("[native code]");
|
|
61
|
-
} catch (n) {
|
|
62
|
-
return "function" == typeof t;
|
|
63
|
-
}
|
|
64
|
-
}
|
|
65
|
-
function _isNativeReflectConstruct() {
|
|
66
|
-
try {
|
|
67
|
-
var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {}));
|
|
68
|
-
} catch (t) {}
|
|
69
|
-
return (_isNativeReflectConstruct = function () {
|
|
70
|
-
return !!t;
|
|
71
|
-
})();
|
|
72
|
-
}
|
|
73
|
-
function _regeneratorRuntime() {
|
|
74
|
-
_regeneratorRuntime = function () {
|
|
75
|
-
return e;
|
|
76
|
-
};
|
|
77
|
-
var t,
|
|
78
|
-
e = {},
|
|
79
|
-
r = Object.prototype,
|
|
80
|
-
n = r.hasOwnProperty,
|
|
81
|
-
o = Object.defineProperty || function (t, e, r) {
|
|
82
|
-
t[e] = r.value;
|
|
83
|
-
},
|
|
84
|
-
i = "function" == typeof Symbol ? Symbol : {},
|
|
85
|
-
a = i.iterator || "@@iterator",
|
|
86
|
-
c = i.asyncIterator || "@@asyncIterator",
|
|
87
|
-
u = i.toStringTag || "@@toStringTag";
|
|
88
|
-
function define(t, e, r) {
|
|
89
|
-
return Object.defineProperty(t, e, {
|
|
90
|
-
value: r,
|
|
91
|
-
enumerable: !0,
|
|
92
|
-
configurable: !0,
|
|
93
|
-
writable: !0
|
|
94
|
-
}), t[e];
|
|
95
|
-
}
|
|
96
|
-
try {
|
|
97
|
-
define({}, "");
|
|
98
|
-
} catch (t) {
|
|
99
|
-
define = function (t, e, r) {
|
|
100
|
-
return t[e] = r;
|
|
101
|
-
};
|
|
102
|
-
}
|
|
103
|
-
function wrap(t, e, r, n) {
|
|
104
|
-
var i = e && e.prototype instanceof Generator ? e : Generator,
|
|
105
|
-
a = Object.create(i.prototype),
|
|
106
|
-
c = new Context(n || []);
|
|
107
|
-
return o(a, "_invoke", {
|
|
108
|
-
value: makeInvokeMethod(t, r, c)
|
|
109
|
-
}), a;
|
|
110
|
-
}
|
|
111
|
-
function tryCatch(t, e, r) {
|
|
112
|
-
try {
|
|
113
|
-
return {
|
|
114
|
-
type: "normal",
|
|
115
|
-
arg: t.call(e, r)
|
|
116
|
-
};
|
|
117
|
-
} catch (t) {
|
|
118
|
-
return {
|
|
119
|
-
type: "throw",
|
|
120
|
-
arg: t
|
|
121
|
-
};
|
|
122
|
-
}
|
|
123
|
-
}
|
|
124
|
-
e.wrap = wrap;
|
|
125
|
-
var h = "suspendedStart",
|
|
126
|
-
l = "suspendedYield",
|
|
127
|
-
f = "executing",
|
|
128
|
-
s = "completed",
|
|
129
|
-
y = {};
|
|
130
|
-
function Generator() {}
|
|
131
|
-
function GeneratorFunction() {}
|
|
132
|
-
function GeneratorFunctionPrototype() {}
|
|
133
|
-
var p = {};
|
|
134
|
-
define(p, a, function () {
|
|
135
|
-
return this;
|
|
136
|
-
});
|
|
137
|
-
var d = Object.getPrototypeOf,
|
|
138
|
-
v = d && d(d(values([])));
|
|
139
|
-
v && v !== r && n.call(v, a) && (p = v);
|
|
140
|
-
var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p);
|
|
141
|
-
function defineIteratorMethods(t) {
|
|
142
|
-
["next", "throw", "return"].forEach(function (e) {
|
|
143
|
-
define(t, e, function (t) {
|
|
144
|
-
return this._invoke(e, t);
|
|
145
|
-
});
|
|
146
|
-
});
|
|
147
|
-
}
|
|
148
|
-
function AsyncIterator(t, e) {
|
|
149
|
-
function invoke(r, o, i, a) {
|
|
150
|
-
var c = tryCatch(t[r], t, o);
|
|
151
|
-
if ("throw" !== c.type) {
|
|
152
|
-
var u = c.arg,
|
|
153
|
-
h = u.value;
|
|
154
|
-
return h && "object" == typeof h && n.call(h, "__await") ? e.resolve(h.__await).then(function (t) {
|
|
155
|
-
invoke("next", t, i, a);
|
|
156
|
-
}, function (t) {
|
|
157
|
-
invoke("throw", t, i, a);
|
|
158
|
-
}) : e.resolve(h).then(function (t) {
|
|
159
|
-
u.value = t, i(u);
|
|
160
|
-
}, function (t) {
|
|
161
|
-
return invoke("throw", t, i, a);
|
|
162
|
-
});
|
|
163
|
-
}
|
|
164
|
-
a(c.arg);
|
|
165
|
-
}
|
|
166
|
-
var r;
|
|
167
|
-
o(this, "_invoke", {
|
|
168
|
-
value: function (t, n) {
|
|
169
|
-
function callInvokeWithMethodAndArg() {
|
|
170
|
-
return new e(function (e, r) {
|
|
171
|
-
invoke(t, n, e, r);
|
|
172
|
-
});
|
|
173
|
-
}
|
|
174
|
-
return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg();
|
|
175
|
-
}
|
|
176
|
-
});
|
|
177
|
-
}
|
|
178
|
-
function makeInvokeMethod(e, r, n) {
|
|
179
|
-
var o = h;
|
|
180
|
-
return function (i, a) {
|
|
181
|
-
if (o === f) throw Error("Generator is already running");
|
|
182
|
-
if (o === s) {
|
|
183
|
-
if ("throw" === i) throw a;
|
|
184
|
-
return {
|
|
185
|
-
value: t,
|
|
186
|
-
done: !0
|
|
187
|
-
};
|
|
188
|
-
}
|
|
189
|
-
for (n.method = i, n.arg = a;;) {
|
|
190
|
-
var c = n.delegate;
|
|
191
|
-
if (c) {
|
|
192
|
-
var u = maybeInvokeDelegate(c, n);
|
|
193
|
-
if (u) {
|
|
194
|
-
if (u === y) continue;
|
|
195
|
-
return u;
|
|
196
|
-
}
|
|
197
|
-
}
|
|
198
|
-
if ("next" === n.method) n.sent = n._sent = n.arg;else if ("throw" === n.method) {
|
|
199
|
-
if (o === h) throw o = s, n.arg;
|
|
200
|
-
n.dispatchException(n.arg);
|
|
201
|
-
} else "return" === n.method && n.abrupt("return", n.arg);
|
|
202
|
-
o = f;
|
|
203
|
-
var p = tryCatch(e, r, n);
|
|
204
|
-
if ("normal" === p.type) {
|
|
205
|
-
if (o = n.done ? s : l, p.arg === y) continue;
|
|
206
|
-
return {
|
|
207
|
-
value: p.arg,
|
|
208
|
-
done: n.done
|
|
209
|
-
};
|
|
210
|
-
}
|
|
211
|
-
"throw" === p.type && (o = s, n.method = "throw", n.arg = p.arg);
|
|
212
|
-
}
|
|
213
|
-
};
|
|
214
|
-
}
|
|
215
|
-
function maybeInvokeDelegate(e, r) {
|
|
216
|
-
var n = r.method,
|
|
217
|
-
o = e.iterator[n];
|
|
218
|
-
if (o === t) return r.delegate = null, "throw" === n && e.iterator.return && (r.method = "return", r.arg = t, maybeInvokeDelegate(e, r), "throw" === r.method) || "return" !== n && (r.method = "throw", r.arg = new TypeError("The iterator does not provide a '" + n + "' method")), y;
|
|
219
|
-
var i = tryCatch(o, e.iterator, r.arg);
|
|
220
|
-
if ("throw" === i.type) return r.method = "throw", r.arg = i.arg, r.delegate = null, y;
|
|
221
|
-
var a = i.arg;
|
|
222
|
-
return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, "return" !== r.method && (r.method = "next", r.arg = t), r.delegate = null, y) : a : (r.method = "throw", r.arg = new TypeError("iterator result is not an object"), r.delegate = null, y);
|
|
223
|
-
}
|
|
224
|
-
function pushTryEntry(t) {
|
|
225
|
-
var e = {
|
|
226
|
-
tryLoc: t[0]
|
|
227
|
-
};
|
|
228
|
-
1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e);
|
|
229
|
-
}
|
|
230
|
-
function resetTryEntry(t) {
|
|
231
|
-
var e = t.completion || {};
|
|
232
|
-
e.type = "normal", delete e.arg, t.completion = e;
|
|
233
|
-
}
|
|
234
|
-
function Context(t) {
|
|
235
|
-
this.tryEntries = [{
|
|
236
|
-
tryLoc: "root"
|
|
237
|
-
}], t.forEach(pushTryEntry, this), this.reset(!0);
|
|
238
|
-
}
|
|
239
|
-
function values(e) {
|
|
240
|
-
if (e || "" === e) {
|
|
241
|
-
var r = e[a];
|
|
242
|
-
if (r) return r.call(e);
|
|
243
|
-
if ("function" == typeof e.next) return e;
|
|
244
|
-
if (!isNaN(e.length)) {
|
|
245
|
-
var o = -1,
|
|
246
|
-
i = function next() {
|
|
247
|
-
for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next;
|
|
248
|
-
return next.value = t, next.done = !0, next;
|
|
249
|
-
};
|
|
250
|
-
return i.next = i;
|
|
251
|
-
}
|
|
252
|
-
}
|
|
253
|
-
throw new TypeError(typeof e + " is not iterable");
|
|
254
|
-
}
|
|
255
|
-
return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, "constructor", {
|
|
256
|
-
value: GeneratorFunctionPrototype,
|
|
257
|
-
configurable: !0
|
|
258
|
-
}), o(GeneratorFunctionPrototype, "constructor", {
|
|
259
|
-
value: GeneratorFunction,
|
|
260
|
-
configurable: !0
|
|
261
|
-
}), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, "GeneratorFunction"), e.isGeneratorFunction = function (t) {
|
|
262
|
-
var e = "function" == typeof t && t.constructor;
|
|
263
|
-
return !!e && (e === GeneratorFunction || "GeneratorFunction" === (e.displayName || e.name));
|
|
264
|
-
}, e.mark = function (t) {
|
|
265
|
-
return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, "GeneratorFunction")), t.prototype = Object.create(g), t;
|
|
266
|
-
}, e.awrap = function (t) {
|
|
267
|
-
return {
|
|
268
|
-
__await: t
|
|
269
|
-
};
|
|
270
|
-
}, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () {
|
|
271
|
-
return this;
|
|
272
|
-
}), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) {
|
|
273
|
-
void 0 === i && (i = Promise);
|
|
274
|
-
var a = new AsyncIterator(wrap(t, r, n, o), i);
|
|
275
|
-
return e.isGeneratorFunction(r) ? a : a.next().then(function (t) {
|
|
276
|
-
return t.done ? t.value : a.next();
|
|
277
|
-
});
|
|
278
|
-
}, defineIteratorMethods(g), define(g, u, "Generator"), define(g, a, function () {
|
|
279
|
-
return this;
|
|
280
|
-
}), define(g, "toString", function () {
|
|
281
|
-
return "[object Generator]";
|
|
282
|
-
}), e.keys = function (t) {
|
|
283
|
-
var e = Object(t),
|
|
284
|
-
r = [];
|
|
285
|
-
for (var n in e) r.push(n);
|
|
286
|
-
return r.reverse(), function next() {
|
|
287
|
-
for (; r.length;) {
|
|
288
|
-
var t = r.pop();
|
|
289
|
-
if (t in e) return next.value = t, next.done = !1, next;
|
|
290
|
-
}
|
|
291
|
-
return next.done = !0, next;
|
|
292
|
-
};
|
|
293
|
-
}, e.values = values, Context.prototype = {
|
|
294
|
-
constructor: Context,
|
|
295
|
-
reset: function (e) {
|
|
296
|
-
if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = "next", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) "t" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t);
|
|
297
|
-
},
|
|
298
|
-
stop: function () {
|
|
299
|
-
this.done = !0;
|
|
300
|
-
var t = this.tryEntries[0].completion;
|
|
301
|
-
if ("throw" === t.type) throw t.arg;
|
|
302
|
-
return this.rval;
|
|
303
|
-
},
|
|
304
|
-
dispatchException: function (e) {
|
|
305
|
-
if (this.done) throw e;
|
|
306
|
-
var r = this;
|
|
307
|
-
function handle(n, o) {
|
|
308
|
-
return a.type = "throw", a.arg = e, r.next = n, o && (r.method = "next", r.arg = t), !!o;
|
|
309
|
-
}
|
|
310
|
-
for (var o = this.tryEntries.length - 1; o >= 0; --o) {
|
|
311
|
-
var i = this.tryEntries[o],
|
|
312
|
-
a = i.completion;
|
|
313
|
-
if ("root" === i.tryLoc) return handle("end");
|
|
314
|
-
if (i.tryLoc <= this.prev) {
|
|
315
|
-
var c = n.call(i, "catchLoc"),
|
|
316
|
-
u = n.call(i, "finallyLoc");
|
|
317
|
-
if (c && u) {
|
|
318
|
-
if (this.prev < i.catchLoc) return handle(i.catchLoc, !0);
|
|
319
|
-
if (this.prev < i.finallyLoc) return handle(i.finallyLoc);
|
|
320
|
-
} else if (c) {
|
|
321
|
-
if (this.prev < i.catchLoc) return handle(i.catchLoc, !0);
|
|
322
|
-
} else {
|
|
323
|
-
if (!u) throw Error("try statement without catch or finally");
|
|
324
|
-
if (this.prev < i.finallyLoc) return handle(i.finallyLoc);
|
|
325
|
-
}
|
|
326
|
-
}
|
|
327
|
-
}
|
|
328
|
-
},
|
|
329
|
-
abrupt: function (t, e) {
|
|
330
|
-
for (var r = this.tryEntries.length - 1; r >= 0; --r) {
|
|
331
|
-
var o = this.tryEntries[r];
|
|
332
|
-
if (o.tryLoc <= this.prev && n.call(o, "finallyLoc") && this.prev < o.finallyLoc) {
|
|
333
|
-
var i = o;
|
|
334
|
-
break;
|
|
335
|
-
}
|
|
336
|
-
}
|
|
337
|
-
i && ("break" === t || "continue" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null);
|
|
338
|
-
var a = i ? i.completion : {};
|
|
339
|
-
return a.type = t, a.arg = e, i ? (this.method = "next", this.next = i.finallyLoc, y) : this.complete(a);
|
|
340
|
-
},
|
|
341
|
-
complete: function (t, e) {
|
|
342
|
-
if ("throw" === t.type) throw t.arg;
|
|
343
|
-
return "break" === t.type || "continue" === t.type ? this.next = t.arg : "return" === t.type ? (this.rval = this.arg = t.arg, this.method = "return", this.next = "end") : "normal" === t.type && e && (this.next = e), y;
|
|
344
|
-
},
|
|
345
|
-
finish: function (t) {
|
|
346
|
-
for (var e = this.tryEntries.length - 1; e >= 0; --e) {
|
|
347
|
-
var r = this.tryEntries[e];
|
|
348
|
-
if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y;
|
|
349
|
-
}
|
|
350
|
-
},
|
|
351
|
-
catch: function (t) {
|
|
352
|
-
for (var e = this.tryEntries.length - 1; e >= 0; --e) {
|
|
353
|
-
var r = this.tryEntries[e];
|
|
354
|
-
if (r.tryLoc === t) {
|
|
355
|
-
var n = r.completion;
|
|
356
|
-
if ("throw" === n.type) {
|
|
357
|
-
var o = n.arg;
|
|
358
|
-
resetTryEntry(r);
|
|
359
|
-
}
|
|
360
|
-
return o;
|
|
361
|
-
}
|
|
362
|
-
}
|
|
363
|
-
throw Error("illegal catch attempt");
|
|
364
|
-
},
|
|
365
|
-
delegateYield: function (e, r, n) {
|
|
366
|
-
return this.delegate = {
|
|
367
|
-
iterator: values(e),
|
|
368
|
-
resultName: r,
|
|
369
|
-
nextLoc: n
|
|
370
|
-
}, "next" === this.method && (this.arg = t), y;
|
|
371
|
-
}
|
|
372
|
-
}, e;
|
|
373
|
-
}
|
|
374
|
-
function _setPrototypeOf(t, e) {
|
|
375
|
-
return _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function (t, e) {
|
|
376
|
-
return t.__proto__ = e, t;
|
|
377
|
-
}, _setPrototypeOf(t, e);
|
|
378
|
-
}
|
|
379
|
-
function _wrapNativeSuper(t) {
|
|
380
|
-
var r = "function" == typeof Map ? new Map() : void 0;
|
|
381
|
-
return _wrapNativeSuper = function (t) {
|
|
382
|
-
if (null === t || !_isNativeFunction(t)) return t;
|
|
383
|
-
if ("function" != typeof t) throw new TypeError("Super expression must either be null or a function");
|
|
384
|
-
if (void 0 !== r) {
|
|
385
|
-
if (r.has(t)) return r.get(t);
|
|
386
|
-
r.set(t, Wrapper);
|
|
387
|
-
}
|
|
388
|
-
function Wrapper() {
|
|
389
|
-
return _construct(t, arguments, _getPrototypeOf(this).constructor);
|
|
390
|
-
}
|
|
391
|
-
return Wrapper.prototype = Object.create(t.prototype, {
|
|
392
|
-
constructor: {
|
|
393
|
-
value: Wrapper,
|
|
394
|
-
enumerable: !1,
|
|
395
|
-
writable: !0,
|
|
396
|
-
configurable: !0
|
|
397
|
-
}
|
|
398
|
-
}), _setPrototypeOf(Wrapper, t);
|
|
399
|
-
}, _wrapNativeSuper(t);
|
|
400
|
-
}
|
|
401
|
-
|
|
402
|
-
var TooFewSubscribersError = /*#__PURE__*/function (_Error) {
|
|
403
|
-
function TooFewSubscribersError(message) {
|
|
404
|
-
var _this;
|
|
405
|
-
if (message === void 0) {
|
|
406
|
-
message = 'Too few subscribers';
|
|
407
|
-
}
|
|
408
|
-
_this = _Error.call(this, message) || this;
|
|
409
|
-
_this.name = 'TooFewSubscribersError';
|
|
410
|
-
return _this;
|
|
411
|
-
}
|
|
412
|
-
_inheritsLoose(TooFewSubscribersError, _Error);
|
|
413
|
-
return TooFewSubscribersError;
|
|
414
|
-
}( /*#__PURE__*/_wrapNativeSuper(Error));
|
|
415
|
-
var TooManySubscribersError = /*#__PURE__*/function (_Error2) {
|
|
416
|
-
function TooManySubscribersError(message) {
|
|
417
|
-
var _this2;
|
|
418
|
-
if (message === void 0) {
|
|
419
|
-
message = 'Too many subscribers';
|
|
420
|
-
}
|
|
421
|
-
_this2 = _Error2.call(this, message) || this;
|
|
422
|
-
_this2.name = 'TooManySubscribersError';
|
|
423
|
-
return _this2;
|
|
424
|
-
}
|
|
425
|
-
_inheritsLoose(TooManySubscribersError, _Error2);
|
|
426
|
-
return TooManySubscribersError;
|
|
427
|
-
}( /*#__PURE__*/_wrapNativeSuper(Error));
|
|
428
|
-
var TooFewEventsError = /*#__PURE__*/function (_Error3) {
|
|
429
|
-
function TooFewEventsError(message) {
|
|
430
|
-
var _this3;
|
|
431
|
-
if (message === void 0) {
|
|
432
|
-
message = 'Too few events';
|
|
433
|
-
}
|
|
434
|
-
_this3 = _Error3.call(this, message) || this;
|
|
435
|
-
_this3.name = 'TooFewEventsError';
|
|
436
|
-
return _this3;
|
|
437
|
-
}
|
|
438
|
-
_inheritsLoose(TooFewEventsError, _Error3);
|
|
439
|
-
return TooFewEventsError;
|
|
440
|
-
}( /*#__PURE__*/_wrapNativeSuper(Error));
|
|
441
|
-
var TooManyEventsError = /*#__PURE__*/function (_Error4) {
|
|
442
|
-
function TooManyEventsError(message) {
|
|
443
|
-
var _this4;
|
|
444
|
-
if (message === void 0) {
|
|
445
|
-
message = 'Too many events';
|
|
446
|
-
}
|
|
447
|
-
_this4 = _Error4.call(this, message) || this;
|
|
448
|
-
_this4.name = 'TooManyEventsError';
|
|
449
|
-
return _this4;
|
|
450
|
-
}
|
|
451
|
-
_inheritsLoose(TooManyEventsError, _Error4);
|
|
452
|
-
return TooManyEventsError;
|
|
453
|
-
}( /*#__PURE__*/_wrapNativeSuper(Error));
|
|
454
|
-
var TooFewEmailsError = /*#__PURE__*/function (_Error5) {
|
|
455
|
-
function TooFewEmailsError(message) {
|
|
456
|
-
var _this5;
|
|
457
|
-
if (message === void 0) {
|
|
458
|
-
message = 'Too few emails';
|
|
459
|
-
}
|
|
460
|
-
_this5 = _Error5.call(this, message) || this;
|
|
461
|
-
_this5.name = 'TooFewEmailsError';
|
|
462
|
-
return _this5;
|
|
463
|
-
}
|
|
464
|
-
_inheritsLoose(TooFewEmailsError, _Error5);
|
|
465
|
-
return TooFewEmailsError;
|
|
466
|
-
}( /*#__PURE__*/_wrapNativeSuper(Error));
|
|
467
|
-
var TooManyEmailsError = /*#__PURE__*/function (_Error6) {
|
|
468
|
-
function TooManyEmailsError(message) {
|
|
469
|
-
var _this6;
|
|
470
|
-
if (message === void 0) {
|
|
471
|
-
message = 'Too many emails';
|
|
472
|
-
}
|
|
473
|
-
_this6 = _Error6.call(this, message) || this;
|
|
474
|
-
_this6.name = 'TooManyEmailsError';
|
|
475
|
-
return _this6;
|
|
476
|
-
}
|
|
477
|
-
_inheritsLoose(TooManyEmailsError, _Error6);
|
|
478
|
-
return TooManyEmailsError;
|
|
479
|
-
}( /*#__PURE__*/_wrapNativeSuper(Error));
|
|
480
|
-
|
|
481
|
-
var BentoBatch = /*#__PURE__*/function () {
|
|
482
|
-
function BentoBatch(_client) {
|
|
483
|
-
this._client = void 0;
|
|
484
|
-
this._maxEmailBatchSize = 100;
|
|
485
|
-
this._maxBatchSize = 1000;
|
|
486
|
-
this._url = '/batch';
|
|
487
|
-
this._client = _client;
|
|
488
|
-
}
|
|
489
|
-
/**
|
|
490
|
-
* **This does not trigger automations!** - If you wish to trigger automations, please batch import
|
|
491
|
-
* events with the type set to `BentoEvents.SUBSCRIBE`, or `$subscribe`. Note that the batch event import
|
|
492
|
-
* cannot attach custom fields and will ignore everything except the email.
|
|
493
|
-
*
|
|
494
|
-
* Creates a batch job to import subscribers into the system. You can pass in
|
|
495
|
-
* between 1 and 1,000 subscribers to import. Each subscriber must have an email,
|
|
496
|
-
* and may optionally have any additional fields. The additional fields are added
|
|
497
|
-
* as custom fields on the subscriber.
|
|
498
|
-
*
|
|
499
|
-
* This method is processed by the Bento import queues and it may take between 1 and
|
|
500
|
-
* 5 minutes for the results to appear in your dashboard.
|
|
501
|
-
*
|
|
502
|
-
* Returns the number of subscribers that were imported.
|
|
503
|
-
*
|
|
504
|
-
* @param parameters
|
|
505
|
-
* @returns Promise\<number\>
|
|
506
|
-
*/
|
|
507
|
-
var _proto = BentoBatch.prototype;
|
|
508
|
-
_proto.importSubscribers =
|
|
509
|
-
/*#__PURE__*/
|
|
510
|
-
function () {
|
|
511
|
-
var _importSubscribers = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(parameters) {
|
|
512
|
-
var result;
|
|
513
|
-
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
514
|
-
while (1) switch (_context.prev = _context.next) {
|
|
515
|
-
case 0:
|
|
516
|
-
if (!(parameters.subscribers.length === 0)) {
|
|
517
|
-
_context.next = 2;
|
|
518
|
-
break;
|
|
519
|
-
}
|
|
520
|
-
throw new TooFewSubscribersError("You must send between 1 and 1,000 subscribers.");
|
|
521
|
-
case 2:
|
|
522
|
-
if (!(parameters.subscribers.length > this._maxBatchSize)) {
|
|
523
|
-
_context.next = 4;
|
|
524
|
-
break;
|
|
525
|
-
}
|
|
526
|
-
throw new TooManySubscribersError("You must send between 1 and 1,000 subscribers.");
|
|
527
|
-
case 4:
|
|
528
|
-
_context.next = 6;
|
|
529
|
-
return this._client.post(this._url + "/subscribers", {
|
|
530
|
-
subscribers: parameters.subscribers
|
|
531
|
-
});
|
|
532
|
-
case 6:
|
|
533
|
-
result = _context.sent;
|
|
534
|
-
return _context.abrupt("return", result.results);
|
|
535
|
-
case 8:
|
|
536
|
-
case "end":
|
|
537
|
-
return _context.stop();
|
|
538
|
-
}
|
|
539
|
-
}, _callee, this);
|
|
540
|
-
}));
|
|
541
|
-
function importSubscribers(_x) {
|
|
542
|
-
return _importSubscribers.apply(this, arguments);
|
|
543
|
-
}
|
|
544
|
-
return importSubscribers;
|
|
545
|
-
}()
|
|
546
|
-
/**
|
|
547
|
-
* Creates a batch job to import events into the system. You can pass in
|
|
548
|
-
* between 1 and 1,000 events to import. Each event must have an email and
|
|
549
|
-
* a type. In addition to this, you my pass in additional data in the
|
|
550
|
-
* `details` property.
|
|
551
|
-
*
|
|
552
|
-
* Returns the number of events that were imported.
|
|
553
|
-
*
|
|
554
|
-
* @param parameters
|
|
555
|
-
* @returns Promise\<number\>
|
|
556
|
-
*/
|
|
557
|
-
;
|
|
558
|
-
_proto.importEvents =
|
|
559
|
-
/*#__PURE__*/
|
|
560
|
-
function () {
|
|
561
|
-
var _importEvents = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(parameters) {
|
|
562
|
-
var result;
|
|
563
|
-
return _regeneratorRuntime().wrap(function _callee2$(_context2) {
|
|
564
|
-
while (1) switch (_context2.prev = _context2.next) {
|
|
565
|
-
case 0:
|
|
566
|
-
if (!(parameters.events.length === 0)) {
|
|
567
|
-
_context2.next = 2;
|
|
568
|
-
break;
|
|
569
|
-
}
|
|
570
|
-
throw new TooFewEventsError("You must send between 1 and 1,000 events.");
|
|
571
|
-
case 2:
|
|
572
|
-
if (!(parameters.events.length > this._maxBatchSize)) {
|
|
573
|
-
_context2.next = 4;
|
|
574
|
-
break;
|
|
575
|
-
}
|
|
576
|
-
throw new TooManyEventsError("You must send between 1 and 1,000 events.");
|
|
577
|
-
case 4:
|
|
578
|
-
_context2.next = 6;
|
|
579
|
-
return this._client.post(this._url + "/events", {
|
|
580
|
-
events: parameters.events
|
|
581
|
-
});
|
|
582
|
-
case 6:
|
|
583
|
-
result = _context2.sent;
|
|
584
|
-
return _context2.abrupt("return", result.results);
|
|
585
|
-
case 8:
|
|
586
|
-
case "end":
|
|
587
|
-
return _context2.stop();
|
|
588
|
-
}
|
|
589
|
-
}, _callee2, this);
|
|
590
|
-
}));
|
|
591
|
-
function importEvents(_x2) {
|
|
592
|
-
return _importEvents.apply(this, arguments);
|
|
593
|
-
}
|
|
594
|
-
return importEvents;
|
|
595
|
-
}()
|
|
596
|
-
/**
|
|
597
|
-
* Creates a batch job to send transactional emails from Bento's infrastructure. You can pass in
|
|
598
|
-
* between 1 and 100 emails to send.
|
|
599
|
-
*
|
|
600
|
-
* Each email must have a `to` address, a `from` address, a `subject`, an `html_body`
|
|
601
|
-
* and `transactional: true`.
|
|
602
|
-
* In addition you can add a `personalizations` object to provide
|
|
603
|
-
* liquid tsags that will be injected into the email.
|
|
604
|
-
*
|
|
605
|
-
* Returns the number of events that were imported.
|
|
606
|
-
*
|
|
607
|
-
* @param parameters
|
|
608
|
-
* @returns Promise\<number\>
|
|
609
|
-
*/
|
|
610
|
-
;
|
|
611
|
-
_proto.sendTransactionalEmails =
|
|
612
|
-
/*#__PURE__*/
|
|
613
|
-
function () {
|
|
614
|
-
var _sendTransactionalEmails = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3(parameters) {
|
|
615
|
-
var result;
|
|
616
|
-
return _regeneratorRuntime().wrap(function _callee3$(_context3) {
|
|
617
|
-
while (1) switch (_context3.prev = _context3.next) {
|
|
618
|
-
case 0:
|
|
619
|
-
if (!(parameters.emails.length === 0)) {
|
|
620
|
-
_context3.next = 2;
|
|
621
|
-
break;
|
|
622
|
-
}
|
|
623
|
-
throw new TooFewEmailsError("You must send between 1 and 100 emails.");
|
|
624
|
-
case 2:
|
|
625
|
-
if (!(parameters.emails.length > this._maxEmailBatchSize)) {
|
|
626
|
-
_context3.next = 4;
|
|
627
|
-
break;
|
|
628
|
-
}
|
|
629
|
-
throw new TooManyEmailsError("You must send between 1 and 100 emails.");
|
|
630
|
-
case 4:
|
|
631
|
-
_context3.next = 6;
|
|
632
|
-
return this._client.post(this._url + "/emails", {
|
|
633
|
-
emails: parameters.emails
|
|
634
|
-
});
|
|
635
|
-
case 6:
|
|
636
|
-
result = _context3.sent;
|
|
637
|
-
return _context3.abrupt("return", result.results);
|
|
638
|
-
case 8:
|
|
639
|
-
case "end":
|
|
640
|
-
return _context3.stop();
|
|
641
|
-
}
|
|
642
|
-
}, _callee3, this);
|
|
643
|
-
}));
|
|
644
|
-
function sendTransactionalEmails(_x3) {
|
|
645
|
-
return _sendTransactionalEmails.apply(this, arguments);
|
|
646
|
-
}
|
|
647
|
-
return sendTransactionalEmails;
|
|
648
|
-
}();
|
|
649
|
-
return BentoBatch;
|
|
650
|
-
}();
|
|
651
|
-
|
|
652
|
-
var NotAuthorizedError = /*#__PURE__*/function (_Error) {
|
|
653
|
-
function NotAuthorizedError(message) {
|
|
654
|
-
var _this;
|
|
655
|
-
if (message === void 0) {
|
|
656
|
-
message = 'Not authorized';
|
|
657
|
-
}
|
|
658
|
-
_this = _Error.call(this, message) || this;
|
|
659
|
-
_this.name = 'NotAuthorizedError';
|
|
660
|
-
return _this;
|
|
661
|
-
}
|
|
662
|
-
_inheritsLoose(NotAuthorizedError, _Error);
|
|
663
|
-
return NotAuthorizedError;
|
|
664
|
-
}( /*#__PURE__*/_wrapNativeSuper(Error));
|
|
665
|
-
var RateLimitedError = /*#__PURE__*/function (_Error2) {
|
|
666
|
-
function RateLimitedError(message) {
|
|
667
|
-
var _this2;
|
|
668
|
-
if (message === void 0) {
|
|
669
|
-
message = 'You are being rate limited';
|
|
670
|
-
}
|
|
671
|
-
_this2 = _Error2.call(this, message) || this;
|
|
672
|
-
_this2.name = 'RateLimitedError';
|
|
673
|
-
return _this2;
|
|
674
|
-
}
|
|
675
|
-
_inheritsLoose(RateLimitedError, _Error2);
|
|
676
|
-
return RateLimitedError;
|
|
677
|
-
}( /*#__PURE__*/_wrapNativeSuper(Error));
|
|
678
|
-
|
|
679
|
-
var BentoClient = /*#__PURE__*/function () {
|
|
680
|
-
function BentoClient(options) {
|
|
681
|
-
var _options$clientOption;
|
|
682
|
-
this._headers = {};
|
|
683
|
-
this._baseUrl = 'https://app.bentonow.com/api/v1';
|
|
684
|
-
this._siteUuid = '';
|
|
685
|
-
this._logErrors = false;
|
|
686
|
-
this._baseUrl = ((_options$clientOption = options.clientOptions) == null ? void 0 : _options$clientOption.baseUrl) || this._baseUrl;
|
|
687
|
-
this._siteUuid = options.siteUuid;
|
|
688
|
-
this._headers = this._extractHeaders(options.authentication);
|
|
689
|
-
this._logErrors = options.logErrors || false;
|
|
690
|
-
}
|
|
691
|
-
/**
|
|
692
|
-
* Wraps a GET request to the Bento API and automatically adds the required
|
|
693
|
-
* headers.
|
|
694
|
-
*
|
|
695
|
-
* @param endpoint string
|
|
696
|
-
* @param payload object
|
|
697
|
-
* @returns Promise\<T\>
|
|
698
|
-
* */
|
|
699
|
-
var _proto = BentoClient.prototype;
|
|
700
|
-
_proto.get = function get(endpoint, payload) {
|
|
701
|
-
var _this = this;
|
|
702
|
-
if (payload === void 0) {
|
|
703
|
-
payload = {};
|
|
704
|
-
}
|
|
705
|
-
return new Promise(function (resolve, reject) {
|
|
706
|
-
var queryParameters = _this._getQueryParameters(payload);
|
|
707
|
-
fetch("" + _this._baseUrl + endpoint + "?" + queryParameters, {
|
|
708
|
-
method: 'GET',
|
|
709
|
-
headers: _this._headers
|
|
710
|
-
}).then( /*#__PURE__*/function () {
|
|
711
|
-
var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(result) {
|
|
712
|
-
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
713
|
-
while (1) switch (_context.prev = _context.next) {
|
|
714
|
-
case 0:
|
|
715
|
-
if (!_this._isSuccessfulStatus(result.status)) {
|
|
716
|
-
_context.next = 2;
|
|
717
|
-
break;
|
|
718
|
-
}
|
|
719
|
-
return _context.abrupt("return", result.json());
|
|
720
|
-
case 2:
|
|
721
|
-
_context.next = 4;
|
|
722
|
-
return _this._getErrorForResponse(result);
|
|
723
|
-
case 4:
|
|
724
|
-
throw _context.sent;
|
|
725
|
-
case 5:
|
|
726
|
-
case "end":
|
|
727
|
-
return _context.stop();
|
|
728
|
-
}
|
|
729
|
-
}, _callee);
|
|
730
|
-
}));
|
|
731
|
-
return function (_x) {
|
|
732
|
-
return _ref.apply(this, arguments);
|
|
733
|
-
};
|
|
734
|
-
}()).then(function (data) {
|
|
735
|
-
return resolve(data);
|
|
736
|
-
})["catch"](function (error) {
|
|
737
|
-
return reject(error);
|
|
738
|
-
});
|
|
739
|
-
});
|
|
740
|
-
}
|
|
741
|
-
/**
|
|
742
|
-
* Wraps a POST request to the Bento API and automatically adds the required
|
|
743
|
-
* headers.
|
|
744
|
-
*
|
|
745
|
-
* @param endpoint string
|
|
746
|
-
* @param payload object
|
|
747
|
-
* @returns Promise\<T\>
|
|
748
|
-
* */;
|
|
749
|
-
_proto.post = function post(endpoint, payload) {
|
|
750
|
-
var _this2 = this;
|
|
751
|
-
if (payload === void 0) {
|
|
752
|
-
payload = {};
|
|
753
|
-
}
|
|
754
|
-
return new Promise(function (resolve, reject) {
|
|
755
|
-
var body = _this2._getBody(payload);
|
|
756
|
-
fetch("" + _this2._baseUrl + endpoint, {
|
|
757
|
-
method: 'POST',
|
|
758
|
-
headers: _extends({}, _this2._headers, {
|
|
759
|
-
'Content-Type': 'application/json'
|
|
760
|
-
}),
|
|
761
|
-
body: body
|
|
762
|
-
}).then( /*#__PURE__*/function () {
|
|
763
|
-
var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(result) {
|
|
764
|
-
return _regeneratorRuntime().wrap(function _callee2$(_context2) {
|
|
765
|
-
while (1) switch (_context2.prev = _context2.next) {
|
|
766
|
-
case 0:
|
|
767
|
-
if (!_this2._isSuccessfulStatus(result.status)) {
|
|
768
|
-
_context2.next = 2;
|
|
769
|
-
break;
|
|
770
|
-
}
|
|
771
|
-
return _context2.abrupt("return", result.json());
|
|
772
|
-
case 2:
|
|
773
|
-
_context2.next = 4;
|
|
774
|
-
return _this2._getErrorForResponse(result);
|
|
775
|
-
case 4:
|
|
776
|
-
throw _context2.sent;
|
|
777
|
-
case 5:
|
|
778
|
-
case "end":
|
|
779
|
-
return _context2.stop();
|
|
780
|
-
}
|
|
781
|
-
}, _callee2);
|
|
782
|
-
}));
|
|
783
|
-
return function (_x2) {
|
|
784
|
-
return _ref2.apply(this, arguments);
|
|
785
|
-
};
|
|
786
|
-
}()).then(function (data) {
|
|
787
|
-
return resolve(data);
|
|
788
|
-
})["catch"](function (error) {
|
|
789
|
-
return reject(error);
|
|
790
|
-
});
|
|
791
|
-
});
|
|
792
|
-
}
|
|
793
|
-
/**
|
|
794
|
-
* Extracts the `publishableKey` and `secretKey` from the `authentication` options and
|
|
795
|
-
* adds the `Authorization` header.
|
|
796
|
-
*
|
|
797
|
-
* @param authentication AuthenticationOptions
|
|
798
|
-
* @returns HeadersInit
|
|
799
|
-
*/;
|
|
800
|
-
_proto._extractHeaders = function _extractHeaders(authentication) {
|
|
801
|
-
var authenticationKey = Buffer.from(authentication.publishableKey + ":" + authentication.secretKey).toString('base64');
|
|
802
|
-
return {
|
|
803
|
-
Authorization: "Basic " + authenticationKey
|
|
804
|
-
};
|
|
805
|
-
}
|
|
806
|
-
/**
|
|
807
|
-
* Takes the existing payload and adds the `site_uuid` to it, then returns
|
|
808
|
-
* it out as a JSON string so that it can be sent alongside the request.
|
|
809
|
-
*
|
|
810
|
-
* @param payload object
|
|
811
|
-
* @returns string
|
|
812
|
-
*/;
|
|
813
|
-
_proto._getBody = function _getBody(payload) {
|
|
814
|
-
return JSON.stringify(_extends({}, payload, {
|
|
815
|
-
site_uuid: this._siteUuid
|
|
816
|
-
}));
|
|
817
|
-
}
|
|
818
|
-
/**
|
|
819
|
-
* Takes the existing payload and adds the `site_uuid` to it, converts the
|
|
820
|
-
* object to a query string so that it can be sent alongside a GET request.
|
|
821
|
-
*
|
|
822
|
-
* @param payload object
|
|
823
|
-
* @returns string
|
|
824
|
-
*/;
|
|
825
|
-
_proto._getQueryParameters = function _getQueryParameters(payload) {
|
|
826
|
-
var body = _extends({}, payload, {
|
|
827
|
-
site_uuid: this._siteUuid
|
|
828
|
-
});
|
|
829
|
-
var queryParameters = new URLSearchParams();
|
|
830
|
-
for (var _i = 0, _Object$entries = Object.entries(body); _i < _Object$entries.length; _i++) {
|
|
831
|
-
var _Object$entries$_i = _Object$entries[_i],
|
|
832
|
-
key = _Object$entries$_i[0],
|
|
833
|
-
value = _Object$entries$_i[1];
|
|
834
|
-
queryParameters.append(key, value);
|
|
835
|
-
}
|
|
836
|
-
return queryParameters.toString();
|
|
837
|
-
}
|
|
838
|
-
/**
|
|
839
|
-
* Filters down the status codes to those that are considered a 'success'.
|
|
840
|
-
*
|
|
841
|
-
* @param statusCode number
|
|
842
|
-
* @returns boolean
|
|
843
|
-
*/;
|
|
844
|
-
_proto._isSuccessfulStatus = function _isSuccessfulStatus(statusCode) {
|
|
845
|
-
var validStatusCodes = [200, 201];
|
|
846
|
-
return validStatusCodes.includes(statusCode);
|
|
847
|
-
}
|
|
848
|
-
/**
|
|
849
|
-
* Returns an appropriate error to be thrown given the received response.
|
|
850
|
-
*
|
|
851
|
-
* @param response Response
|
|
852
|
-
* @returns Error
|
|
853
|
-
*/;
|
|
854
|
-
_proto._getErrorForResponse =
|
|
855
|
-
/*#__PURE__*/
|
|
856
|
-
function () {
|
|
857
|
-
var _getErrorForResponse2 = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3(response) {
|
|
858
|
-
var contentType, responseMessage;
|
|
859
|
-
return _regeneratorRuntime().wrap(function _callee3$(_context3) {
|
|
860
|
-
while (1) switch (_context3.prev = _context3.next) {
|
|
861
|
-
case 0:
|
|
862
|
-
if (this._logErrors) {
|
|
863
|
-
console.error(response);
|
|
864
|
-
}
|
|
865
|
-
if (!(response.status === 401)) {
|
|
866
|
-
_context3.next = 3;
|
|
867
|
-
break;
|
|
868
|
-
}
|
|
869
|
-
return _context3.abrupt("return", new NotAuthorizedError());
|
|
870
|
-
case 3:
|
|
871
|
-
if (!(response.status === 429)) {
|
|
872
|
-
_context3.next = 5;
|
|
873
|
-
break;
|
|
874
|
-
}
|
|
875
|
-
return _context3.abrupt("return", new RateLimitedError());
|
|
876
|
-
case 5:
|
|
877
|
-
contentType = response.headers.get('Content-Type');
|
|
878
|
-
responseMessage = '';
|
|
879
|
-
_context3.t0 = contentType == null ? void 0 : contentType.toLocaleLowerCase();
|
|
880
|
-
_context3.next = _context3.t0 === 'text/plain' ? 10 : _context3.t0 === 'application/json' ? 14 : 20;
|
|
881
|
-
break;
|
|
882
|
-
case 10:
|
|
883
|
-
_context3.next = 12;
|
|
884
|
-
return response.text();
|
|
885
|
-
case 12:
|
|
886
|
-
responseMessage = _context3.sent;
|
|
887
|
-
return _context3.abrupt("break", 22);
|
|
888
|
-
case 14:
|
|
889
|
-
_context3.t1 = JSON;
|
|
890
|
-
_context3.next = 17;
|
|
891
|
-
return response.json();
|
|
892
|
-
case 17:
|
|
893
|
-
_context3.t2 = _context3.sent;
|
|
894
|
-
responseMessage = _context3.t1.stringify.call(_context3.t1, _context3.t2);
|
|
895
|
-
return _context3.abrupt("break", 22);
|
|
896
|
-
case 20:
|
|
897
|
-
responseMessage = 'Unknown response from the Bento API.';
|
|
898
|
-
return _context3.abrupt("break", 22);
|
|
899
|
-
case 22:
|
|
900
|
-
return _context3.abrupt("return", new Error("[" + response.status + "] - " + responseMessage));
|
|
901
|
-
case 23:
|
|
902
|
-
case "end":
|
|
903
|
-
return _context3.stop();
|
|
904
|
-
}
|
|
905
|
-
}, _callee3, this);
|
|
906
|
-
}));
|
|
907
|
-
function _getErrorForResponse(_x3) {
|
|
908
|
-
return _getErrorForResponse2.apply(this, arguments);
|
|
909
|
-
}
|
|
910
|
-
return _getErrorForResponse;
|
|
911
|
-
}();
|
|
912
|
-
return BentoClient;
|
|
913
|
-
}();
|
|
914
|
-
|
|
915
|
-
/**
|
|
916
|
-
* Command Enums
|
|
917
|
-
*/
|
|
918
|
-
var CommandTypes;
|
|
919
|
-
(function (CommandTypes) {
|
|
920
|
-
CommandTypes["ADD_FIELD"] = "add_field";
|
|
921
|
-
CommandTypes["ADD_TAG"] = "add_tag";
|
|
922
|
-
CommandTypes["CHANGE_EMAIL"] = "change_email";
|
|
923
|
-
CommandTypes["REMOVE_FIELD"] = "remove_field";
|
|
924
|
-
CommandTypes["REMOVE_TAG"] = "remove_tag";
|
|
925
|
-
CommandTypes["SUBSCRIBE"] = "subscribe";
|
|
926
|
-
CommandTypes["UNSUBSCRIBE"] = "unsubscribe";
|
|
927
|
-
})(CommandTypes || (CommandTypes = {}));
|
|
928
|
-
|
|
929
|
-
var BentoCommands = /*#__PURE__*/function () {
|
|
930
|
-
function BentoCommands(_client) {
|
|
931
|
-
this._client = void 0;
|
|
932
|
-
this._url = '/fetch/commands';
|
|
933
|
-
this._client = _client;
|
|
934
|
-
}
|
|
935
|
-
/**
|
|
936
|
-
* **This does not trigger automations!** - If you wish to trigger automations, please use the
|
|
937
|
-
* core module's `tagSubscriber` method.
|
|
938
|
-
*
|
|
939
|
-
* Adds a tag to the subscriber with the matching email.
|
|
940
|
-
*
|
|
941
|
-
* Note that both the tag and the subscriber will be created if either is missing
|
|
942
|
-
* from system.
|
|
943
|
-
*
|
|
944
|
-
*
|
|
945
|
-
* @param parameters \{ email: string, tagName: string \}
|
|
946
|
-
* @returns Promise\<Subscriber | null\>
|
|
947
|
-
*/
|
|
948
|
-
var _proto = BentoCommands.prototype;
|
|
949
|
-
_proto.addTag =
|
|
950
|
-
/*#__PURE__*/
|
|
951
|
-
function () {
|
|
952
|
-
var _addTag = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(parameters) {
|
|
953
|
-
var result;
|
|
954
|
-
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
955
|
-
while (1) switch (_context.prev = _context.next) {
|
|
956
|
-
case 0:
|
|
957
|
-
_context.next = 2;
|
|
958
|
-
return this._client.post(this._url, {
|
|
959
|
-
command: {
|
|
960
|
-
command: CommandTypes.ADD_TAG,
|
|
961
|
-
email: parameters.email,
|
|
962
|
-
query: parameters.tagName
|
|
963
|
-
}
|
|
964
|
-
});
|
|
965
|
-
case 2:
|
|
966
|
-
result = _context.sent;
|
|
967
|
-
if (!(Object.keys(result).length === 0 || !result.data)) {
|
|
968
|
-
_context.next = 5;
|
|
969
|
-
break;
|
|
970
|
-
}
|
|
971
|
-
return _context.abrupt("return", null);
|
|
972
|
-
case 5:
|
|
973
|
-
return _context.abrupt("return", result.data);
|
|
974
|
-
case 6:
|
|
975
|
-
case "end":
|
|
976
|
-
return _context.stop();
|
|
977
|
-
}
|
|
978
|
-
}, _callee, this);
|
|
979
|
-
}));
|
|
980
|
-
function addTag(_x) {
|
|
981
|
-
return _addTag.apply(this, arguments);
|
|
982
|
-
}
|
|
983
|
-
return addTag;
|
|
984
|
-
}()
|
|
985
|
-
/**
|
|
986
|
-
* Removes the specified tag from the subscriber with the matching email.
|
|
987
|
-
*
|
|
988
|
-
* @param parameters \{ email: string, tagName: string \}
|
|
989
|
-
* @returns Promise\<Subscriber | null\>
|
|
990
|
-
*/
|
|
991
|
-
;
|
|
992
|
-
_proto.removeTag =
|
|
993
|
-
/*#__PURE__*/
|
|
994
|
-
function () {
|
|
995
|
-
var _removeTag = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(parameters) {
|
|
996
|
-
var result;
|
|
997
|
-
return _regeneratorRuntime().wrap(function _callee2$(_context2) {
|
|
998
|
-
while (1) switch (_context2.prev = _context2.next) {
|
|
999
|
-
case 0:
|
|
1000
|
-
_context2.next = 2;
|
|
1001
|
-
return this._client.post(this._url, {
|
|
1002
|
-
command: {
|
|
1003
|
-
command: CommandTypes.REMOVE_TAG,
|
|
1004
|
-
email: parameters.email,
|
|
1005
|
-
query: parameters.tagName
|
|
1006
|
-
}
|
|
1007
|
-
});
|
|
1008
|
-
case 2:
|
|
1009
|
-
result = _context2.sent;
|
|
1010
|
-
if (!(Object.keys(result).length === 0 || !result.data)) {
|
|
1011
|
-
_context2.next = 5;
|
|
1012
|
-
break;
|
|
1013
|
-
}
|
|
1014
|
-
return _context2.abrupt("return", null);
|
|
1015
|
-
case 5:
|
|
1016
|
-
return _context2.abrupt("return", result.data);
|
|
1017
|
-
case 6:
|
|
1018
|
-
case "end":
|
|
1019
|
-
return _context2.stop();
|
|
1020
|
-
}
|
|
1021
|
-
}, _callee2, this);
|
|
1022
|
-
}));
|
|
1023
|
-
function removeTag(_x2) {
|
|
1024
|
-
return _removeTag.apply(this, arguments);
|
|
1025
|
-
}
|
|
1026
|
-
return removeTag;
|
|
1027
|
-
}()
|
|
1028
|
-
/**
|
|
1029
|
-
* **This does not trigger automations!** - If you wish to trigger automations, please use the
|
|
1030
|
-
* core module's `updateFields` method.
|
|
1031
|
-
*
|
|
1032
|
-
* Adds a field to the subscriber with the matching email.
|
|
1033
|
-
*
|
|
1034
|
-
* Note that both the field and the subscriber will be created if either is missing
|
|
1035
|
-
* from system.
|
|
1036
|
-
*
|
|
1037
|
-
* @param parameters \{ email: string, field: \{ key: string; value: string; \} \}
|
|
1038
|
-
* @returns Promise\<Subscriber | null\>
|
|
1039
|
-
*/
|
|
1040
|
-
;
|
|
1041
|
-
_proto.addField =
|
|
1042
|
-
/*#__PURE__*/
|
|
1043
|
-
function () {
|
|
1044
|
-
var _addField = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3(parameters) {
|
|
1045
|
-
var result;
|
|
1046
|
-
return _regeneratorRuntime().wrap(function _callee3$(_context3) {
|
|
1047
|
-
while (1) switch (_context3.prev = _context3.next) {
|
|
1048
|
-
case 0:
|
|
1049
|
-
_context3.next = 2;
|
|
1050
|
-
return this._client.post(this._url, {
|
|
1051
|
-
command: {
|
|
1052
|
-
command: CommandTypes.ADD_FIELD,
|
|
1053
|
-
email: parameters.email,
|
|
1054
|
-
query: parameters.field
|
|
1055
|
-
}
|
|
1056
|
-
});
|
|
1057
|
-
case 2:
|
|
1058
|
-
result = _context3.sent;
|
|
1059
|
-
if (!(Object.keys(result).length === 0 || !result.data)) {
|
|
1060
|
-
_context3.next = 5;
|
|
1061
|
-
break;
|
|
1062
|
-
}
|
|
1063
|
-
return _context3.abrupt("return", null);
|
|
1064
|
-
case 5:
|
|
1065
|
-
return _context3.abrupt("return", result.data);
|
|
1066
|
-
case 6:
|
|
1067
|
-
case "end":
|
|
1068
|
-
return _context3.stop();
|
|
1069
|
-
}
|
|
1070
|
-
}, _callee3, this);
|
|
1071
|
-
}));
|
|
1072
|
-
function addField(_x3) {
|
|
1073
|
-
return _addField.apply(this, arguments);
|
|
1074
|
-
}
|
|
1075
|
-
return addField;
|
|
1076
|
-
}()
|
|
1077
|
-
/**
|
|
1078
|
-
* Removes a field to the subscriber with the matching email.
|
|
1079
|
-
*
|
|
1080
|
-
* @param parameters \{ email: string, fieldName: string \}
|
|
1081
|
-
* @returns Promise\<Subscriber | null\>
|
|
1082
|
-
*/
|
|
1083
|
-
;
|
|
1084
|
-
_proto.removeField =
|
|
1085
|
-
/*#__PURE__*/
|
|
1086
|
-
function () {
|
|
1087
|
-
var _removeField = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4(parameters) {
|
|
1088
|
-
var result;
|
|
1089
|
-
return _regeneratorRuntime().wrap(function _callee4$(_context4) {
|
|
1090
|
-
while (1) switch (_context4.prev = _context4.next) {
|
|
1091
|
-
case 0:
|
|
1092
|
-
_context4.next = 2;
|
|
1093
|
-
return this._client.post(this._url, {
|
|
1094
|
-
command: {
|
|
1095
|
-
command: CommandTypes.REMOVE_FIELD,
|
|
1096
|
-
email: parameters.email,
|
|
1097
|
-
query: parameters.fieldName
|
|
1098
|
-
}
|
|
1099
|
-
});
|
|
1100
|
-
case 2:
|
|
1101
|
-
result = _context4.sent;
|
|
1102
|
-
if (!(Object.keys(result).length === 0 || !result.data)) {
|
|
1103
|
-
_context4.next = 5;
|
|
1104
|
-
break;
|
|
1105
|
-
}
|
|
1106
|
-
return _context4.abrupt("return", null);
|
|
1107
|
-
case 5:
|
|
1108
|
-
return _context4.abrupt("return", result.data);
|
|
1109
|
-
case 6:
|
|
1110
|
-
case "end":
|
|
1111
|
-
return _context4.stop();
|
|
1112
|
-
}
|
|
1113
|
-
}, _callee4, this);
|
|
1114
|
-
}));
|
|
1115
|
-
function removeField(_x4) {
|
|
1116
|
-
return _removeField.apply(this, arguments);
|
|
1117
|
-
}
|
|
1118
|
-
return removeField;
|
|
1119
|
-
}()
|
|
1120
|
-
/**
|
|
1121
|
-
* **This does not trigger automations!** - If you wish to trigger automations, please use the
|
|
1122
|
-
* core module's `addSubscriber` method.
|
|
1123
|
-
*
|
|
1124
|
-
* Subscribes the supplied email to Bento. If the email does not exist, it is created.
|
|
1125
|
-
* If the subscriber had previously unsubscribed, they will be re-subscribed.
|
|
1126
|
-
*
|
|
1127
|
-
* @param parameters \{ email: string \}
|
|
1128
|
-
* @returns Promise\<Subscriber | null\>
|
|
1129
|
-
*/
|
|
1130
|
-
;
|
|
1131
|
-
_proto.subscribe =
|
|
1132
|
-
/*#__PURE__*/
|
|
1133
|
-
function () {
|
|
1134
|
-
var _subscribe = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee5(parameters) {
|
|
1135
|
-
var result;
|
|
1136
|
-
return _regeneratorRuntime().wrap(function _callee5$(_context5) {
|
|
1137
|
-
while (1) switch (_context5.prev = _context5.next) {
|
|
1138
|
-
case 0:
|
|
1139
|
-
_context5.next = 2;
|
|
1140
|
-
return this._client.post(this._url, {
|
|
1141
|
-
command: {
|
|
1142
|
-
command: CommandTypes.SUBSCRIBE,
|
|
1143
|
-
email: parameters.email
|
|
1144
|
-
}
|
|
1145
|
-
});
|
|
1146
|
-
case 2:
|
|
1147
|
-
result = _context5.sent;
|
|
1148
|
-
if (!(Object.keys(result).length === 0 || !result.data)) {
|
|
1149
|
-
_context5.next = 5;
|
|
1150
|
-
break;
|
|
1151
|
-
}
|
|
1152
|
-
return _context5.abrupt("return", null);
|
|
1153
|
-
case 5:
|
|
1154
|
-
return _context5.abrupt("return", result.data);
|
|
1155
|
-
case 6:
|
|
1156
|
-
case "end":
|
|
1157
|
-
return _context5.stop();
|
|
1158
|
-
}
|
|
1159
|
-
}, _callee5, this);
|
|
1160
|
-
}));
|
|
1161
|
-
function subscribe(_x5) {
|
|
1162
|
-
return _subscribe.apply(this, arguments);
|
|
1163
|
-
}
|
|
1164
|
-
return subscribe;
|
|
1165
|
-
}()
|
|
1166
|
-
/**
|
|
1167
|
-
* **This does not trigger automations!** - If you wish to trigger automations, please use the
|
|
1168
|
-
* core module's `removeSubscriber` method.
|
|
1169
|
-
*
|
|
1170
|
-
* Unsubscribes the supplied email to Bento. If the email does not exist, it is created and
|
|
1171
|
-
* immediately unsubscribed. If they had already unsubscribed, the `unsubscribed_at` property
|
|
1172
|
-
* is updated.
|
|
1173
|
-
*
|
|
1174
|
-
* @param parameters \{ email: string \}
|
|
1175
|
-
* @returns Promise\<Subscriber | null\>
|
|
1176
|
-
*/
|
|
1177
|
-
;
|
|
1178
|
-
_proto.unsubscribe =
|
|
1179
|
-
/*#__PURE__*/
|
|
1180
|
-
function () {
|
|
1181
|
-
var _unsubscribe = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee6(parameters) {
|
|
1182
|
-
var result;
|
|
1183
|
-
return _regeneratorRuntime().wrap(function _callee6$(_context6) {
|
|
1184
|
-
while (1) switch (_context6.prev = _context6.next) {
|
|
1185
|
-
case 0:
|
|
1186
|
-
_context6.next = 2;
|
|
1187
|
-
return this._client.post(this._url, {
|
|
1188
|
-
command: {
|
|
1189
|
-
command: CommandTypes.UNSUBSCRIBE,
|
|
1190
|
-
email: parameters.email
|
|
1191
|
-
}
|
|
1192
|
-
});
|
|
1193
|
-
case 2:
|
|
1194
|
-
result = _context6.sent;
|
|
1195
|
-
if (!(Object.keys(result).length === 0 || !result.data)) {
|
|
1196
|
-
_context6.next = 5;
|
|
1197
|
-
break;
|
|
1198
|
-
}
|
|
1199
|
-
return _context6.abrupt("return", null);
|
|
1200
|
-
case 5:
|
|
1201
|
-
return _context6.abrupt("return", result.data);
|
|
1202
|
-
case 6:
|
|
1203
|
-
case "end":
|
|
1204
|
-
return _context6.stop();
|
|
1205
|
-
}
|
|
1206
|
-
}, _callee6, this);
|
|
1207
|
-
}));
|
|
1208
|
-
function unsubscribe(_x6) {
|
|
1209
|
-
return _unsubscribe.apply(this, arguments);
|
|
1210
|
-
}
|
|
1211
|
-
return unsubscribe;
|
|
1212
|
-
}()
|
|
1213
|
-
/**
|
|
1214
|
-
* Updates the email of a user in Bento.
|
|
1215
|
-
*
|
|
1216
|
-
* @param parameters \{ oldEmail: string, newEmail: string \}
|
|
1217
|
-
* @returns Promise\<Subscriber | null\>
|
|
1218
|
-
*/
|
|
1219
|
-
;
|
|
1220
|
-
_proto.changeEmail =
|
|
1221
|
-
/*#__PURE__*/
|
|
1222
|
-
function () {
|
|
1223
|
-
var _changeEmail = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee7(parameters) {
|
|
1224
|
-
var result;
|
|
1225
|
-
return _regeneratorRuntime().wrap(function _callee7$(_context7) {
|
|
1226
|
-
while (1) switch (_context7.prev = _context7.next) {
|
|
1227
|
-
case 0:
|
|
1228
|
-
_context7.next = 2;
|
|
1229
|
-
return this._client.post(this._url, {
|
|
1230
|
-
command: {
|
|
1231
|
-
command: CommandTypes.CHANGE_EMAIL,
|
|
1232
|
-
email: parameters.oldEmail,
|
|
1233
|
-
query: parameters.newEmail
|
|
1234
|
-
}
|
|
1235
|
-
});
|
|
1236
|
-
case 2:
|
|
1237
|
-
result = _context7.sent;
|
|
1238
|
-
if (!(Object.keys(result).length === 0 || !result.data)) {
|
|
1239
|
-
_context7.next = 5;
|
|
1240
|
-
break;
|
|
1241
|
-
}
|
|
1242
|
-
return _context7.abrupt("return", null);
|
|
1243
|
-
case 5:
|
|
1244
|
-
return _context7.abrupt("return", result.data);
|
|
1245
|
-
case 6:
|
|
1246
|
-
case "end":
|
|
1247
|
-
return _context7.stop();
|
|
1248
|
-
}
|
|
1249
|
-
}, _callee7, this);
|
|
1250
|
-
}));
|
|
1251
|
-
function changeEmail(_x7) {
|
|
1252
|
-
return _changeEmail.apply(this, arguments);
|
|
1253
|
-
}
|
|
1254
|
-
return changeEmail;
|
|
1255
|
-
}();
|
|
1256
|
-
return BentoCommands;
|
|
1257
|
-
}();
|
|
1258
|
-
|
|
1259
|
-
var BentoExperimental = /*#__PURE__*/function () {
|
|
1260
|
-
function BentoExperimental(_client) {
|
|
1261
|
-
this._client = void 0;
|
|
1262
|
-
this._url = '/experimental';
|
|
1263
|
-
this._client = _client;
|
|
1264
|
-
}
|
|
1265
|
-
/**
|
|
1266
|
-
* **EXPERIMENTAL** -
|
|
1267
|
-
* This functionality is experimental and may change or stop working at any time.
|
|
1268
|
-
*
|
|
1269
|
-
* Attempts to validate the email. You can provide additional information to further
|
|
1270
|
-
* refine the validation.
|
|
1271
|
-
*
|
|
1272
|
-
* If a name is provided, it compares it against the US Census Data, and so the results
|
|
1273
|
-
* may be biased.
|
|
1274
|
-
*
|
|
1275
|
-
* @param parameters
|
|
1276
|
-
* @returns Promise\<boolean\>
|
|
1277
|
-
*/
|
|
1278
|
-
var _proto = BentoExperimental.prototype;
|
|
1279
|
-
_proto.validateEmail =
|
|
1280
|
-
/*#__PURE__*/
|
|
1281
|
-
function () {
|
|
1282
|
-
var _validateEmail = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(parameters) {
|
|
1283
|
-
var result;
|
|
1284
|
-
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
1285
|
-
while (1) switch (_context.prev = _context.next) {
|
|
1286
|
-
case 0:
|
|
1287
|
-
_context.next = 2;
|
|
1288
|
-
return this._client.post(this._url + "/validation", {
|
|
1289
|
-
email: parameters.email,
|
|
1290
|
-
ip: parameters.ip,
|
|
1291
|
-
name: parameters.name,
|
|
1292
|
-
user_agent: parameters.userAgent
|
|
1293
|
-
});
|
|
1294
|
-
case 2:
|
|
1295
|
-
result = _context.sent;
|
|
1296
|
-
return _context.abrupt("return", result.valid);
|
|
1297
|
-
case 4:
|
|
1298
|
-
case "end":
|
|
1299
|
-
return _context.stop();
|
|
1300
|
-
}
|
|
1301
|
-
}, _callee, this);
|
|
1302
|
-
}));
|
|
1303
|
-
function validateEmail(_x) {
|
|
1304
|
-
return _validateEmail.apply(this, arguments);
|
|
1305
|
-
}
|
|
1306
|
-
return validateEmail;
|
|
1307
|
-
}()
|
|
1308
|
-
/**
|
|
1309
|
-
* **EXPERIMENTAL** -
|
|
1310
|
-
* This functionality is experimental and may change or stop working at any time.
|
|
1311
|
-
*
|
|
1312
|
-
* Attempts to guess the gender of the person given a provided name. It compares
|
|
1313
|
-
* the name against the US Census Data, and so the results may be biased.
|
|
1314
|
-
*
|
|
1315
|
-
* It is possible for the gender to be unknown if the system cannot confidently
|
|
1316
|
-
* conclude what gender it may be.
|
|
1317
|
-
*
|
|
1318
|
-
* @param parameters
|
|
1319
|
-
* @returns Promise\<GuessGenderResponse\>
|
|
1320
|
-
*/
|
|
1321
|
-
;
|
|
1322
|
-
_proto.guessGender =
|
|
1323
|
-
/*#__PURE__*/
|
|
1324
|
-
function () {
|
|
1325
|
-
var _guessGender = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(parameters) {
|
|
1326
|
-
var result;
|
|
1327
|
-
return _regeneratorRuntime().wrap(function _callee2$(_context2) {
|
|
1328
|
-
while (1) switch (_context2.prev = _context2.next) {
|
|
1329
|
-
case 0:
|
|
1330
|
-
_context2.next = 2;
|
|
1331
|
-
return this._client.post(this._url + "/gender", parameters);
|
|
1332
|
-
case 2:
|
|
1333
|
-
result = _context2.sent;
|
|
1334
|
-
return _context2.abrupt("return", result);
|
|
1335
|
-
case 4:
|
|
1336
|
-
case "end":
|
|
1337
|
-
return _context2.stop();
|
|
1338
|
-
}
|
|
1339
|
-
}, _callee2, this);
|
|
1340
|
-
}));
|
|
1341
|
-
function guessGender(_x2) {
|
|
1342
|
-
return _guessGender.apply(this, arguments);
|
|
1343
|
-
}
|
|
1344
|
-
return guessGender;
|
|
1345
|
-
}()
|
|
1346
|
-
/**
|
|
1347
|
-
* **EXPERIMENTAL** -
|
|
1348
|
-
* This functionality is experimental and may change or stop working at any time.
|
|
1349
|
-
*
|
|
1350
|
-
* Attempts to provide location data given a provided IP address.
|
|
1351
|
-
*
|
|
1352
|
-
* @param parameters
|
|
1353
|
-
* @returns Promise\<GeolocateResponse\>
|
|
1354
|
-
*/
|
|
1355
|
-
;
|
|
1356
|
-
_proto.geolocate =
|
|
1357
|
-
/*#__PURE__*/
|
|
1358
|
-
function () {
|
|
1359
|
-
var _geolocate = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3(parameters) {
|
|
1360
|
-
var result;
|
|
1361
|
-
return _regeneratorRuntime().wrap(function _callee3$(_context3) {
|
|
1362
|
-
while (1) switch (_context3.prev = _context3.next) {
|
|
1363
|
-
case 0:
|
|
1364
|
-
_context3.next = 2;
|
|
1365
|
-
return this._client.get(this._url + "/geolocation", parameters);
|
|
1366
|
-
case 2:
|
|
1367
|
-
result = _context3.sent;
|
|
1368
|
-
if (!(Object.keys(result).length === 0)) {
|
|
1369
|
-
_context3.next = 5;
|
|
1370
|
-
break;
|
|
1371
|
-
}
|
|
1372
|
-
return _context3.abrupt("return", null);
|
|
1373
|
-
case 5:
|
|
1374
|
-
return _context3.abrupt("return", result);
|
|
1375
|
-
case 6:
|
|
1376
|
-
case "end":
|
|
1377
|
-
return _context3.stop();
|
|
1378
|
-
}
|
|
1379
|
-
}, _callee3, this);
|
|
1380
|
-
}));
|
|
1381
|
-
function geolocate(_x3) {
|
|
1382
|
-
return _geolocate.apply(this, arguments);
|
|
1383
|
-
}
|
|
1384
|
-
return geolocate;
|
|
1385
|
-
}()
|
|
1386
|
-
/**
|
|
1387
|
-
* **EXPERIMENTAL** -
|
|
1388
|
-
* This functionality is experimental and may change or stop working at any time.
|
|
1389
|
-
*
|
|
1390
|
-
* Looks up the provided URL or IP Address against various blacklists to see if the site has been
|
|
1391
|
-
* blacklisted anywhere.
|
|
1392
|
-
*
|
|
1393
|
-
* @param parameters
|
|
1394
|
-
* @returns Promise\<BlacklistResponse\>
|
|
1395
|
-
*/
|
|
1396
|
-
;
|
|
1397
|
-
_proto.checkBlacklist =
|
|
1398
|
-
/*#__PURE__*/
|
|
1399
|
-
function () {
|
|
1400
|
-
var _checkBlacklist = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4(parameters) {
|
|
1401
|
-
var result;
|
|
1402
|
-
return _regeneratorRuntime().wrap(function _callee4$(_context4) {
|
|
1403
|
-
while (1) switch (_context4.prev = _context4.next) {
|
|
1404
|
-
case 0:
|
|
1405
|
-
_context4.next = 2;
|
|
1406
|
-
return this._client.get(this._url + "/blacklist.json", parameters);
|
|
1407
|
-
case 2:
|
|
1408
|
-
result = _context4.sent;
|
|
1409
|
-
return _context4.abrupt("return", result);
|
|
1410
|
-
case 4:
|
|
1411
|
-
case "end":
|
|
1412
|
-
return _context4.stop();
|
|
1413
|
-
}
|
|
1414
|
-
}, _callee4, this);
|
|
1415
|
-
}));
|
|
1416
|
-
function checkBlacklist(_x4) {
|
|
1417
|
-
return _checkBlacklist.apply(this, arguments);
|
|
1418
|
-
}
|
|
1419
|
-
return checkBlacklist;
|
|
1420
|
-
}();
|
|
1421
|
-
return BentoExperimental;
|
|
1422
|
-
}();
|
|
1423
|
-
|
|
1424
|
-
var BentoFields = /*#__PURE__*/function () {
|
|
1425
|
-
function BentoFields(_client) {
|
|
1426
|
-
this._client = void 0;
|
|
1427
|
-
this._url = '/fetch/fields';
|
|
1428
|
-
this._client = _client;
|
|
1429
|
-
}
|
|
1430
|
-
/**
|
|
1431
|
-
* Returns all of the fields for the site.
|
|
1432
|
-
*
|
|
1433
|
-
* @returns Promise<Field[]>
|
|
1434
|
-
*/
|
|
1435
|
-
var _proto = BentoFields.prototype;
|
|
1436
|
-
_proto.getFields =
|
|
1437
|
-
/*#__PURE__*/
|
|
1438
|
-
function () {
|
|
1439
|
-
var _getFields = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
|
|
1440
|
-
var result;
|
|
1441
|
-
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
1442
|
-
while (1) switch (_context.prev = _context.next) {
|
|
1443
|
-
case 0:
|
|
1444
|
-
_context.next = 2;
|
|
1445
|
-
return this._client.get(this._url);
|
|
1446
|
-
case 2:
|
|
1447
|
-
result = _context.sent;
|
|
1448
|
-
if (!(Object.keys(result).length === 0 || !result.data)) {
|
|
1449
|
-
_context.next = 5;
|
|
1450
|
-
break;
|
|
1451
|
-
}
|
|
1452
|
-
return _context.abrupt("return", null);
|
|
1453
|
-
case 5:
|
|
1454
|
-
return _context.abrupt("return", result.data);
|
|
1455
|
-
case 6:
|
|
1456
|
-
case "end":
|
|
1457
|
-
return _context.stop();
|
|
1458
|
-
}
|
|
1459
|
-
}, _callee, this);
|
|
1460
|
-
}));
|
|
1461
|
-
function getFields() {
|
|
1462
|
-
return _getFields.apply(this, arguments);
|
|
1463
|
-
}
|
|
1464
|
-
return getFields;
|
|
1465
|
-
}()
|
|
1466
|
-
/**
|
|
1467
|
-
* Creates a field inside of Bento. The name of the field is automatically generated
|
|
1468
|
-
* from the key that is passed in upon creation. For example
|
|
1469
|
-
* - Key: `thisIsAKey`
|
|
1470
|
-
* Name: `This Is A Key`
|
|
1471
|
-
* - Key: `this is a key`
|
|
1472
|
-
* Name: `This Is A Key`
|
|
1473
|
-
* - Key: `this-is-a-key`
|
|
1474
|
-
* Name: `This Is A Key`
|
|
1475
|
-
* - Key: `this_is_a_key`
|
|
1476
|
-
* Name: `This Is A Key`
|
|
1477
|
-
*
|
|
1478
|
-
* @param parameters \{ key: string \}
|
|
1479
|
-
* @returns Promise<Field[]>
|
|
1480
|
-
*/
|
|
1481
|
-
;
|
|
1482
|
-
_proto.createField =
|
|
1483
|
-
/*#__PURE__*/
|
|
1484
|
-
function () {
|
|
1485
|
-
var _createField = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(parameters) {
|
|
1486
|
-
var result;
|
|
1487
|
-
return _regeneratorRuntime().wrap(function _callee2$(_context2) {
|
|
1488
|
-
while (1) switch (_context2.prev = _context2.next) {
|
|
1489
|
-
case 0:
|
|
1490
|
-
_context2.next = 2;
|
|
1491
|
-
return this._client.post(this._url, {
|
|
1492
|
-
field: parameters
|
|
1493
|
-
});
|
|
1494
|
-
case 2:
|
|
1495
|
-
result = _context2.sent;
|
|
1496
|
-
if (!(Object.keys(result).length === 0 || !result.data)) {
|
|
1497
|
-
_context2.next = 5;
|
|
1498
|
-
break;
|
|
1499
|
-
}
|
|
1500
|
-
return _context2.abrupt("return", null);
|
|
1501
|
-
case 5:
|
|
1502
|
-
return _context2.abrupt("return", result.data);
|
|
1503
|
-
case 6:
|
|
1504
|
-
case "end":
|
|
1505
|
-
return _context2.stop();
|
|
1506
|
-
}
|
|
1507
|
-
}, _callee2, this);
|
|
1508
|
-
}));
|
|
1509
|
-
function createField(_x) {
|
|
1510
|
-
return _createField.apply(this, arguments);
|
|
1511
|
-
}
|
|
1512
|
-
return createField;
|
|
1513
|
-
}();
|
|
1514
|
-
return BentoFields;
|
|
1515
|
-
}();
|
|
1516
|
-
|
|
1517
|
-
var BentoForms = /*#__PURE__*/function () {
|
|
1518
|
-
function BentoForms(_client) {
|
|
1519
|
-
this._client = void 0;
|
|
1520
|
-
this._url = '/fetch/responses';
|
|
1521
|
-
this._client = _client;
|
|
1522
|
-
}
|
|
1523
|
-
/**
|
|
1524
|
-
* Returns all of the responses for the form with the specified identifier.
|
|
1525
|
-
*
|
|
1526
|
-
* @param formIdentifier string
|
|
1527
|
-
* @returns Promise\<FormResponse[] | null\>
|
|
1528
|
-
*/
|
|
1529
|
-
var _proto = BentoForms.prototype;
|
|
1530
|
-
_proto.getResponses =
|
|
1531
|
-
/*#__PURE__*/
|
|
1532
|
-
function () {
|
|
1533
|
-
var _getResponses = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(formIdentifier) {
|
|
1534
|
-
var result;
|
|
1535
|
-
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
1536
|
-
while (1) switch (_context.prev = _context.next) {
|
|
1537
|
-
case 0:
|
|
1538
|
-
_context.next = 2;
|
|
1539
|
-
return this._client.get(this._url, {
|
|
1540
|
-
id: formIdentifier
|
|
1541
|
-
});
|
|
1542
|
-
case 2:
|
|
1543
|
-
result = _context.sent;
|
|
1544
|
-
if (!(Object.keys(result).length === 0 || !result.data)) {
|
|
1545
|
-
_context.next = 5;
|
|
1546
|
-
break;
|
|
1547
|
-
}
|
|
1548
|
-
return _context.abrupt("return", null);
|
|
1549
|
-
case 5:
|
|
1550
|
-
return _context.abrupt("return", result.data);
|
|
1551
|
-
case 6:
|
|
1552
|
-
case "end":
|
|
1553
|
-
return _context.stop();
|
|
1554
|
-
}
|
|
1555
|
-
}, _callee, this);
|
|
1556
|
-
}));
|
|
1557
|
-
function getResponses(_x) {
|
|
1558
|
-
return _getResponses.apply(this, arguments);
|
|
1559
|
-
}
|
|
1560
|
-
return getResponses;
|
|
1561
|
-
}();
|
|
1562
|
-
return BentoForms;
|
|
1563
|
-
}();
|
|
1564
|
-
|
|
1565
|
-
var BentoSubscribers = /*#__PURE__*/function () {
|
|
1566
|
-
function BentoSubscribers(_client) {
|
|
1567
|
-
this._client = void 0;
|
|
1568
|
-
this._url = '/fetch/subscribers';
|
|
1569
|
-
this._client = _client;
|
|
1570
|
-
}
|
|
1571
|
-
/**
|
|
1572
|
-
* Returns the subscriber with the specified email or UUID.
|
|
1573
|
-
*
|
|
1574
|
-
* @returns Promise\<Subscriber\<S\> | null\>
|
|
1575
|
-
*/
|
|
1576
|
-
var _proto = BentoSubscribers.prototype;
|
|
1577
|
-
_proto.getSubscribers =
|
|
1578
|
-
/*#__PURE__*/
|
|
1579
|
-
function () {
|
|
1580
|
-
var _getSubscribers = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(parameters) {
|
|
1581
|
-
var result;
|
|
1582
|
-
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
1583
|
-
while (1) switch (_context.prev = _context.next) {
|
|
1584
|
-
case 0:
|
|
1585
|
-
_context.next = 2;
|
|
1586
|
-
return this._client.get(this._url, parameters);
|
|
1587
|
-
case 2:
|
|
1588
|
-
result = _context.sent;
|
|
1589
|
-
if (!(Object.keys(result).length === 0 || !result.data)) {
|
|
1590
|
-
_context.next = 5;
|
|
1591
|
-
break;
|
|
1592
|
-
}
|
|
1593
|
-
return _context.abrupt("return", null);
|
|
1594
|
-
case 5:
|
|
1595
|
-
return _context.abrupt("return", result.data);
|
|
1596
|
-
case 6:
|
|
1597
|
-
case "end":
|
|
1598
|
-
return _context.stop();
|
|
1599
|
-
}
|
|
1600
|
-
}, _callee, this);
|
|
1601
|
-
}));
|
|
1602
|
-
function getSubscribers(_x) {
|
|
1603
|
-
return _getSubscribers.apply(this, arguments);
|
|
1604
|
-
}
|
|
1605
|
-
return getSubscribers;
|
|
1606
|
-
}()
|
|
1607
|
-
/**
|
|
1608
|
-
* Creates a subscriber inside of Bento.
|
|
1609
|
-
*
|
|
1610
|
-
* @param parameters CreateSubscriberParameters
|
|
1611
|
-
* @returns Promise\<Subscriber\<S\> | null\>
|
|
1612
|
-
*/
|
|
1613
|
-
;
|
|
1614
|
-
_proto.createSubscriber =
|
|
1615
|
-
/*#__PURE__*/
|
|
1616
|
-
function () {
|
|
1617
|
-
var _createSubscriber = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(parameters) {
|
|
1618
|
-
var result;
|
|
1619
|
-
return _regeneratorRuntime().wrap(function _callee2$(_context2) {
|
|
1620
|
-
while (1) switch (_context2.prev = _context2.next) {
|
|
1621
|
-
case 0:
|
|
1622
|
-
_context2.next = 2;
|
|
1623
|
-
return this._client.post(this._url, {
|
|
1624
|
-
subscriber: parameters
|
|
1625
|
-
});
|
|
1626
|
-
case 2:
|
|
1627
|
-
result = _context2.sent;
|
|
1628
|
-
if (!(Object.keys(result).length === 0 || !result.data)) {
|
|
1629
|
-
_context2.next = 5;
|
|
1630
|
-
break;
|
|
1631
|
-
}
|
|
1632
|
-
return _context2.abrupt("return", null);
|
|
1633
|
-
case 5:
|
|
1634
|
-
return _context2.abrupt("return", result.data);
|
|
1635
|
-
case 6:
|
|
1636
|
-
case "end":
|
|
1637
|
-
return _context2.stop();
|
|
1638
|
-
}
|
|
1639
|
-
}, _callee2, this);
|
|
1640
|
-
}));
|
|
1641
|
-
function createSubscriber(_x2) {
|
|
1642
|
-
return _createSubscriber.apply(this, arguments);
|
|
1643
|
-
}
|
|
1644
|
-
return createSubscriber;
|
|
1645
|
-
}();
|
|
1646
|
-
return BentoSubscribers;
|
|
1647
|
-
}();
|
|
1648
|
-
|
|
1649
|
-
var BentoTags = /*#__PURE__*/function () {
|
|
1650
|
-
function BentoTags(_client) {
|
|
1651
|
-
this._client = void 0;
|
|
1652
|
-
this._url = '/fetch/tags';
|
|
1653
|
-
this._client = _client;
|
|
1654
|
-
}
|
|
1655
|
-
/**
|
|
1656
|
-
* Returns all of the fields for the site.
|
|
1657
|
-
*
|
|
1658
|
-
* @returns Promise\<Tag[] | null\>
|
|
1659
|
-
*/
|
|
1660
|
-
var _proto = BentoTags.prototype;
|
|
1661
|
-
_proto.getTags =
|
|
1662
|
-
/*#__PURE__*/
|
|
1663
|
-
function () {
|
|
1664
|
-
var _getTags = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
|
|
1665
|
-
var result;
|
|
1666
|
-
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
1667
|
-
while (1) switch (_context.prev = _context.next) {
|
|
1668
|
-
case 0:
|
|
1669
|
-
_context.next = 2;
|
|
1670
|
-
return this._client.get(this._url);
|
|
1671
|
-
case 2:
|
|
1672
|
-
result = _context.sent;
|
|
1673
|
-
if (!(Object.keys(result).length === 0 || !result.data)) {
|
|
1674
|
-
_context.next = 5;
|
|
1675
|
-
break;
|
|
1676
|
-
}
|
|
1677
|
-
return _context.abrupt("return", null);
|
|
1678
|
-
case 5:
|
|
1679
|
-
return _context.abrupt("return", result.data);
|
|
1680
|
-
case 6:
|
|
1681
|
-
case "end":
|
|
1682
|
-
return _context.stop();
|
|
1683
|
-
}
|
|
1684
|
-
}, _callee, this);
|
|
1685
|
-
}));
|
|
1686
|
-
function getTags() {
|
|
1687
|
-
return _getTags.apply(this, arguments);
|
|
1688
|
-
}
|
|
1689
|
-
return getTags;
|
|
1690
|
-
}()
|
|
1691
|
-
/**
|
|
1692
|
-
* Creates a tag inside of Bento.
|
|
1693
|
-
*
|
|
1694
|
-
* @param parameters CreateTagParameters
|
|
1695
|
-
* @returns Promise\<Tag[] | null\>
|
|
1696
|
-
*/
|
|
1697
|
-
;
|
|
1698
|
-
_proto.createTag =
|
|
1699
|
-
/*#__PURE__*/
|
|
1700
|
-
function () {
|
|
1701
|
-
var _createTag = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(parameters) {
|
|
1702
|
-
var result;
|
|
1703
|
-
return _regeneratorRuntime().wrap(function _callee2$(_context2) {
|
|
1704
|
-
while (1) switch (_context2.prev = _context2.next) {
|
|
1705
|
-
case 0:
|
|
1706
|
-
_context2.next = 2;
|
|
1707
|
-
return this._client.post(this._url, {
|
|
1708
|
-
tag: parameters
|
|
1709
|
-
});
|
|
1710
|
-
case 2:
|
|
1711
|
-
result = _context2.sent;
|
|
1712
|
-
if (!(Object.keys(result).length === 0 || !result.data)) {
|
|
1713
|
-
_context2.next = 5;
|
|
1714
|
-
break;
|
|
1715
|
-
}
|
|
1716
|
-
return _context2.abrupt("return", null);
|
|
1717
|
-
case 5:
|
|
1718
|
-
return _context2.abrupt("return", result.data);
|
|
1719
|
-
case 6:
|
|
1720
|
-
case "end":
|
|
1721
|
-
return _context2.stop();
|
|
1722
|
-
}
|
|
1723
|
-
}, _callee2, this);
|
|
1724
|
-
}));
|
|
1725
|
-
function createTag(_x) {
|
|
1726
|
-
return _createTag.apply(this, arguments);
|
|
1727
|
-
}
|
|
1728
|
-
return createTag;
|
|
1729
|
-
}();
|
|
1730
|
-
return BentoTags;
|
|
1731
|
-
}();
|
|
1732
|
-
|
|
1733
|
-
var BentoEvents;
|
|
1734
|
-
(function (BentoEvents) {
|
|
1735
|
-
BentoEvents["PURCHASE"] = "$purchase";
|
|
1736
|
-
BentoEvents["SUBSCRIBE"] = "$subscribe";
|
|
1737
|
-
BentoEvents["TAG"] = "$tag";
|
|
1738
|
-
BentoEvents["REMOVE_TAG"] = "$remove_tag";
|
|
1739
|
-
BentoEvents["UNSUBSCRIBE"] = "$unsubscribe";
|
|
1740
|
-
BentoEvents["UPDATE_FIELDS"] = "$update_fields";
|
|
1741
|
-
})(BentoEvents || (BentoEvents = {}));
|
|
1742
|
-
|
|
1743
|
-
var BentoAPIV1 = /*#__PURE__*/function () {
|
|
1744
|
-
function BentoAPIV1(options) {
|
|
1745
|
-
this._client = void 0;
|
|
1746
|
-
this.Batch = void 0;
|
|
1747
|
-
this.Commands = void 0;
|
|
1748
|
-
this.Experimental = void 0;
|
|
1749
|
-
this.Fields = void 0;
|
|
1750
|
-
this.Forms = void 0;
|
|
1751
|
-
this.Subscribers = void 0;
|
|
1752
|
-
this.Tags = void 0;
|
|
1753
|
-
this._client = new BentoClient(options);
|
|
1754
|
-
this.Batch = new BentoBatch(this._client);
|
|
1755
|
-
this.Commands = new BentoCommands(this._client);
|
|
1756
|
-
this.Experimental = new BentoExperimental(this._client);
|
|
1757
|
-
this.Fields = new BentoFields(this._client);
|
|
1758
|
-
this.Forms = new BentoForms(this._client);
|
|
1759
|
-
this.Subscribers = new BentoSubscribers(this._client);
|
|
1760
|
-
this.Tags = new BentoTags(this._client);
|
|
1761
|
-
}
|
|
1762
|
-
/**
|
|
1763
|
-
* **This TRIGGERS automations!** - If you do not wish to trigger automations, please use the
|
|
1764
|
-
* `Commands.addTag` method.
|
|
1765
|
-
*
|
|
1766
|
-
* Tags a subscriber with the specified email and tag. If either the tag or the user
|
|
1767
|
-
* do not exist, they will be created in the system. If the user already has the tag,
|
|
1768
|
-
* another tag event will be sent, triggering any automations that take place upon a
|
|
1769
|
-
* tag being added to a subscriber. Please be aware of the potential consequences.
|
|
1770
|
-
*
|
|
1771
|
-
* Because this method uses the batch API, the tag may take between 1 and 3 minutes
|
|
1772
|
-
* to appear in the system.
|
|
1773
|
-
*
|
|
1774
|
-
* Returns `true` if the event was successfully dispatched. Returns `false` otherwise.
|
|
1775
|
-
*
|
|
1776
|
-
* @param parameters TagSubscriberParameters
|
|
1777
|
-
* @returns Promise\<boolean\>
|
|
1778
|
-
*/
|
|
1779
|
-
var _proto = BentoAPIV1.prototype;
|
|
1780
|
-
_proto.tagSubscriber =
|
|
1781
|
-
/*#__PURE__*/
|
|
1782
|
-
function () {
|
|
1783
|
-
var _tagSubscriber = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(parameters) {
|
|
1784
|
-
var result;
|
|
1785
|
-
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
1786
|
-
while (1) switch (_context.prev = _context.next) {
|
|
1787
|
-
case 0:
|
|
1788
|
-
_context.next = 2;
|
|
1789
|
-
return this.Batch.importEvents({
|
|
1790
|
-
events: [{
|
|
1791
|
-
date: parameters.date,
|
|
1792
|
-
details: {
|
|
1793
|
-
tag: parameters.tagName
|
|
1794
|
-
},
|
|
1795
|
-
email: parameters.email,
|
|
1796
|
-
type: BentoEvents.TAG
|
|
1797
|
-
}]
|
|
1798
|
-
});
|
|
1799
|
-
case 2:
|
|
1800
|
-
result = _context.sent;
|
|
1801
|
-
return _context.abrupt("return", result === 1);
|
|
1802
|
-
case 4:
|
|
1803
|
-
case "end":
|
|
1804
|
-
return _context.stop();
|
|
1805
|
-
}
|
|
1806
|
-
}, _callee, this);
|
|
1807
|
-
}));
|
|
1808
|
-
function tagSubscriber(_x) {
|
|
1809
|
-
return _tagSubscriber.apply(this, arguments);
|
|
1810
|
-
}
|
|
1811
|
-
return tagSubscriber;
|
|
1812
|
-
}()
|
|
1813
|
-
/**
|
|
1814
|
-
* **This TRIGGERS automations!** - If you do not wish to trigger automations, please use the
|
|
1815
|
-
* `Commands.subscribe` method.
|
|
1816
|
-
*
|
|
1817
|
-
* Creates a subscriber in the system. If the subscriber already exists, another subscribe event
|
|
1818
|
-
* will be sent, triggering any automations that take place upon subscription. Please be aware
|
|
1819
|
-
* of the potential consequences.
|
|
1820
|
-
*
|
|
1821
|
-
* You may optionally pass any fields that you wish to be set on the subscriber during creation
|
|
1822
|
-
* as well as a `Date` which will backdate the event. If no date is supplied, then the event will
|
|
1823
|
-
* default to the current time.
|
|
1824
|
-
*
|
|
1825
|
-
* Because this method uses the batch API, the tag may take between 1 and 3 minutes
|
|
1826
|
-
* to appear in the system.
|
|
1827
|
-
*
|
|
1828
|
-
* Returns `true` if the event was successfully dispatched. Returns `false` otherwise.
|
|
1829
|
-
*
|
|
1830
|
-
* @param parameters AddSubscriberParameters
|
|
1831
|
-
* @returns Promise\<boolean\>
|
|
1832
|
-
*/
|
|
1833
|
-
;
|
|
1834
|
-
_proto.addSubscriber =
|
|
1835
|
-
/*#__PURE__*/
|
|
1836
|
-
function () {
|
|
1837
|
-
var _addSubscriber = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(parameters) {
|
|
1838
|
-
var result;
|
|
1839
|
-
return _regeneratorRuntime().wrap(function _callee2$(_context2) {
|
|
1840
|
-
while (1) switch (_context2.prev = _context2.next) {
|
|
1841
|
-
case 0:
|
|
1842
|
-
_context2.next = 2;
|
|
1843
|
-
return this.Batch.importEvents({
|
|
1844
|
-
events: [{
|
|
1845
|
-
date: parameters.date,
|
|
1846
|
-
email: parameters.email,
|
|
1847
|
-
type: BentoEvents.SUBSCRIBE,
|
|
1848
|
-
fields: parameters.fields || {}
|
|
1849
|
-
}]
|
|
1850
|
-
});
|
|
1851
|
-
case 2:
|
|
1852
|
-
result = _context2.sent;
|
|
1853
|
-
return _context2.abrupt("return", result === 1);
|
|
1854
|
-
case 4:
|
|
1855
|
-
case "end":
|
|
1856
|
-
return _context2.stop();
|
|
1857
|
-
}
|
|
1858
|
-
}, _callee2, this);
|
|
1859
|
-
}));
|
|
1860
|
-
function addSubscriber(_x2) {
|
|
1861
|
-
return _addSubscriber.apply(this, arguments);
|
|
1862
|
-
}
|
|
1863
|
-
return addSubscriber;
|
|
1864
|
-
}()
|
|
1865
|
-
/**
|
|
1866
|
-
* **This TRIGGERS automations!** - If you do not wish to trigger automations, please use the
|
|
1867
|
-
* `Commands.unsubscribe` method.
|
|
1868
|
-
*
|
|
1869
|
-
* Unsubscribes an email in the system. If the email is already unsubscribed, another unsubscribe event
|
|
1870
|
-
* will be sent, triggering any automations that take place upon an unsubscribe happening. Please be aware
|
|
1871
|
-
* of the potential consequences.
|
|
1872
|
-
*
|
|
1873
|
-
* You may optionally pass a `Date` which will backdate the event. If no date is supplied, then the event
|
|
1874
|
-
* will default to the current time.
|
|
1875
|
-
*
|
|
1876
|
-
* Because this method uses the batch API, the tag may take between 1 and 3 minutes
|
|
1877
|
-
* to appear in the system.
|
|
1878
|
-
*
|
|
1879
|
-
* Returns `true` if the event was successfully dispatched. Returns `false` otherwise.
|
|
1880
|
-
*
|
|
1881
|
-
* @param parameters RemoveSubscriberParameters
|
|
1882
|
-
* @returns Promise\<boolean\>
|
|
1883
|
-
*/
|
|
1884
|
-
;
|
|
1885
|
-
_proto.removeSubscriber =
|
|
1886
|
-
/*#__PURE__*/
|
|
1887
|
-
function () {
|
|
1888
|
-
var _removeSubscriber = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3(parameters) {
|
|
1889
|
-
var result;
|
|
1890
|
-
return _regeneratorRuntime().wrap(function _callee3$(_context3) {
|
|
1891
|
-
while (1) switch (_context3.prev = _context3.next) {
|
|
1892
|
-
case 0:
|
|
1893
|
-
_context3.next = 2;
|
|
1894
|
-
return this.Batch.importEvents({
|
|
1895
|
-
events: [{
|
|
1896
|
-
date: parameters.date,
|
|
1897
|
-
email: parameters.email,
|
|
1898
|
-
type: BentoEvents.UNSUBSCRIBE
|
|
1899
|
-
}]
|
|
1900
|
-
});
|
|
1901
|
-
case 2:
|
|
1902
|
-
result = _context3.sent;
|
|
1903
|
-
return _context3.abrupt("return", result === 1);
|
|
1904
|
-
case 4:
|
|
1905
|
-
case "end":
|
|
1906
|
-
return _context3.stop();
|
|
1907
|
-
}
|
|
1908
|
-
}, _callee3, this);
|
|
1909
|
-
}));
|
|
1910
|
-
function removeSubscriber(_x3) {
|
|
1911
|
-
return _removeSubscriber.apply(this, arguments);
|
|
1912
|
-
}
|
|
1913
|
-
return removeSubscriber;
|
|
1914
|
-
}()
|
|
1915
|
-
/**
|
|
1916
|
-
* **This TRIGGERS automations!** - If you do not wish to trigger automations, please use the
|
|
1917
|
-
* `Commands.addField` method.
|
|
1918
|
-
*
|
|
1919
|
-
* Sets the passed-in custom fields on the subscriber, creating the subscriber if it does not exist.
|
|
1920
|
-
* If the fields are already set on the subscriber, the event will be sent, triggering any automations
|
|
1921
|
-
* that take place upon fields being updated. Please be aware of the potential consequences.
|
|
1922
|
-
*
|
|
1923
|
-
* You may optionally pass a `Date` which will backdate the event. If no date is supplied, then the event
|
|
1924
|
-
* will default to the current time.
|
|
1925
|
-
*
|
|
1926
|
-
* Because this method uses the batch API, the tag may take between 1 and 3 minutes
|
|
1927
|
-
* to appear in the system.
|
|
1928
|
-
*
|
|
1929
|
-
* Returns `true` if the event was successfully dispatched. Returns `false` otherwise.
|
|
1930
|
-
*
|
|
1931
|
-
* @param parameters UpdateFieldsParameters\<S\>
|
|
1932
|
-
* @returns Promise\<boolean\>
|
|
1933
|
-
*/
|
|
1934
|
-
;
|
|
1935
|
-
_proto.updateFields =
|
|
1936
|
-
/*#__PURE__*/
|
|
1937
|
-
function () {
|
|
1938
|
-
var _updateFields = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4(parameters) {
|
|
1939
|
-
var result;
|
|
1940
|
-
return _regeneratorRuntime().wrap(function _callee4$(_context4) {
|
|
1941
|
-
while (1) switch (_context4.prev = _context4.next) {
|
|
1942
|
-
case 0:
|
|
1943
|
-
_context4.next = 2;
|
|
1944
|
-
return this.Batch.importEvents({
|
|
1945
|
-
events: [{
|
|
1946
|
-
date: parameters.date,
|
|
1947
|
-
email: parameters.email,
|
|
1948
|
-
type: BentoEvents.UPDATE_FIELDS,
|
|
1949
|
-
fields: parameters.fields
|
|
1950
|
-
}]
|
|
1951
|
-
});
|
|
1952
|
-
case 2:
|
|
1953
|
-
result = _context4.sent;
|
|
1954
|
-
return _context4.abrupt("return", result === 1);
|
|
1955
|
-
case 4:
|
|
1956
|
-
case "end":
|
|
1957
|
-
return _context4.stop();
|
|
1958
|
-
}
|
|
1959
|
-
}, _callee4, this);
|
|
1960
|
-
}));
|
|
1961
|
-
function updateFields(_x4) {
|
|
1962
|
-
return _updateFields.apply(this, arguments);
|
|
1963
|
-
}
|
|
1964
|
-
return updateFields;
|
|
1965
|
-
}()
|
|
1966
|
-
/**
|
|
1967
|
-
* **This TRIGGERS automations!** - There is no way to achieve this same behavior without triggering
|
|
1968
|
-
* automations.
|
|
1969
|
-
*
|
|
1970
|
-
* Tracks a purchase in Bento, used to calculate LTV for your subscribers. The values that are received
|
|
1971
|
-
* should be numbers, in cents. For example, `$1.00` should be `100`.
|
|
1972
|
-
*
|
|
1973
|
-
* You may optionally pass a `Date` which will backdate the event. If no date is supplied, then the event
|
|
1974
|
-
* will default to the current time.
|
|
1975
|
-
*
|
|
1976
|
-
* Because this method uses the batch API, the tag may take between 1 and 3 minutes
|
|
1977
|
-
* to appear in the system.
|
|
1978
|
-
*
|
|
1979
|
-
* Returns `true` if the event was successfully dispatched. Returns `false` otherwise.
|
|
1980
|
-
*
|
|
1981
|
-
* @param parameters TrackPurchaseParameters
|
|
1982
|
-
* @returns Promise\<boolean\>
|
|
1983
|
-
*/
|
|
1984
|
-
;
|
|
1985
|
-
_proto.trackPurchase =
|
|
1986
|
-
/*#__PURE__*/
|
|
1987
|
-
function () {
|
|
1988
|
-
var _trackPurchase = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee5(parameters) {
|
|
1989
|
-
var result;
|
|
1990
|
-
return _regeneratorRuntime().wrap(function _callee5$(_context5) {
|
|
1991
|
-
while (1) switch (_context5.prev = _context5.next) {
|
|
1992
|
-
case 0:
|
|
1993
|
-
_context5.next = 2;
|
|
1994
|
-
return this.Batch.importEvents({
|
|
1995
|
-
events: [{
|
|
1996
|
-
date: parameters.date,
|
|
1997
|
-
email: parameters.email,
|
|
1998
|
-
type: BentoEvents.PURCHASE,
|
|
1999
|
-
details: parameters.purchaseDetails
|
|
2000
|
-
}]
|
|
2001
|
-
});
|
|
2002
|
-
case 2:
|
|
2003
|
-
result = _context5.sent;
|
|
2004
|
-
return _context5.abrupt("return", result === 1);
|
|
2005
|
-
case 4:
|
|
2006
|
-
case "end":
|
|
2007
|
-
return _context5.stop();
|
|
2008
|
-
}
|
|
2009
|
-
}, _callee5, this);
|
|
2010
|
-
}));
|
|
2011
|
-
function trackPurchase(_x5) {
|
|
2012
|
-
return _trackPurchase.apply(this, arguments);
|
|
2013
|
-
}
|
|
2014
|
-
return trackPurchase;
|
|
2015
|
-
}()
|
|
2016
|
-
/**
|
|
2017
|
-
* **This TRIGGERS automations!** - There is no way to achieve this same behavior without triggering
|
|
2018
|
-
* automations.
|
|
2019
|
-
*
|
|
2020
|
-
* Tracks a custom event in Bento.
|
|
2021
|
-
*
|
|
2022
|
-
* You may optionally pass a `Date` which will backdate the event. If no date is supplied, then the event
|
|
2023
|
-
* will default to the current time.
|
|
2024
|
-
*
|
|
2025
|
-
* Because this method uses the batch API, the tag may take between 1 and 3 minutes
|
|
2026
|
-
* to appear in the system.
|
|
2027
|
-
*
|
|
2028
|
-
* Returns `true` if the event was successfully dispatched. Returns `false` otherwise.
|
|
2029
|
-
*
|
|
2030
|
-
* @param parameters TrackParameters<S, E>
|
|
2031
|
-
* @returns Promise\<boolean\>
|
|
2032
|
-
*/
|
|
2033
|
-
;
|
|
2034
|
-
_proto.track =
|
|
2035
|
-
/*#__PURE__*/
|
|
2036
|
-
function () {
|
|
2037
|
-
var _track = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee6(parameters) {
|
|
2038
|
-
var result;
|
|
2039
|
-
return _regeneratorRuntime().wrap(function _callee6$(_context6) {
|
|
2040
|
-
while (1) switch (_context6.prev = _context6.next) {
|
|
2041
|
-
case 0:
|
|
2042
|
-
_context6.next = 2;
|
|
2043
|
-
return this.Batch.importEvents({
|
|
2044
|
-
events: [parameters]
|
|
2045
|
-
});
|
|
2046
|
-
case 2:
|
|
2047
|
-
result = _context6.sent;
|
|
2048
|
-
return _context6.abrupt("return", result === 1);
|
|
2049
|
-
case 4:
|
|
2050
|
-
case "end":
|
|
2051
|
-
return _context6.stop();
|
|
2052
|
-
}
|
|
2053
|
-
}, _callee6, this);
|
|
2054
|
-
}));
|
|
2055
|
-
function track(_x6) {
|
|
2056
|
-
return _track.apply(this, arguments);
|
|
2057
|
-
}
|
|
2058
|
-
return track;
|
|
2059
|
-
}();
|
|
2060
|
-
return BentoAPIV1;
|
|
2061
|
-
}();
|
|
2062
|
-
|
|
2063
|
-
var Analytics = function Analytics(options) {
|
|
2064
|
-
this.V1 = void 0;
|
|
2065
|
-
this.V1 = new BentoAPIV1(options);
|
|
2066
|
-
};
|
|
2067
|
-
|
|
2068
|
-
exports.Analytics = Analytics;
|
|
2069
|
-
exports.NotAuthorizedError = NotAuthorizedError;
|
|
2070
|
-
exports.RateLimitedError = RateLimitedError;
|
|
2071
|
-
//# sourceMappingURL=bento-node-sdk.cjs.development.js.map
|