@suprsend/node-sdk 1.8.1 → 1.8.2

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/dist/utils.js CHANGED
@@ -1,7 +1,6 @@
1
1
  "use strict";
2
2
 
3
3
  var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
-
5
4
  Object.defineProperty(exports, "__esModule", {
6
5
  value: true
7
6
  });
@@ -22,157 +21,103 @@ exports.uuid = uuid;
22
21
  exports.validate_list_broadcast_body_schema = validate_list_broadcast_body_schema;
23
22
  exports.validate_track_event_schema = validate_track_event_schema;
24
23
  exports.validate_workflow_body_schema = validate_workflow_body_schema;
25
-
26
24
  var _typeof2 = _interopRequireDefault(require("@babel/runtime/helpers/typeof"));
27
-
28
25
  var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
29
-
30
26
  var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits"));
31
-
32
27
  var _possibleConstructorReturn2 = _interopRequireDefault(require("@babel/runtime/helpers/possibleConstructorReturn"));
33
-
34
28
  var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime/helpers/getPrototypeOf"));
35
-
36
29
  var _wrapNativeSuper2 = _interopRequireDefault(require("@babel/runtime/helpers/wrapNativeSuper"));
37
-
38
30
  var _os = _interopRequireDefault(require("os"));
39
-
40
31
  var _fs = _interopRequireDefault(require("fs"));
41
-
42
32
  var _jsonschema = require("jsonschema");
43
-
44
33
  var _uuid = require("uuid");
45
-
46
34
  var _constants = require("./constants");
47
-
48
35
  var _lodash = require("lodash");
49
-
50
36
  function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it["return"] != null) it["return"](); } finally { if (didErr) throw err; } } }; }
51
-
52
37
  function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
53
-
54
38
  function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
55
-
56
39
  function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = (0, _getPrototypeOf2["default"])(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = (0, _getPrototypeOf2["default"])(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return (0, _possibleConstructorReturn2["default"])(this, result); }; }
57
-
58
40
  function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
59
-
60
41
  var workflow_schema = require("./request_json/workflow.json");
61
-
62
42
  var event_schema = require("./request_json/event.json");
63
-
64
43
  var list_broadcast_schema = require("./request_json/list_broadcast.json");
65
-
66
44
  function base64Encode(file) {
67
45
  var body = _fs["default"].readFileSync(file);
68
-
69
46
  return body.toString("base64");
70
47
  }
71
-
72
48
  function resolveTilde(filePath) {
73
49
  if (!filePath || typeof filePath !== "string") {
74
50
  return "";
75
51
  }
76
-
77
52
  if (filePath.startsWith("~/") || filePath === "~") {
78
53
  return filePath.replace("~", _os["default"].homedir());
79
54
  }
80
-
81
55
  return filePath;
82
56
  }
83
-
84
57
  var SuprsendError = /*#__PURE__*/function (_Error) {
85
58
  (0, _inherits2["default"])(SuprsendError, _Error);
86
-
87
59
  var _super = _createSuper(SuprsendError);
88
-
89
60
  function SuprsendError(message) {
90
61
  var _this;
91
-
92
62
  (0, _classCallCheck2["default"])(this, SuprsendError);
93
63
  _this = _super.call(this, message);
94
64
  _this.name = "SuprsendError";
95
65
  return _this;
96
66
  }
97
-
98
67
  return SuprsendError;
99
68
  }( /*#__PURE__*/(0, _wrapNativeSuper2["default"])(Error));
100
-
101
69
  exports.SuprsendError = SuprsendError;
102
-
103
70
  var SuprsendConfigError = /*#__PURE__*/function (_Error2) {
104
71
  (0, _inherits2["default"])(SuprsendConfigError, _Error2);
105
-
106
72
  var _super2 = _createSuper(SuprsendConfigError);
107
-
108
73
  function SuprsendConfigError(message) {
109
74
  var _this2;
110
-
111
75
  (0, _classCallCheck2["default"])(this, SuprsendConfigError);
112
76
  _this2 = _super2.call(this, message);
113
77
  _this2.name = "SuprsendConfigError";
114
78
  return _this2;
115
79
  }
116
-
117
80
  return SuprsendConfigError;
118
81
  }( /*#__PURE__*/(0, _wrapNativeSuper2["default"])(Error));
119
-
120
82
  exports.SuprsendConfigError = SuprsendConfigError;
121
-
122
83
  var SuprsendApiError = /*#__PURE__*/function (_Error3) {
123
84
  (0, _inherits2["default"])(SuprsendApiError, _Error3);
124
-
125
85
  var _super3 = _createSuper(SuprsendApiError);
126
-
127
86
  function SuprsendApiError(error) {
128
87
  var _this3;
129
-
130
88
  (0, _classCallCheck2["default"])(this, SuprsendApiError);
131
89
  var message;
132
-
133
90
  if (error.response) {
134
91
  message = "".concat(error.response.status, ": ").concat(error.response.data.message);
135
92
  } else {
136
93
  message = error.message;
137
94
  }
138
-
139
95
  _this3 = _super3.call(this, message);
140
96
  _this3.name = "SuprsendApiError";
141
97
  return _this3;
142
98
  }
143
-
144
99
  return SuprsendApiError;
145
100
  }( /*#__PURE__*/(0, _wrapNativeSuper2["default"])(Error));
146
-
147
101
  exports.SuprsendApiError = SuprsendApiError;
148
-
149
102
  var InputValueError = /*#__PURE__*/function (_Error4) {
150
103
  (0, _inherits2["default"])(InputValueError, _Error4);
151
-
152
104
  var _super4 = _createSuper(InputValueError);
153
-
154
105
  function InputValueError(message) {
155
106
  var _this4;
156
-
157
107
  (0, _classCallCheck2["default"])(this, InputValueError);
158
108
  _this4 = _super4.call(this, message);
159
109
  _this4.name = "InputValueError";
160
110
  return _this4;
161
111
  }
162
-
163
112
  return InputValueError;
164
113
  }( /*#__PURE__*/(0, _wrapNativeSuper2["default"])(Error));
165
-
166
114
  exports.InputValueError = InputValueError;
167
-
168
115
  function is_string(value) {
169
116
  return typeof value === "string";
170
117
  }
171
-
172
118
  function is_object(value) {
173
119
  return (0, _typeof2["default"])(value) === "object" && !Array.isArray(value) && value !== null;
174
120
  }
175
-
176
121
  function is_empty(value) {
177
122
  if (is_object(value)) {
178
123
  return Object.keys(value) <= 0;
@@ -182,36 +127,27 @@ function is_empty(value) {
182
127
  return !value;
183
128
  }
184
129
  }
185
-
186
130
  var has_special_char = function has_special_char(str) {
187
131
  var _str$toLowerCase;
188
-
189
132
  return str.startsWith("$") || (str === null || str === void 0 ? void 0 : (_str$toLowerCase = str.toLowerCase()) === null || _str$toLowerCase === void 0 ? void 0 : _str$toLowerCase.startsWith("ss_"));
190
133
  };
191
-
192
134
  exports.has_special_char = has_special_char;
193
-
194
135
  function uuid() {
195
136
  return (0, _uuid.v4)();
196
137
  }
197
-
198
138
  function epoch_milliseconds() {
199
139
  return Math.round(Date.now());
200
140
  }
201
-
202
141
  function validate_workflow_body_schema(body) {
203
142
  if (!(body !== null && body !== void 0 && body.data)) {
204
143
  body.data = {};
205
144
  }
206
-
207
145
  if (!(body.data instanceof Object)) {
208
146
  throw new InputValueError("data must be a object");
209
147
  }
210
-
211
148
  var schema = workflow_schema;
212
149
  var v = new _jsonschema.Validator();
213
150
  var validated_data = v.validate(body, schema);
214
-
215
151
  if (validated_data.valid) {
216
152
  return body;
217
153
  } else {
@@ -220,16 +156,13 @@ function validate_workflow_body_schema(body) {
220
156
  throw new SuprsendError(error_msg);
221
157
  }
222
158
  }
223
-
224
159
  function validate_track_event_schema(body) {
225
160
  if (!(body !== null && body !== void 0 && body.properties)) {
226
161
  body.properties = {};
227
162
  }
228
-
229
163
  var schema = event_schema;
230
164
  var v = new _jsonschema.Validator();
231
165
  var validated_data = v.validate(body, schema);
232
-
233
166
  if (validated_data.valid) {
234
167
  return body;
235
168
  } else {
@@ -238,20 +171,16 @@ function validate_track_event_schema(body) {
238
171
  throw new SuprsendError(error_msg);
239
172
  }
240
173
  }
241
-
242
174
  function validate_list_broadcast_body_schema(body) {
243
175
  if (!(body !== null && body !== void 0 && body.data)) {
244
176
  body.data = {};
245
177
  }
246
-
247
178
  if (!(body.data instanceof Object)) {
248
179
  throw new InputValueError("data must be a object");
249
180
  }
250
-
251
181
  var schema = list_broadcast_schema;
252
182
  var v = new _jsonschema.Validator();
253
183
  var validated_data = v.validate(body, schema);
254
-
255
184
  if (validated_data.valid) {
256
185
  return body;
257
186
  } else {
@@ -260,23 +189,18 @@ function validate_list_broadcast_body_schema(body) {
260
189
  throw new SuprsendError(error_msg);
261
190
  }
262
191
  }
263
-
264
192
  function get_apparent_workflow_body_size(body, is_part_of_bulk) {
265
193
  var extra_bytes = _constants.WORKFLOW_RUNTIME_KEYS_POTENTIAL_SIZE_IN_BYTES;
266
194
  var apparent_body = body;
267
-
268
195
  if (body !== null && body !== void 0 && body.data["$attachments"]) {
269
196
  var num_attachments = body.data["$attachments"].length;
270
-
271
197
  if (is_part_of_bulk) {
272
198
  if (_constants.ALLOW_ATTACHMENTS_IN_BULK_API) {
273
199
  if (_constants.ATTACHMENT_UPLOAD_ENABLED) {
274
200
  extra_bytes += num_attachments * _constants.ATTACHMENT_URL_POTENTIAL_SIZE_IN_BYTES;
275
201
  apparent_body = (0, _lodash.cloneDeep)(body);
276
-
277
202
  var _iterator = _createForOfIteratorHelper(apparent_body["data"]["$attachments"]),
278
- _step;
279
-
203
+ _step;
280
204
  try {
281
205
  for (_iterator.s(); !(_step = _iterator.n()).done;) {
282
206
  var attach_data = _step.value;
@@ -287,7 +211,8 @@ function get_apparent_workflow_body_size(body, is_part_of_bulk) {
287
211
  } finally {
288
212
  _iterator.f();
289
213
  }
290
- } else {// pass
214
+ } else {
215
+ // pass
291
216
  }
292
217
  } else {
293
218
  apparent_body = (0, _lodash.cloneDeep)(body);
@@ -297,10 +222,8 @@ function get_apparent_workflow_body_size(body, is_part_of_bulk) {
297
222
  if (_constants.ATTACHMENT_UPLOAD_ENABLED) {
298
223
  extra_bytes += num_attachments * _constants.ATTACHMENT_URL_POTENTIAL_SIZE_IN_BYTES;
299
224
  apparent_body = (0, _lodash.cloneDeep)(body);
300
-
301
225
  var _iterator2 = _createForOfIteratorHelper(apparent_body["data"]["$attachments"]),
302
- _step2;
303
-
226
+ _step2;
304
227
  try {
305
228
  for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
306
229
  var _attach_data = _step2.value;
@@ -311,34 +234,28 @@ function get_apparent_workflow_body_size(body, is_part_of_bulk) {
311
234
  } finally {
312
235
  _iterator2.f();
313
236
  }
314
- } else {// pass
237
+ } else {
238
+ // pass
315
239
  }
316
240
  }
317
241
  }
318
-
319
242
  var body_size = JSON.stringify(apparent_body).length;
320
243
  var apparent_body_size = body_size + extra_bytes;
321
244
  return apparent_body_size;
322
245
  }
323
-
324
246
  function get_apparent_event_size(event, is_part_of_bulk) {
325
247
  var _event$properties;
326
-
327
248
  var extra_bytes = 0;
328
249
  var apparent_body = event;
329
-
330
250
  if (event !== null && event !== void 0 && (_event$properties = event.properties) !== null && _event$properties !== void 0 && _event$properties["$attachments"]) {
331
251
  var num_attachments = event.properties["$attachments"].length;
332
-
333
252
  if (is_part_of_bulk) {
334
253
  if (_constants.ALLOW_ATTACHMENTS_IN_BULK_API) {
335
254
  if (_constants.ATTACHMENT_UPLOAD_ENABLED) {
336
255
  extra_bytes += num_attachments * _constants.ATTACHMENT_URL_POTENTIAL_SIZE_IN_BYTES;
337
256
  apparent_body = (0, _lodash.cloneDeep)(event);
338
-
339
257
  var _iterator3 = _createForOfIteratorHelper(apparent_body["properties"]["$attachments"]),
340
- _step3;
341
-
258
+ _step3;
342
259
  try {
343
260
  for (_iterator3.s(); !(_step3 = _iterator3.n()).done;) {
344
261
  var attach_data = _step3.value;
@@ -349,7 +266,8 @@ function get_apparent_event_size(event, is_part_of_bulk) {
349
266
  } finally {
350
267
  _iterator3.f();
351
268
  }
352
- } else {// pass
269
+ } else {
270
+ // pass
353
271
  }
354
272
  } else {
355
273
  apparent_body = (0, _lodash.cloneDeep)(body);
@@ -359,10 +277,8 @@ function get_apparent_event_size(event, is_part_of_bulk) {
359
277
  if (_constants.ATTACHMENT_UPLOAD_ENABLED) {
360
278
  extra_bytes += num_attachments * _constants.ATTACHMENT_URL_POTENTIAL_SIZE_IN_BYTES;
361
279
  apparent_body = (0, _lodash.cloneDeep)(body);
362
-
363
280
  var _iterator4 = _createForOfIteratorHelper(apparent_body["properties"]["$attachments"]),
364
- _step4;
365
-
281
+ _step4;
366
282
  try {
367
283
  for (_iterator4.s(); !(_step4 = _iterator4.n()).done;) {
368
284
  var _attach_data2 = _step4.value;
@@ -373,29 +289,25 @@ function get_apparent_event_size(event, is_part_of_bulk) {
373
289
  } finally {
374
290
  _iterator4.f();
375
291
  }
376
- } else {// pass
292
+ } else {
293
+ // pass
377
294
  }
378
295
  }
379
296
  }
380
-
381
297
  var body_size = JSON.stringify(apparent_body).length;
382
298
  var apparent_size = body_size + extra_bytes;
383
299
  return apparent_size;
384
300
  }
385
-
386
301
  function get_apparent_identity_event_size(event) {
387
302
  var body_size = JSON.stringify(event).length;
388
303
  return body_size;
389
304
  }
390
-
391
305
  function get_apparent_list_broadcast_body_size(body) {
392
306
  var body_size = JSON.stringify(body).length;
393
307
  return body_size;
394
308
  }
395
-
396
309
  function invalid_record_json(failed_record, err) {
397
310
  var err_str;
398
-
399
311
  if (err instanceof InputValueError) {
400
312
  err_str = err.message;
401
313
  } else {
@@ -403,7 +315,6 @@ function invalid_record_json(failed_record, err) {
403
315
  // OR any other error
404
316
  err_str = "".concat(err.message, "\n").concat(err.stack);
405
317
  }
406
-
407
318
  return {
408
319
  record: failed_record,
409
320
  error: err_str,
package/dist/workflow.js CHANGED
@@ -1,135 +1,99 @@
1
1
  "use strict";
2
2
 
3
3
  var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
-
5
4
  Object.defineProperty(exports, "__esModule", {
6
5
  value: true
7
6
  });
8
7
  exports["default"] = exports._WorkflowTrigger = void 0;
9
-
10
8
  var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
11
-
12
9
  var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
13
-
14
10
  var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
15
-
16
11
  var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
17
-
18
12
  var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
19
-
20
13
  var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
21
-
22
14
  var _axios = _interopRequireDefault(require("axios"));
23
-
24
15
  var _signature = _interopRequireDefault(require("./signature"));
25
-
26
16
  var _utils = require("./utils");
27
-
28
17
  var _attachment = _interopRequireDefault(require("./attachment"));
29
-
30
18
  var _constants = require("./constants");
31
-
32
19
  function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
33
-
34
20
  function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { (0, _defineProperty2["default"])(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
35
-
36
21
  var Workflow = /*#__PURE__*/function () {
37
22
  function Workflow(body) {
38
23
  var kwargs = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
39
24
  (0, _classCallCheck2["default"])(this, Workflow);
40
-
41
25
  if (!(body instanceof Object)) {
42
26
  throw new _utils.InputValueError("workflow body must be a json/dictionary");
43
27
  }
44
-
45
28
  this.body = body;
46
29
  this.idempotency_key = kwargs === null || kwargs === void 0 ? void 0 : kwargs.idempotency_key;
47
30
  this.brand_id = kwargs === null || kwargs === void 0 ? void 0 : kwargs.brand_id;
48
31
  }
49
-
50
32
  (0, _createClass2["default"])(Workflow, [{
51
33
  key: "add_attachment",
52
34
  value: function add_attachment() {
53
35
  var _kwargs$ignore_if_err, _this$body;
54
-
55
36
  var file_path = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : "";
56
37
  var kwargs = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
57
38
  var file_name = kwargs === null || kwargs === void 0 ? void 0 : kwargs.file_name;
58
39
  var ignore_if_error = (_kwargs$ignore_if_err = kwargs === null || kwargs === void 0 ? void 0 : kwargs.ignore_if_error) !== null && _kwargs$ignore_if_err !== void 0 ? _kwargs$ignore_if_err : false;
59
-
60
40
  if (!((_this$body = this.body) !== null && _this$body !== void 0 && _this$body.data)) {
61
41
  this.body.data = {};
62
- } // if body["data"] is not a dict, not raising error while adding attachment.
63
-
64
-
42
+ }
43
+ // if body["data"] is not a dict, not raising error while adding attachment.
65
44
  if (!(this.body["data"] instanceof Object)) {
66
45
  console.log("WARNING: attachment cannot be added. please make sure body['data'] is a dictionary. Workflow ".concat(JSON.stringify(this.as_json())));
67
46
  return;
68
47
  }
69
-
70
48
  var attachment = (0, _attachment["default"])(file_path, file_name, ignore_if_error);
71
-
72
49
  if (!attachment) {
73
50
  return;
74
51
  }
75
-
76
52
  if (!this.body.data["$attachments"]) {
77
53
  this.body["data"]["$attachments"] = [];
78
54
  }
79
-
80
55
  this.body["data"]["$attachments"].push(attachment);
81
56
  }
82
57
  }, {
83
58
  key: "get_final_json",
84
59
  value: function get_final_json(config) {
85
60
  var is_part_of_bulk = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
86
-
87
61
  // add idempotency key in body if present
88
62
  if (this.idempotency_key) {
89
63
  this.body["$idempotency_key"] = this.idempotency_key;
90
64
  }
91
-
92
65
  if (this.brand_id) {
93
66
  this.body["brand_id"] = this.brand_id;
94
67
  }
95
-
96
68
  this.body = (0, _utils.validate_workflow_body_schema)(this.body);
97
69
  var apparent_size = (0, _utils.get_apparent_workflow_body_size)(this.body, is_part_of_bulk); // review
98
-
99
70
  if (apparent_size > _constants.SINGLE_EVENT_MAX_APPARENT_SIZE_IN_BYTES) {
100
71
  throw new _utils.InputValueError("workflow body too big - ".concat(apparent_size, " Bytes, must not cross ").concat(_constants.SINGLE_EVENT_MAX_APPARENT_SIZE_IN_BYTES_READABLE));
101
72
  }
102
-
103
73
  return [this.body, apparent_size];
104
74
  }
105
75
  }, {
106
76
  key: "as_json",
107
77
  value: function as_json() {
108
78
  var body_dict = _objectSpread({}, this.body);
109
-
110
79
  if (this.idempotency_key) {
111
80
  body_dict["$idempotency_key"] = this.idempotency_key;
112
81
  }
113
-
114
82
  if (this.brand_id) {
115
83
  body_dict["brand_id"] = this.brand_id;
116
84
  }
117
-
118
85
  return body_dict;
119
86
  }
120
87
  }]);
121
88
  return Workflow;
122
89
  }();
123
-
124
90
  exports["default"] = Workflow;
125
-
126
91
  var _WorkflowTrigger = /*#__PURE__*/function () {
127
92
  function _WorkflowTrigger(config) {
128
93
  (0, _classCallCheck2["default"])(this, _WorkflowTrigger);
129
94
  this.config = config;
130
95
  this.url = this._get_url();
131
96
  }
132
-
133
97
  (0, _createClass2["default"])(_WorkflowTrigger, [{
134
98
  key: "_get_url",
135
99
  value: function _get_url() {
@@ -148,12 +112,10 @@ var _WorkflowTrigger = /*#__PURE__*/function () {
148
112
  key: "trigger",
149
113
  value: function trigger(workflow) {
150
114
  var is_part_of_bulk = false;
151
-
152
115
  var _workflow$get_final_j = workflow.get_final_json(this.config, is_part_of_bulk),
153
- _workflow$get_final_j2 = (0, _slicedToArray2["default"])(_workflow$get_final_j, 2),
154
- workflow_body = _workflow$get_final_j2[0],
155
- body_size = _workflow$get_final_j2[1];
156
-
116
+ _workflow$get_final_j2 = (0, _slicedToArray2["default"])(_workflow$get_final_j, 2),
117
+ workflow_body = _workflow$get_final_j2[0],
118
+ body_size = _workflow$get_final_j2[1];
157
119
  return this.send(workflow_body);
158
120
  }
159
121
  }, {
@@ -174,23 +136,19 @@ var _WorkflowTrigger = /*#__PURE__*/function () {
174
136
  return _axios["default"].post(this.url, content_text, {
175
137
  headers: headers
176
138
  });
177
-
178
139
  case 7:
179
140
  response = _context.sent;
180
141
  ok_response = Math.floor(response.status / 100) == 2;
181
-
182
142
  if (!ok_response) {
183
143
  _context.next = 13;
184
144
  break;
185
145
  }
186
-
187
146
  return _context.abrupt("return", {
188
147
  success: true,
189
148
  status: "success",
190
149
  status_code: response.status,
191
150
  message: response.statusText
192
151
  });
193
-
194
152
  case 13:
195
153
  return _context.abrupt("return", {
196
154
  success: false,
@@ -198,11 +156,9 @@ var _WorkflowTrigger = /*#__PURE__*/function () {
198
156
  status_code: response.status,
199
157
  message: response.statusText
200
158
  });
201
-
202
159
  case 14:
203
160
  _context.next = 19;
204
161
  break;
205
-
206
162
  case 16:
207
163
  _context.prev = 16;
208
164
  _context.t0 = _context["catch"](4);
@@ -212,7 +168,6 @@ var _WorkflowTrigger = /*#__PURE__*/function () {
212
168
  status_code: _context.t0.status || 500,
213
169
  message: _context.t0.message
214
170
  });
215
-
216
171
  case 19:
217
172
  case "end":
218
173
  return _context.stop();
@@ -220,15 +175,12 @@ var _WorkflowTrigger = /*#__PURE__*/function () {
220
175
  }
221
176
  }, _callee, this, [[4, 16]]);
222
177
  }));
223
-
224
178
  function send(_x) {
225
179
  return _send.apply(this, arguments);
226
180
  }
227
-
228
181
  return send;
229
182
  }()
230
183
  }]);
231
184
  return _WorkflowTrigger;
232
185
  }();
233
-
234
186
  exports._WorkflowTrigger = _WorkflowTrigger;