@sweepbright/api-client 0.26.2 → 0.27.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,6 +1,777 @@
1
1
  import axios from 'axios';
2
2
  import invariant from 'tiny-invariant';
3
3
 
4
+ function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
5
+ try {
6
+ var info = gen[key](arg);
7
+ var value = info.value;
8
+ } catch (error) {
9
+ reject(error);
10
+ return;
11
+ }
12
+
13
+ if (info.done) {
14
+ resolve(value);
15
+ } else {
16
+ Promise.resolve(value).then(_next, _throw);
17
+ }
18
+ }
19
+
20
+ function _asyncToGenerator(fn) {
21
+ return function () {
22
+ var self = this,
23
+ args = arguments;
24
+ return new Promise(function (resolve, reject) {
25
+ var gen = fn.apply(self, args);
26
+
27
+ function _next(value) {
28
+ asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value);
29
+ }
30
+
31
+ function _throw(err) {
32
+ asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err);
33
+ }
34
+
35
+ _next(undefined);
36
+ });
37
+ };
38
+ }
39
+
40
+ function createCommonjsModule(fn, module) {
41
+ return module = { exports: {} }, fn(module, module.exports), module.exports;
42
+ }
43
+
44
+ var runtime_1 = createCommonjsModule(function (module) {
45
+ /**
46
+ * Copyright (c) 2014-present, Facebook, Inc.
47
+ *
48
+ * This source code is licensed under the MIT license found in the
49
+ * LICENSE file in the root directory of this source tree.
50
+ */
51
+
52
+ var runtime = (function (exports) {
53
+
54
+ var Op = Object.prototype;
55
+ var hasOwn = Op.hasOwnProperty;
56
+ var undefined$1; // More compressible than void 0.
57
+ var $Symbol = typeof Symbol === "function" ? Symbol : {};
58
+ var iteratorSymbol = $Symbol.iterator || "@@iterator";
59
+ var asyncIteratorSymbol = $Symbol.asyncIterator || "@@asyncIterator";
60
+ var toStringTagSymbol = $Symbol.toStringTag || "@@toStringTag";
61
+
62
+ function wrap(innerFn, outerFn, self, tryLocsList) {
63
+ // If outerFn provided and outerFn.prototype is a Generator, then outerFn.prototype instanceof Generator.
64
+ var protoGenerator = outerFn && outerFn.prototype instanceof Generator ? outerFn : Generator;
65
+ var generator = Object.create(protoGenerator.prototype);
66
+ var context = new Context(tryLocsList || []);
67
+
68
+ // The ._invoke method unifies the implementations of the .next,
69
+ // .throw, and .return methods.
70
+ generator._invoke = makeInvokeMethod(innerFn, self, context);
71
+
72
+ return generator;
73
+ }
74
+ exports.wrap = wrap;
75
+
76
+ // Try/catch helper to minimize deoptimizations. Returns a completion
77
+ // record like context.tryEntries[i].completion. This interface could
78
+ // have been (and was previously) designed to take a closure to be
79
+ // invoked without arguments, but in all the cases we care about we
80
+ // already have an existing method we want to call, so there's no need
81
+ // to create a new function object. We can even get away with assuming
82
+ // the method takes exactly one argument, since that happens to be true
83
+ // in every case, so we don't have to touch the arguments object. The
84
+ // only additional allocation required is the completion record, which
85
+ // has a stable shape and so hopefully should be cheap to allocate.
86
+ function tryCatch(fn, obj, arg) {
87
+ try {
88
+ return { type: "normal", arg: fn.call(obj, arg) };
89
+ } catch (err) {
90
+ return { type: "throw", arg: err };
91
+ }
92
+ }
93
+
94
+ var GenStateSuspendedStart = "suspendedStart";
95
+ var GenStateSuspendedYield = "suspendedYield";
96
+ var GenStateExecuting = "executing";
97
+ var GenStateCompleted = "completed";
98
+
99
+ // Returning this object from the innerFn has the same effect as
100
+ // breaking out of the dispatch switch statement.
101
+ var ContinueSentinel = {};
102
+
103
+ // Dummy constructor functions that we use as the .constructor and
104
+ // .constructor.prototype properties for functions that return Generator
105
+ // objects. For full spec compliance, you may wish to configure your
106
+ // minifier not to mangle the names of these two functions.
107
+ function Generator() {}
108
+ function GeneratorFunction() {}
109
+ function GeneratorFunctionPrototype() {}
110
+
111
+ // This is a polyfill for %IteratorPrototype% for environments that
112
+ // don't natively support it.
113
+ var IteratorPrototype = {};
114
+ IteratorPrototype[iteratorSymbol] = function () {
115
+ return this;
116
+ };
117
+
118
+ var getProto = Object.getPrototypeOf;
119
+ var NativeIteratorPrototype = getProto && getProto(getProto(values([])));
120
+ if (NativeIteratorPrototype &&
121
+ NativeIteratorPrototype !== Op &&
122
+ hasOwn.call(NativeIteratorPrototype, iteratorSymbol)) {
123
+ // This environment has a native %IteratorPrototype%; use it instead
124
+ // of the polyfill.
125
+ IteratorPrototype = NativeIteratorPrototype;
126
+ }
127
+
128
+ var Gp = GeneratorFunctionPrototype.prototype =
129
+ Generator.prototype = Object.create(IteratorPrototype);
130
+ GeneratorFunction.prototype = Gp.constructor = GeneratorFunctionPrototype;
131
+ GeneratorFunctionPrototype.constructor = GeneratorFunction;
132
+ GeneratorFunctionPrototype[toStringTagSymbol] =
133
+ GeneratorFunction.displayName = "GeneratorFunction";
134
+
135
+ // Helper for defining the .next, .throw, and .return methods of the
136
+ // Iterator interface in terms of a single ._invoke method.
137
+ function defineIteratorMethods(prototype) {
138
+ ["next", "throw", "return"].forEach(function(method) {
139
+ prototype[method] = function(arg) {
140
+ return this._invoke(method, arg);
141
+ };
142
+ });
143
+ }
144
+
145
+ exports.isGeneratorFunction = function(genFun) {
146
+ var ctor = typeof genFun === "function" && genFun.constructor;
147
+ return ctor
148
+ ? ctor === GeneratorFunction ||
149
+ // For the native GeneratorFunction constructor, the best we can
150
+ // do is to check its .name property.
151
+ (ctor.displayName || ctor.name) === "GeneratorFunction"
152
+ : false;
153
+ };
154
+
155
+ exports.mark = function(genFun) {
156
+ if (Object.setPrototypeOf) {
157
+ Object.setPrototypeOf(genFun, GeneratorFunctionPrototype);
158
+ } else {
159
+ genFun.__proto__ = GeneratorFunctionPrototype;
160
+ if (!(toStringTagSymbol in genFun)) {
161
+ genFun[toStringTagSymbol] = "GeneratorFunction";
162
+ }
163
+ }
164
+ genFun.prototype = Object.create(Gp);
165
+ return genFun;
166
+ };
167
+
168
+ // Within the body of any async function, `await x` is transformed to
169
+ // `yield regeneratorRuntime.awrap(x)`, so that the runtime can test
170
+ // `hasOwn.call(value, "__await")` to determine if the yielded value is
171
+ // meant to be awaited.
172
+ exports.awrap = function(arg) {
173
+ return { __await: arg };
174
+ };
175
+
176
+ function AsyncIterator(generator, PromiseImpl) {
177
+ function invoke(method, arg, resolve, reject) {
178
+ var record = tryCatch(generator[method], generator, arg);
179
+ if (record.type === "throw") {
180
+ reject(record.arg);
181
+ } else {
182
+ var result = record.arg;
183
+ var value = result.value;
184
+ if (value &&
185
+ typeof value === "object" &&
186
+ hasOwn.call(value, "__await")) {
187
+ return PromiseImpl.resolve(value.__await).then(function(value) {
188
+ invoke("next", value, resolve, reject);
189
+ }, function(err) {
190
+ invoke("throw", err, resolve, reject);
191
+ });
192
+ }
193
+
194
+ return PromiseImpl.resolve(value).then(function(unwrapped) {
195
+ // When a yielded Promise is resolved, its final value becomes
196
+ // the .value of the Promise<{value,done}> result for the
197
+ // current iteration.
198
+ result.value = unwrapped;
199
+ resolve(result);
200
+ }, function(error) {
201
+ // If a rejected Promise was yielded, throw the rejection back
202
+ // into the async generator function so it can be handled there.
203
+ return invoke("throw", error, resolve, reject);
204
+ });
205
+ }
206
+ }
207
+
208
+ var previousPromise;
209
+
210
+ function enqueue(method, arg) {
211
+ function callInvokeWithMethodAndArg() {
212
+ return new PromiseImpl(function(resolve, reject) {
213
+ invoke(method, arg, resolve, reject);
214
+ });
215
+ }
216
+
217
+ return previousPromise =
218
+ // If enqueue has been called before, then we want to wait until
219
+ // all previous Promises have been resolved before calling invoke,
220
+ // so that results are always delivered in the correct order. If
221
+ // enqueue has not been called before, then it is important to
222
+ // call invoke immediately, without waiting on a callback to fire,
223
+ // so that the async generator function has the opportunity to do
224
+ // any necessary setup in a predictable way. This predictability
225
+ // is why the Promise constructor synchronously invokes its
226
+ // executor callback, and why async functions synchronously
227
+ // execute code before the first await. Since we implement simple
228
+ // async functions in terms of async generators, it is especially
229
+ // important to get this right, even though it requires care.
230
+ previousPromise ? previousPromise.then(
231
+ callInvokeWithMethodAndArg,
232
+ // Avoid propagating failures to Promises returned by later
233
+ // invocations of the iterator.
234
+ callInvokeWithMethodAndArg
235
+ ) : callInvokeWithMethodAndArg();
236
+ }
237
+
238
+ // Define the unified helper method that is used to implement .next,
239
+ // .throw, and .return (see defineIteratorMethods).
240
+ this._invoke = enqueue;
241
+ }
242
+
243
+ defineIteratorMethods(AsyncIterator.prototype);
244
+ AsyncIterator.prototype[asyncIteratorSymbol] = function () {
245
+ return this;
246
+ };
247
+ exports.AsyncIterator = AsyncIterator;
248
+
249
+ // Note that simple async functions are implemented on top of
250
+ // AsyncIterator objects; they just return a Promise for the value of
251
+ // the final result produced by the iterator.
252
+ exports.async = function(innerFn, outerFn, self, tryLocsList, PromiseImpl) {
253
+ if (PromiseImpl === void 0) PromiseImpl = Promise;
254
+
255
+ var iter = new AsyncIterator(
256
+ wrap(innerFn, outerFn, self, tryLocsList),
257
+ PromiseImpl
258
+ );
259
+
260
+ return exports.isGeneratorFunction(outerFn)
261
+ ? iter // If outerFn is a generator, return the full iterator.
262
+ : iter.next().then(function(result) {
263
+ return result.done ? result.value : iter.next();
264
+ });
265
+ };
266
+
267
+ function makeInvokeMethod(innerFn, self, context) {
268
+ var state = GenStateSuspendedStart;
269
+
270
+ return function invoke(method, arg) {
271
+ if (state === GenStateExecuting) {
272
+ throw new Error("Generator is already running");
273
+ }
274
+
275
+ if (state === GenStateCompleted) {
276
+ if (method === "throw") {
277
+ throw arg;
278
+ }
279
+
280
+ // Be forgiving, per 25.3.3.3.3 of the spec:
281
+ // https://people.mozilla.org/~jorendorff/es6-draft.html#sec-generatorresume
282
+ return doneResult();
283
+ }
284
+
285
+ context.method = method;
286
+ context.arg = arg;
287
+
288
+ while (true) {
289
+ var delegate = context.delegate;
290
+ if (delegate) {
291
+ var delegateResult = maybeInvokeDelegate(delegate, context);
292
+ if (delegateResult) {
293
+ if (delegateResult === ContinueSentinel) continue;
294
+ return delegateResult;
295
+ }
296
+ }
297
+
298
+ if (context.method === "next") {
299
+ // Setting context._sent for legacy support of Babel's
300
+ // function.sent implementation.
301
+ context.sent = context._sent = context.arg;
302
+
303
+ } else if (context.method === "throw") {
304
+ if (state === GenStateSuspendedStart) {
305
+ state = GenStateCompleted;
306
+ throw context.arg;
307
+ }
308
+
309
+ context.dispatchException(context.arg);
310
+
311
+ } else if (context.method === "return") {
312
+ context.abrupt("return", context.arg);
313
+ }
314
+
315
+ state = GenStateExecuting;
316
+
317
+ var record = tryCatch(innerFn, self, context);
318
+ if (record.type === "normal") {
319
+ // If an exception is thrown from innerFn, we leave state ===
320
+ // GenStateExecuting and loop back for another invocation.
321
+ state = context.done
322
+ ? GenStateCompleted
323
+ : GenStateSuspendedYield;
324
+
325
+ if (record.arg === ContinueSentinel) {
326
+ continue;
327
+ }
328
+
329
+ return {
330
+ value: record.arg,
331
+ done: context.done
332
+ };
333
+
334
+ } else if (record.type === "throw") {
335
+ state = GenStateCompleted;
336
+ // Dispatch the exception by looping back around to the
337
+ // context.dispatchException(context.arg) call above.
338
+ context.method = "throw";
339
+ context.arg = record.arg;
340
+ }
341
+ }
342
+ };
343
+ }
344
+
345
+ // Call delegate.iterator[context.method](context.arg) and handle the
346
+ // result, either by returning a { value, done } result from the
347
+ // delegate iterator, or by modifying context.method and context.arg,
348
+ // setting context.delegate to null, and returning the ContinueSentinel.
349
+ function maybeInvokeDelegate(delegate, context) {
350
+ var method = delegate.iterator[context.method];
351
+ if (method === undefined$1) {
352
+ // A .throw or .return when the delegate iterator has no .throw
353
+ // method always terminates the yield* loop.
354
+ context.delegate = null;
355
+
356
+ if (context.method === "throw") {
357
+ // Note: ["return"] must be used for ES3 parsing compatibility.
358
+ if (delegate.iterator["return"]) {
359
+ // If the delegate iterator has a return method, give it a
360
+ // chance to clean up.
361
+ context.method = "return";
362
+ context.arg = undefined$1;
363
+ maybeInvokeDelegate(delegate, context);
364
+
365
+ if (context.method === "throw") {
366
+ // If maybeInvokeDelegate(context) changed context.method from
367
+ // "return" to "throw", let that override the TypeError below.
368
+ return ContinueSentinel;
369
+ }
370
+ }
371
+
372
+ context.method = "throw";
373
+ context.arg = new TypeError(
374
+ "The iterator does not provide a 'throw' method");
375
+ }
376
+
377
+ return ContinueSentinel;
378
+ }
379
+
380
+ var record = tryCatch(method, delegate.iterator, context.arg);
381
+
382
+ if (record.type === "throw") {
383
+ context.method = "throw";
384
+ context.arg = record.arg;
385
+ context.delegate = null;
386
+ return ContinueSentinel;
387
+ }
388
+
389
+ var info = record.arg;
390
+
391
+ if (! info) {
392
+ context.method = "throw";
393
+ context.arg = new TypeError("iterator result is not an object");
394
+ context.delegate = null;
395
+ return ContinueSentinel;
396
+ }
397
+
398
+ if (info.done) {
399
+ // Assign the result of the finished delegate to the temporary
400
+ // variable specified by delegate.resultName (see delegateYield).
401
+ context[delegate.resultName] = info.value;
402
+
403
+ // Resume execution at the desired location (see delegateYield).
404
+ context.next = delegate.nextLoc;
405
+
406
+ // If context.method was "throw" but the delegate handled the
407
+ // exception, let the outer generator proceed normally. If
408
+ // context.method was "next", forget context.arg since it has been
409
+ // "consumed" by the delegate iterator. If context.method was
410
+ // "return", allow the original .return call to continue in the
411
+ // outer generator.
412
+ if (context.method !== "return") {
413
+ context.method = "next";
414
+ context.arg = undefined$1;
415
+ }
416
+
417
+ } else {
418
+ // Re-yield the result returned by the delegate method.
419
+ return info;
420
+ }
421
+
422
+ // The delegate iterator is finished, so forget it and continue with
423
+ // the outer generator.
424
+ context.delegate = null;
425
+ return ContinueSentinel;
426
+ }
427
+
428
+ // Define Generator.prototype.{next,throw,return} in terms of the
429
+ // unified ._invoke helper method.
430
+ defineIteratorMethods(Gp);
431
+
432
+ Gp[toStringTagSymbol] = "Generator";
433
+
434
+ // A Generator should always return itself as the iterator object when the
435
+ // @@iterator function is called on it. Some browsers' implementations of the
436
+ // iterator prototype chain incorrectly implement this, causing the Generator
437
+ // object to not be returned from this call. This ensures that doesn't happen.
438
+ // See https://github.com/facebook/regenerator/issues/274 for more details.
439
+ Gp[iteratorSymbol] = function() {
440
+ return this;
441
+ };
442
+
443
+ Gp.toString = function() {
444
+ return "[object Generator]";
445
+ };
446
+
447
+ function pushTryEntry(locs) {
448
+ var entry = { tryLoc: locs[0] };
449
+
450
+ if (1 in locs) {
451
+ entry.catchLoc = locs[1];
452
+ }
453
+
454
+ if (2 in locs) {
455
+ entry.finallyLoc = locs[2];
456
+ entry.afterLoc = locs[3];
457
+ }
458
+
459
+ this.tryEntries.push(entry);
460
+ }
461
+
462
+ function resetTryEntry(entry) {
463
+ var record = entry.completion || {};
464
+ record.type = "normal";
465
+ delete record.arg;
466
+ entry.completion = record;
467
+ }
468
+
469
+ function Context(tryLocsList) {
470
+ // The root entry object (effectively a try statement without a catch
471
+ // or a finally block) gives us a place to store values thrown from
472
+ // locations where there is no enclosing try statement.
473
+ this.tryEntries = [{ tryLoc: "root" }];
474
+ tryLocsList.forEach(pushTryEntry, this);
475
+ this.reset(true);
476
+ }
477
+
478
+ exports.keys = function(object) {
479
+ var keys = [];
480
+ for (var key in object) {
481
+ keys.push(key);
482
+ }
483
+ keys.reverse();
484
+
485
+ // Rather than returning an object with a next method, we keep
486
+ // things simple and return the next function itself.
487
+ return function next() {
488
+ while (keys.length) {
489
+ var key = keys.pop();
490
+ if (key in object) {
491
+ next.value = key;
492
+ next.done = false;
493
+ return next;
494
+ }
495
+ }
496
+
497
+ // To avoid creating an additional object, we just hang the .value
498
+ // and .done properties off the next function object itself. This
499
+ // also ensures that the minifier will not anonymize the function.
500
+ next.done = true;
501
+ return next;
502
+ };
503
+ };
504
+
505
+ function values(iterable) {
506
+ if (iterable) {
507
+ var iteratorMethod = iterable[iteratorSymbol];
508
+ if (iteratorMethod) {
509
+ return iteratorMethod.call(iterable);
510
+ }
511
+
512
+ if (typeof iterable.next === "function") {
513
+ return iterable;
514
+ }
515
+
516
+ if (!isNaN(iterable.length)) {
517
+ var i = -1, next = function next() {
518
+ while (++i < iterable.length) {
519
+ if (hasOwn.call(iterable, i)) {
520
+ next.value = iterable[i];
521
+ next.done = false;
522
+ return next;
523
+ }
524
+ }
525
+
526
+ next.value = undefined$1;
527
+ next.done = true;
528
+
529
+ return next;
530
+ };
531
+
532
+ return next.next = next;
533
+ }
534
+ }
535
+
536
+ // Return an iterator with no values.
537
+ return { next: doneResult };
538
+ }
539
+ exports.values = values;
540
+
541
+ function doneResult() {
542
+ return { value: undefined$1, done: true };
543
+ }
544
+
545
+ Context.prototype = {
546
+ constructor: Context,
547
+
548
+ reset: function(skipTempReset) {
549
+ this.prev = 0;
550
+ this.next = 0;
551
+ // Resetting context._sent for legacy support of Babel's
552
+ // function.sent implementation.
553
+ this.sent = this._sent = undefined$1;
554
+ this.done = false;
555
+ this.delegate = null;
556
+
557
+ this.method = "next";
558
+ this.arg = undefined$1;
559
+
560
+ this.tryEntries.forEach(resetTryEntry);
561
+
562
+ if (!skipTempReset) {
563
+ for (var name in this) {
564
+ // Not sure about the optimal order of these conditions:
565
+ if (name.charAt(0) === "t" &&
566
+ hasOwn.call(this, name) &&
567
+ !isNaN(+name.slice(1))) {
568
+ this[name] = undefined$1;
569
+ }
570
+ }
571
+ }
572
+ },
573
+
574
+ stop: function() {
575
+ this.done = true;
576
+
577
+ var rootEntry = this.tryEntries[0];
578
+ var rootRecord = rootEntry.completion;
579
+ if (rootRecord.type === "throw") {
580
+ throw rootRecord.arg;
581
+ }
582
+
583
+ return this.rval;
584
+ },
585
+
586
+ dispatchException: function(exception) {
587
+ if (this.done) {
588
+ throw exception;
589
+ }
590
+
591
+ var context = this;
592
+ function handle(loc, caught) {
593
+ record.type = "throw";
594
+ record.arg = exception;
595
+ context.next = loc;
596
+
597
+ if (caught) {
598
+ // If the dispatched exception was caught by a catch block,
599
+ // then let that catch block handle the exception normally.
600
+ context.method = "next";
601
+ context.arg = undefined$1;
602
+ }
603
+
604
+ return !! caught;
605
+ }
606
+
607
+ for (var i = this.tryEntries.length - 1; i >= 0; --i) {
608
+ var entry = this.tryEntries[i];
609
+ var record = entry.completion;
610
+
611
+ if (entry.tryLoc === "root") {
612
+ // Exception thrown outside of any try block that could handle
613
+ // it, so set the completion value of the entire function to
614
+ // throw the exception.
615
+ return handle("end");
616
+ }
617
+
618
+ if (entry.tryLoc <= this.prev) {
619
+ var hasCatch = hasOwn.call(entry, "catchLoc");
620
+ var hasFinally = hasOwn.call(entry, "finallyLoc");
621
+
622
+ if (hasCatch && hasFinally) {
623
+ if (this.prev < entry.catchLoc) {
624
+ return handle(entry.catchLoc, true);
625
+ } else if (this.prev < entry.finallyLoc) {
626
+ return handle(entry.finallyLoc);
627
+ }
628
+
629
+ } else if (hasCatch) {
630
+ if (this.prev < entry.catchLoc) {
631
+ return handle(entry.catchLoc, true);
632
+ }
633
+
634
+ } else if (hasFinally) {
635
+ if (this.prev < entry.finallyLoc) {
636
+ return handle(entry.finallyLoc);
637
+ }
638
+
639
+ } else {
640
+ throw new Error("try statement without catch or finally");
641
+ }
642
+ }
643
+ }
644
+ },
645
+
646
+ abrupt: function(type, arg) {
647
+ for (var i = this.tryEntries.length - 1; i >= 0; --i) {
648
+ var entry = this.tryEntries[i];
649
+ if (entry.tryLoc <= this.prev &&
650
+ hasOwn.call(entry, "finallyLoc") &&
651
+ this.prev < entry.finallyLoc) {
652
+ var finallyEntry = entry;
653
+ break;
654
+ }
655
+ }
656
+
657
+ if (finallyEntry &&
658
+ (type === "break" ||
659
+ type === "continue") &&
660
+ finallyEntry.tryLoc <= arg &&
661
+ arg <= finallyEntry.finallyLoc) {
662
+ // Ignore the finally entry if control is not jumping to a
663
+ // location outside the try/catch block.
664
+ finallyEntry = null;
665
+ }
666
+
667
+ var record = finallyEntry ? finallyEntry.completion : {};
668
+ record.type = type;
669
+ record.arg = arg;
670
+
671
+ if (finallyEntry) {
672
+ this.method = "next";
673
+ this.next = finallyEntry.finallyLoc;
674
+ return ContinueSentinel;
675
+ }
676
+
677
+ return this.complete(record);
678
+ },
679
+
680
+ complete: function(record, afterLoc) {
681
+ if (record.type === "throw") {
682
+ throw record.arg;
683
+ }
684
+
685
+ if (record.type === "break" ||
686
+ record.type === "continue") {
687
+ this.next = record.arg;
688
+ } else if (record.type === "return") {
689
+ this.rval = this.arg = record.arg;
690
+ this.method = "return";
691
+ this.next = "end";
692
+ } else if (record.type === "normal" && afterLoc) {
693
+ this.next = afterLoc;
694
+ }
695
+
696
+ return ContinueSentinel;
697
+ },
698
+
699
+ finish: function(finallyLoc) {
700
+ for (var i = this.tryEntries.length - 1; i >= 0; --i) {
701
+ var entry = this.tryEntries[i];
702
+ if (entry.finallyLoc === finallyLoc) {
703
+ this.complete(entry.completion, entry.afterLoc);
704
+ resetTryEntry(entry);
705
+ return ContinueSentinel;
706
+ }
707
+ }
708
+ },
709
+
710
+ "catch": function(tryLoc) {
711
+ for (var i = this.tryEntries.length - 1; i >= 0; --i) {
712
+ var entry = this.tryEntries[i];
713
+ if (entry.tryLoc === tryLoc) {
714
+ var record = entry.completion;
715
+ if (record.type === "throw") {
716
+ var thrown = record.arg;
717
+ resetTryEntry(entry);
718
+ }
719
+ return thrown;
720
+ }
721
+ }
722
+
723
+ // The context.catch method must only be called with a location
724
+ // argument that corresponds to a known catch block.
725
+ throw new Error("illegal catch attempt");
726
+ },
727
+
728
+ delegateYield: function(iterable, resultName, nextLoc) {
729
+ this.delegate = {
730
+ iterator: values(iterable),
731
+ resultName: resultName,
732
+ nextLoc: nextLoc
733
+ };
734
+
735
+ if (this.method === "next") {
736
+ // Deliberately forget the last sent value so that we don't
737
+ // accidentally pass it on to the delegate.
738
+ this.arg = undefined$1;
739
+ }
740
+
741
+ return ContinueSentinel;
742
+ }
743
+ };
744
+
745
+ // Regardless of whether this script is executing as a CommonJS module
746
+ // or not, return the runtime object so that we can declare the variable
747
+ // regeneratorRuntime in the outer scope, which allows this module to be
748
+ // injected easily by `bin/regenerator --include-runtime script.js`.
749
+ return exports;
750
+
751
+ }(
752
+ // If this script is executing as a CommonJS module, use module.exports
753
+ // as the regeneratorRuntime namespace. Otherwise create a new empty
754
+ // object. Either way, the resulting object will be used to initialize
755
+ // the regeneratorRuntime variable at the top of this file.
756
+ module.exports
757
+ ));
758
+
759
+ try {
760
+ regeneratorRuntime = runtime;
761
+ } catch (accidentalStrictMode) {
762
+ // This module should not be running in strict mode, so the above
763
+ // assignment should always work unless something is misconfigured. Just
764
+ // in case runtime.js accidentally runs in strict mode, we can escape
765
+ // strict mode using a global Function call. This could conceivably fail
766
+ // if a Content Security Policy forbids using Function, but in that case
767
+ // the proper solution is to fix the accidental strict mode problem. If
768
+ // you've misconfigured your bundler to force strict mode and applied a
769
+ // CSP to forbid Function, and you're not willing to fix either of those
770
+ // problems, please detail your unique predicament in a GitHub issue.
771
+ Function("r", "regeneratorRuntime = r")(runtime);
772
+ }
773
+ });
774
+
4
775
  var TokenType;
5
776
 
6
777
  (function (TokenType) {
@@ -72,39 +843,70 @@ function leads (ctx) {
72
843
  }
73
844
 
74
845
  function channels (ctx) {
846
+ /**
847
+ * @deprecated use channels.resolveReferences()
848
+ */
849
+ function getPropertyIdFromReference(_x, _x2) {
850
+ return _getPropertyIdFromReference.apply(this, arguments);
851
+ }
75
852
  /**
76
853
  * @param channel_id Channel ID, for example, `"immoweb"` or `"immovlan"` etc
77
854
  * @param reference_code Reference
78
855
  * @param company_id Company ID
79
856
  */
80
- var resolveReferences = function resolveReferences(channel_id, reference_code, company_id) {
81
- try {
82
- ctx.checkAuth(TokenType.API_TOKEN);
83
- var endpoint = "/services/channel-references";
84
- return Promise.resolve(ctx.httpClient.get(endpoint, {
85
- params: {
86
- channel_id: channel_id,
87
- reference_code: reference_code,
88
- company_id: company_id
857
+
858
+
859
+ function _getPropertyIdFromReference() {
860
+ _getPropertyIdFromReference = _asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee(channel, referenceId) {
861
+ var endpoint;
862
+ return runtime_1.wrap(function _callee$(_context) {
863
+ while (1) {
864
+ switch (_context.prev = _context.next) {
865
+ case 0:
866
+ ctx.checkAuth(TokenType.API_TOKEN);
867
+ endpoint = "/channels/" + channel + "/channel-references/" + referenceId;
868
+ return _context.abrupt("return", ctx.httpClient.get(endpoint));
869
+
870
+ case 3:
871
+ case "end":
872
+ return _context.stop();
873
+ }
89
874
  }
90
- }));
91
- } catch (e) {
92
- return Promise.reject(e);
93
- }
94
- };
875
+ }, _callee);
876
+ }));
877
+ return _getPropertyIdFromReference.apply(this, arguments);
878
+ }
95
879
 
96
- /**
97
- * @deprecated use channels.resolveReferences()
98
- */
99
- var getPropertyIdFromReference = function getPropertyIdFromReference(channel, referenceId) {
100
- try {
101
- ctx.checkAuth(TokenType.API_TOKEN);
102
- var endpoint = "/channels/" + channel + "/channel-references/" + referenceId;
103
- return Promise.resolve(ctx.httpClient.get(endpoint));
104
- } catch (e) {
105
- return Promise.reject(e);
106
- }
107
- };
880
+ function resolveReferences(_x3, _x4, _x5) {
881
+ return _resolveReferences.apply(this, arguments);
882
+ }
883
+
884
+ function _resolveReferences() {
885
+ _resolveReferences = _asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee2(channel_id, reference_code, company_id) {
886
+ var endpoint;
887
+ return runtime_1.wrap(function _callee2$(_context2) {
888
+ while (1) {
889
+ switch (_context2.prev = _context2.next) {
890
+ case 0:
891
+ ctx.checkAuth(TokenType.API_TOKEN);
892
+ endpoint = "/services/channel-references";
893
+ return _context2.abrupt("return", ctx.httpClient.get(endpoint, {
894
+ params: {
895
+ channel_id: channel_id,
896
+ reference_code: reference_code,
897
+ company_id: company_id
898
+ }
899
+ }));
900
+
901
+ case 3:
902
+ case "end":
903
+ return _context2.stop();
904
+ }
905
+ }
906
+ }, _callee2);
907
+ }));
908
+ return _resolveReferences.apply(this, arguments);
909
+ }
108
910
 
109
911
  return {
110
912
  getPropertyIdFromReference: getPropertyIdFromReference,
@@ -119,7 +921,7 @@ function estates (ctx) {
119
921
  ctx.checkAuth(TokenType.API_TOKEN);
120
922
  return ctx.httpClient.get("/services/estates/" + attributes.estateId, {
121
923
  params: {
122
- includes: (_attributes$includes = attributes.includes) !== null && _attributes$includes !== void 0 ? _attributes$includes : []
924
+ includes: (_attributes$includes = attributes.includes) != null ? _attributes$includes : []
123
925
  }
124
926
  }).then(function (res) {
125
927
  return res.data;
@@ -132,8 +934,8 @@ function estates (ctx) {
132
934
  ctx.checkAuth(TokenType.API_TOKEN);
133
935
  return ctx.httpClient.get("/services/companies/" + attributes.companyId + "/estates", {
134
936
  params: {
135
- page: (_attributes$page = attributes.page) !== null && _attributes$page !== void 0 ? _attributes$page : 1,
136
- limit: (_attributes$limit = attributes.limit) !== null && _attributes$limit !== void 0 ? _attributes$limit : 10,
937
+ page: (_attributes$page = attributes.page) != null ? _attributes$page : 1,
938
+ limit: (_attributes$limit = attributes.limit) != null ? _attributes$limit : 10,
137
939
  archived: attributes.archived
138
940
  }
139
941
  });
@@ -199,51 +1001,95 @@ function estates (ctx) {
199
1001
  }
200
1002
 
201
1003
  function channelAccounts (ctx) {
202
- var getEstateHash = function getEstateHash(_ref2) {
203
- var estateId = _ref2.estateId,
204
- channelAccountId = _ref2.channelAccountId;
1004
+ function getAll(_x) {
1005
+ return _getAll.apply(this, arguments);
1006
+ }
205
1007
 
206
- try {
207
- var endpoint = "services/estates/" + estateId + "/channel-accounts/" + channelAccountId + "/hash";
208
- return Promise.resolve(ctx.httpClient.post(endpoint)).then(function (response) {
209
- return response.data;
210
- });
211
- } catch (e) {
212
- return Promise.reject(e);
213
- }
214
- };
1008
+ function _getAll() {
1009
+ _getAll = _asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee(_ref) {
1010
+ var companyId, endpoint;
1011
+ return runtime_1.wrap(function _callee$(_context) {
1012
+ while (1) {
1013
+ switch (_context.prev = _context.next) {
1014
+ case 0:
1015
+ companyId = _ref.companyId;
1016
+ ctx.checkAuth(TokenType.API_TOKEN);
1017
+ endpoint = "/services/companies/" + companyId + "/channel-accounts";
1018
+ return _context.abrupt("return", ctx.httpClient.get(endpoint, {
1019
+ params: {
1020
+ includes: 'channel'
1021
+ }
1022
+ }));
215
1023
 
216
- var get = function get(_ref3) {
217
- var channelAccountId = _ref3.channelAccountId;
1024
+ case 4:
1025
+ case "end":
1026
+ return _context.stop();
1027
+ }
1028
+ }
1029
+ }, _callee);
1030
+ }));
1031
+ return _getAll.apply(this, arguments);
1032
+ }
218
1033
 
219
- try {
220
- ctx.checkAuth(TokenType.API_TOKEN);
221
- var endpoint = "/services/channel-accounts/" + channelAccountId;
222
- return Promise.resolve(ctx.httpClient.get(endpoint, {
223
- params: {
224
- includes: 'channel'
1034
+ function get(_x2) {
1035
+ return _get.apply(this, arguments);
1036
+ }
1037
+
1038
+ function _get() {
1039
+ _get = _asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee2(_ref2) {
1040
+ var channelAccountId, endpoint;
1041
+ return runtime_1.wrap(function _callee2$(_context2) {
1042
+ while (1) {
1043
+ switch (_context2.prev = _context2.next) {
1044
+ case 0:
1045
+ channelAccountId = _ref2.channelAccountId;
1046
+ ctx.checkAuth(TokenType.API_TOKEN);
1047
+ endpoint = "/services/channel-accounts/" + channelAccountId;
1048
+ return _context2.abrupt("return", ctx.httpClient.get(endpoint, {
1049
+ params: {
1050
+ includes: 'channel'
1051
+ }
1052
+ }));
1053
+
1054
+ case 4:
1055
+ case "end":
1056
+ return _context2.stop();
1057
+ }
225
1058
  }
226
- }));
227
- } catch (e) {
228
- return Promise.reject(e);
229
- }
230
- };
1059
+ }, _callee2);
1060
+ }));
1061
+ return _get.apply(this, arguments);
1062
+ }
1063
+
1064
+ function getEstateHash(_x3) {
1065
+ return _getEstateHash.apply(this, arguments);
1066
+ }
231
1067
 
232
- var getAll = function getAll(_ref) {
233
- var companyId = _ref.companyId;
1068
+ function _getEstateHash() {
1069
+ _getEstateHash = _asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee3(_ref3) {
1070
+ var estateId, channelAccountId, endpoint, response;
1071
+ return runtime_1.wrap(function _callee3$(_context3) {
1072
+ while (1) {
1073
+ switch (_context3.prev = _context3.next) {
1074
+ case 0:
1075
+ estateId = _ref3.estateId, channelAccountId = _ref3.channelAccountId;
1076
+ endpoint = "services/estates/" + estateId + "/channel-accounts/" + channelAccountId + "/hash";
1077
+ _context3.next = 4;
1078
+ return ctx.httpClient.post(endpoint);
234
1079
 
235
- try {
236
- ctx.checkAuth(TokenType.API_TOKEN);
237
- var endpoint = "/services/companies/" + companyId + "/channel-accounts";
238
- return Promise.resolve(ctx.httpClient.get(endpoint, {
239
- params: {
240
- includes: 'channel'
1080
+ case 4:
1081
+ response = _context3.sent;
1082
+ return _context3.abrupt("return", response.data);
1083
+
1084
+ case 6:
1085
+ case "end":
1086
+ return _context3.stop();
1087
+ }
241
1088
  }
242
- }));
243
- } catch (e) {
244
- return Promise.reject(e);
245
- }
246
- };
1089
+ }, _callee3);
1090
+ }));
1091
+ return _getEstateHash.apply(this, arguments);
1092
+ }
247
1093
 
248
1094
  return {
249
1095
  getAll: getAll,
@@ -259,7 +1105,7 @@ function companies (ctx) {
259
1105
  ctx.checkAuth(TokenType.API_TOKEN);
260
1106
  return ctx.httpClient.get("/companies/" + attributes.companyId, {
261
1107
  params: {
262
- includes: (_attributes$includes = attributes.includes) === null || _attributes$includes === void 0 ? void 0 : _attributes$includes.join(',')
1108
+ includes: (_attributes$includes = attributes.includes) == null ? void 0 : _attributes$includes.join(',')
263
1109
  }
264
1110
  });
265
1111
  }
@@ -275,20 +1121,26 @@ function contacts (ctx) {
275
1121
  return ctx.httpClient.get("/services/contacts/" + attributes.contactId);
276
1122
  }
277
1123
 
1124
+ function getOneWithNegotiators(attributes) {
1125
+ ctx.checkAuth(TokenType.API_TOKEN);
1126
+ return ctx.httpClient.get("/services/contacts/" + attributes.contactId + "?includes=negotiators");
1127
+ }
1128
+
278
1129
  function getAll(attributes) {
279
1130
  var _attributes$page, _attributes$limit;
280
1131
 
281
1132
  ctx.checkAuth(TokenType.API_TOKEN);
282
1133
  return ctx.httpClient.get("/services/companies/" + attributes.companyId + "/contacts", {
283
1134
  params: {
284
- page: (_attributes$page = attributes.page) !== null && _attributes$page !== void 0 ? _attributes$page : 1,
285
- limit: (_attributes$limit = attributes.limit) !== null && _attributes$limit !== void 0 ? _attributes$limit : 10
1135
+ page: (_attributes$page = attributes.page) != null ? _attributes$page : 1,
1136
+ limit: (_attributes$limit = attributes.limit) != null ? _attributes$limit : 10
286
1137
  }
287
1138
  });
288
1139
  }
289
1140
 
290
1141
  return {
291
1142
  getOne: getOne,
1143
+ getOneWithNegotiators: getOneWithNegotiators,
292
1144
  getAll: getAll
293
1145
  };
294
1146
  }
@@ -316,7 +1168,8 @@ function createClient(conf) {
316
1168
  var _auth = null;
317
1169
  var httpClient = axios.create({
318
1170
  baseURL: envHosts[env]
319
- });
1171
+ }); //TODO: getData here is an antipattern. Interceptor should not change a type of response
1172
+
320
1173
  httpClient.interceptors.response.use(getData, handleRequestFailure);
321
1174
 
322
1175
  if (version) {
@@ -366,18 +1219,33 @@ function createClient(conf) {
366
1219
  return client;
367
1220
  });
368
1221
  },
369
- withUserToken: function (accessToken) {
370
- try {
371
- _auth = {
372
- token: accessToken,
373
- type: TokenType.USER_TOKEN
374
- };
375
- httpClient.defaults.headers.common['Authorization'] = "Bearer " + _auth.token;
376
- return Promise.resolve(client);
377
- } catch (e) {
378
- return Promise.reject(e);
1222
+ withUserToken: function () {
1223
+ var _withUserToken = _asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee(accessToken) {
1224
+ return runtime_1.wrap(function _callee$(_context) {
1225
+ while (1) {
1226
+ switch (_context.prev = _context.next) {
1227
+ case 0:
1228
+ _auth = {
1229
+ token: accessToken,
1230
+ type: TokenType.USER_TOKEN
1231
+ };
1232
+ httpClient.defaults.headers.common['Authorization'] = "Bearer " + _auth.token;
1233
+ return _context.abrupt("return", client);
1234
+
1235
+ case 3:
1236
+ case "end":
1237
+ return _context.stop();
1238
+ }
1239
+ }
1240
+ }, _callee);
1241
+ }));
1242
+
1243
+ function withUserToken(_x) {
1244
+ return _withUserToken.apply(this, arguments);
379
1245
  }
380
- },
1246
+
1247
+ return withUserToken;
1248
+ }(),
381
1249
  leads: leads(ctx),
382
1250
  channels: channels(ctx),
383
1251
  estates: estates(ctx),