@cimplify/sdk 0.2.5 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.mts +296 -55
- package/dist/index.d.ts +296 -55
- package/dist/index.js +333 -89
- package/dist/index.mjs +320 -90
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -276,7 +276,91 @@ var CatalogueQueries = class {
|
|
|
276
276
|
}
|
|
277
277
|
};
|
|
278
278
|
|
|
279
|
+
// src/types/result.ts
|
|
280
|
+
function ok(value) {
|
|
281
|
+
return { ok: true, value };
|
|
282
|
+
}
|
|
283
|
+
function err(error) {
|
|
284
|
+
return { ok: false, error };
|
|
285
|
+
}
|
|
286
|
+
function isOk(result) {
|
|
287
|
+
return result.ok === true;
|
|
288
|
+
}
|
|
289
|
+
function isErr(result) {
|
|
290
|
+
return result.ok === false;
|
|
291
|
+
}
|
|
292
|
+
function mapResult(result, fn) {
|
|
293
|
+
return result.ok ? ok(fn(result.value)) : result;
|
|
294
|
+
}
|
|
295
|
+
function mapError(result, fn) {
|
|
296
|
+
return result.ok ? result : err(fn(result.error));
|
|
297
|
+
}
|
|
298
|
+
function flatMap(result, fn) {
|
|
299
|
+
return result.ok ? fn(result.value) : result;
|
|
300
|
+
}
|
|
301
|
+
function getOrElse(result, defaultFn) {
|
|
302
|
+
return result.ok ? result.value : defaultFn();
|
|
303
|
+
}
|
|
304
|
+
function unwrap(result) {
|
|
305
|
+
if (result.ok) {
|
|
306
|
+
return result.value;
|
|
307
|
+
}
|
|
308
|
+
throw result.error;
|
|
309
|
+
}
|
|
310
|
+
function toNullable(result) {
|
|
311
|
+
return result.ok ? result.value : void 0;
|
|
312
|
+
}
|
|
313
|
+
async function fromPromise(promise, mapError2) {
|
|
314
|
+
try {
|
|
315
|
+
const value = await promise;
|
|
316
|
+
return ok(value);
|
|
317
|
+
} catch (error) {
|
|
318
|
+
return err(mapError2(error));
|
|
319
|
+
}
|
|
320
|
+
}
|
|
321
|
+
function tryCatch(fn, mapError2) {
|
|
322
|
+
try {
|
|
323
|
+
return ok(fn());
|
|
324
|
+
} catch (error) {
|
|
325
|
+
return err(mapError2(error));
|
|
326
|
+
}
|
|
327
|
+
}
|
|
328
|
+
function combine(results) {
|
|
329
|
+
const values = [];
|
|
330
|
+
for (const result of results) {
|
|
331
|
+
if (!result.ok) {
|
|
332
|
+
return result;
|
|
333
|
+
}
|
|
334
|
+
values.push(result.value);
|
|
335
|
+
}
|
|
336
|
+
return ok(values);
|
|
337
|
+
}
|
|
338
|
+
function combineObject(results) {
|
|
339
|
+
const values = {};
|
|
340
|
+
for (const [key, result] of Object.entries(results)) {
|
|
341
|
+
if (!result.ok) {
|
|
342
|
+
return result;
|
|
343
|
+
}
|
|
344
|
+
values[key] = result.value;
|
|
345
|
+
}
|
|
346
|
+
return ok(values);
|
|
347
|
+
}
|
|
348
|
+
|
|
279
349
|
// src/cart.ts
|
|
350
|
+
function toCimplifyError(error) {
|
|
351
|
+
if (error instanceof CimplifyError) return error;
|
|
352
|
+
if (error instanceof Error) {
|
|
353
|
+
return new CimplifyError("UNKNOWN_ERROR", error.message, false);
|
|
354
|
+
}
|
|
355
|
+
return new CimplifyError("UNKNOWN_ERROR", String(error), false);
|
|
356
|
+
}
|
|
357
|
+
async function safe(promise) {
|
|
358
|
+
try {
|
|
359
|
+
return ok(await promise);
|
|
360
|
+
} catch (error) {
|
|
361
|
+
return err(toCimplifyError(error));
|
|
362
|
+
}
|
|
363
|
+
}
|
|
280
364
|
var CartOperations = class {
|
|
281
365
|
constructor(client) {
|
|
282
366
|
this.client = client;
|
|
@@ -289,23 +373,25 @@ var CartOperations = class {
|
|
|
289
373
|
* This is the main method for storefront display.
|
|
290
374
|
*/
|
|
291
375
|
async get() {
|
|
292
|
-
return this.client.query("cart#enriched");
|
|
376
|
+
return safe(this.client.query("cart#enriched"));
|
|
293
377
|
}
|
|
294
378
|
async getRaw() {
|
|
295
|
-
return this.client.query("cart");
|
|
379
|
+
return safe(this.client.query("cart"));
|
|
296
380
|
}
|
|
297
381
|
async getItems() {
|
|
298
|
-
return this.client.query("cart_items");
|
|
382
|
+
return safe(this.client.query("cart_items"));
|
|
299
383
|
}
|
|
300
384
|
async getCount() {
|
|
301
|
-
return this.client.query("cart#count");
|
|
385
|
+
return safe(this.client.query("cart#count"));
|
|
302
386
|
}
|
|
303
387
|
async getTotal() {
|
|
304
|
-
return this.client.query("cart#total");
|
|
388
|
+
return safe(this.client.query("cart#total"));
|
|
305
389
|
}
|
|
306
390
|
async getSummary() {
|
|
307
|
-
const
|
|
308
|
-
return
|
|
391
|
+
const cartResult = await this.get();
|
|
392
|
+
if (!cartResult.ok) return cartResult;
|
|
393
|
+
const cart = cartResult.value;
|
|
394
|
+
return ok({
|
|
309
395
|
item_count: cart.items.length,
|
|
310
396
|
total_items: cart.items.reduce((sum, item) => sum + item.quantity, 0),
|
|
311
397
|
subtotal: cart.pricing.subtotal,
|
|
@@ -313,55 +399,89 @@ var CartOperations = class {
|
|
|
313
399
|
tax_amount: cart.pricing.tax_amount,
|
|
314
400
|
total: cart.pricing.total_price,
|
|
315
401
|
currency: cart.pricing.currency
|
|
316
|
-
};
|
|
402
|
+
});
|
|
317
403
|
}
|
|
318
404
|
// --------------------------------------------------------------------------
|
|
319
405
|
// CART MUTATIONS
|
|
320
406
|
// --------------------------------------------------------------------------
|
|
407
|
+
/**
|
|
408
|
+
* Add an item to the cart.
|
|
409
|
+
*
|
|
410
|
+
* @example
|
|
411
|
+
* ```typescript
|
|
412
|
+
* const result = await client.cart.addItem({
|
|
413
|
+
* item_id: "prod_burger",
|
|
414
|
+
* quantity: 2,
|
|
415
|
+
* variant_id: "var_large",
|
|
416
|
+
* add_on_options: ["addon_cheese", "addon_bacon"],
|
|
417
|
+
* });
|
|
418
|
+
*
|
|
419
|
+
* if (!result.ok) {
|
|
420
|
+
* switch (result.error.code) {
|
|
421
|
+
* case ErrorCode.ITEM_UNAVAILABLE:
|
|
422
|
+
* toast.error("Item no longer available");
|
|
423
|
+
* break;
|
|
424
|
+
* case ErrorCode.VARIANT_OUT_OF_STOCK:
|
|
425
|
+
* toast.error("Selected option is out of stock");
|
|
426
|
+
* break;
|
|
427
|
+
* }
|
|
428
|
+
* }
|
|
429
|
+
* ```
|
|
430
|
+
*/
|
|
321
431
|
async addItem(input) {
|
|
322
|
-
return this.client.call("cart.addItem", input);
|
|
432
|
+
return safe(this.client.call("cart.addItem", input));
|
|
323
433
|
}
|
|
324
434
|
async updateItem(cartItemId, updates) {
|
|
325
|
-
return
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
435
|
+
return safe(
|
|
436
|
+
this.client.call("cart.updateItem", {
|
|
437
|
+
cart_item_id: cartItemId,
|
|
438
|
+
...updates
|
|
439
|
+
})
|
|
440
|
+
);
|
|
329
441
|
}
|
|
330
442
|
async updateQuantity(cartItemId, quantity) {
|
|
331
|
-
return
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
443
|
+
return safe(
|
|
444
|
+
this.client.call("cart.updateItemQuantity", {
|
|
445
|
+
cart_item_id: cartItemId,
|
|
446
|
+
quantity
|
|
447
|
+
})
|
|
448
|
+
);
|
|
335
449
|
}
|
|
336
450
|
async removeItem(cartItemId) {
|
|
337
|
-
return
|
|
338
|
-
|
|
339
|
-
|
|
451
|
+
return safe(
|
|
452
|
+
this.client.call("cart.removeItem", {
|
|
453
|
+
cart_item_id: cartItemId
|
|
454
|
+
})
|
|
455
|
+
);
|
|
340
456
|
}
|
|
341
457
|
async clear() {
|
|
342
|
-
return this.client.call("cart.clearCart");
|
|
458
|
+
return safe(this.client.call("cart.clearCart"));
|
|
343
459
|
}
|
|
344
460
|
// --------------------------------------------------------------------------
|
|
345
461
|
// COUPONS & DISCOUNTS
|
|
346
462
|
// --------------------------------------------------------------------------
|
|
347
463
|
async applyCoupon(code) {
|
|
348
|
-
return
|
|
349
|
-
|
|
350
|
-
|
|
464
|
+
return safe(
|
|
465
|
+
this.client.call("cart.applyCoupon", {
|
|
466
|
+
coupon_code: code
|
|
467
|
+
})
|
|
468
|
+
);
|
|
351
469
|
}
|
|
352
470
|
async removeCoupon() {
|
|
353
|
-
return this.client.call("cart.removeCoupon");
|
|
471
|
+
return safe(this.client.call("cart.removeCoupon"));
|
|
354
472
|
}
|
|
355
473
|
// --------------------------------------------------------------------------
|
|
356
474
|
// CONVENIENCE METHODS
|
|
357
475
|
// --------------------------------------------------------------------------
|
|
358
476
|
async isEmpty() {
|
|
359
|
-
const
|
|
360
|
-
|
|
477
|
+
const countResult = await this.getCount();
|
|
478
|
+
if (!countResult.ok) return countResult;
|
|
479
|
+
return ok(countResult.value === 0);
|
|
361
480
|
}
|
|
362
481
|
async hasItem(productId, variantId) {
|
|
363
|
-
const
|
|
364
|
-
|
|
482
|
+
const itemsResult = await this.getItems();
|
|
483
|
+
if (!itemsResult.ok) return itemsResult;
|
|
484
|
+
const found = itemsResult.value.some((item) => {
|
|
365
485
|
const matchesProduct = item.item_id === productId;
|
|
366
486
|
if (!variantId) return matchesProduct;
|
|
367
487
|
const config = item.configuration;
|
|
@@ -370,10 +490,12 @@ var CartOperations = class {
|
|
|
370
490
|
}
|
|
371
491
|
return matchesProduct;
|
|
372
492
|
});
|
|
493
|
+
return ok(found);
|
|
373
494
|
}
|
|
374
495
|
async findItem(productId, variantId) {
|
|
375
|
-
const
|
|
376
|
-
|
|
496
|
+
const itemsResult = await this.getItems();
|
|
497
|
+
if (!itemsResult.ok) return itemsResult;
|
|
498
|
+
const found = itemsResult.value.find((item) => {
|
|
377
499
|
const matchesProduct = item.item_id === productId;
|
|
378
500
|
if (!variantId) return matchesProduct;
|
|
379
501
|
const config = item.configuration;
|
|
@@ -382,6 +504,7 @@ var CartOperations = class {
|
|
|
382
504
|
}
|
|
383
505
|
return matchesProduct;
|
|
384
506
|
});
|
|
507
|
+
return ok(found);
|
|
385
508
|
}
|
|
386
509
|
};
|
|
387
510
|
|
|
@@ -476,37 +599,88 @@ var DEFAULT_CURRENCY = "GHS";
|
|
|
476
599
|
var DEFAULT_COUNTRY = "GHA";
|
|
477
600
|
|
|
478
601
|
// src/checkout.ts
|
|
602
|
+
function toCimplifyError2(error) {
|
|
603
|
+
if (error instanceof CimplifyError) return error;
|
|
604
|
+
if (error instanceof Error) {
|
|
605
|
+
return new CimplifyError("UNKNOWN_ERROR", error.message, false);
|
|
606
|
+
}
|
|
607
|
+
return new CimplifyError("UNKNOWN_ERROR", String(error), false);
|
|
608
|
+
}
|
|
609
|
+
async function safe2(promise) {
|
|
610
|
+
try {
|
|
611
|
+
return ok(await promise);
|
|
612
|
+
} catch (error) {
|
|
613
|
+
return err(toCimplifyError2(error));
|
|
614
|
+
}
|
|
615
|
+
}
|
|
479
616
|
var CheckoutService = class {
|
|
480
617
|
constructor(client) {
|
|
481
618
|
this.client = client;
|
|
482
619
|
}
|
|
620
|
+
/**
|
|
621
|
+
* Process checkout with cart data.
|
|
622
|
+
*
|
|
623
|
+
* @example
|
|
624
|
+
* ```typescript
|
|
625
|
+
* const result = await client.checkout.process({
|
|
626
|
+
* cart_id: cart.id,
|
|
627
|
+
* customer: { name, email, phone, save_details: true },
|
|
628
|
+
* order_type: "pickup",
|
|
629
|
+
* payment_method: "mobile_money",
|
|
630
|
+
* mobile_money_details: { phone_number, provider: "mtn" },
|
|
631
|
+
* });
|
|
632
|
+
*
|
|
633
|
+
* if (!result.ok) {
|
|
634
|
+
* switch (result.error.code) {
|
|
635
|
+
* case ErrorCode.CART_EMPTY:
|
|
636
|
+
* toast.error("Your cart is empty");
|
|
637
|
+
* break;
|
|
638
|
+
* case ErrorCode.PAYMENT_FAILED:
|
|
639
|
+
* toast.error("Payment failed. Please try again.");
|
|
640
|
+
* break;
|
|
641
|
+
* }
|
|
642
|
+
* }
|
|
643
|
+
* ```
|
|
644
|
+
*/
|
|
483
645
|
async process(data) {
|
|
484
|
-
return
|
|
485
|
-
|
|
486
|
-
|
|
646
|
+
return safe2(
|
|
647
|
+
this.client.call(CHECKOUT_MUTATION.PROCESS, {
|
|
648
|
+
checkout_data: data
|
|
649
|
+
})
|
|
650
|
+
);
|
|
487
651
|
}
|
|
488
652
|
async initializePayment(orderId, method) {
|
|
489
|
-
return
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
653
|
+
return safe2(
|
|
654
|
+
this.client.call("order.initializePayment", {
|
|
655
|
+
order_id: orderId,
|
|
656
|
+
payment_method: method
|
|
657
|
+
})
|
|
658
|
+
);
|
|
493
659
|
}
|
|
494
660
|
async submitAuthorization(input) {
|
|
495
|
-
return
|
|
661
|
+
return safe2(
|
|
662
|
+
this.client.call(PAYMENT_MUTATION.SUBMIT_AUTHORIZATION, input)
|
|
663
|
+
);
|
|
496
664
|
}
|
|
497
665
|
async pollPaymentStatus(orderId) {
|
|
498
|
-
return
|
|
666
|
+
return safe2(
|
|
667
|
+
this.client.call(PAYMENT_MUTATION.CHECK_STATUS, orderId)
|
|
668
|
+
);
|
|
499
669
|
}
|
|
500
670
|
async updateOrderCustomer(orderId, customer) {
|
|
501
|
-
return
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
671
|
+
return safe2(
|
|
672
|
+
this.client.call(ORDER_MUTATION.UPDATE_CUSTOMER, {
|
|
673
|
+
order_id: orderId,
|
|
674
|
+
...customer
|
|
675
|
+
})
|
|
676
|
+
);
|
|
505
677
|
}
|
|
506
678
|
async verifyPayment(orderId) {
|
|
507
|
-
return
|
|
508
|
-
|
|
509
|
-
|
|
679
|
+
return safe2(
|
|
680
|
+
this.client.call("order.verifyPayment", {
|
|
681
|
+
order_id: orderId
|
|
682
|
+
})
|
|
683
|
+
);
|
|
510
684
|
}
|
|
511
685
|
};
|
|
512
686
|
|
|
@@ -547,117 +721,173 @@ var OrderQueries = class {
|
|
|
547
721
|
};
|
|
548
722
|
|
|
549
723
|
// src/link.ts
|
|
724
|
+
function toCimplifyError3(error) {
|
|
725
|
+
if (error instanceof CimplifyError) return error;
|
|
726
|
+
if (error instanceof Error) {
|
|
727
|
+
return new CimplifyError("UNKNOWN_ERROR", error.message, false);
|
|
728
|
+
}
|
|
729
|
+
return new CimplifyError("UNKNOWN_ERROR", String(error), false);
|
|
730
|
+
}
|
|
731
|
+
async function safe3(promise) {
|
|
732
|
+
try {
|
|
733
|
+
return ok(await promise);
|
|
734
|
+
} catch (error) {
|
|
735
|
+
return err(toCimplifyError3(error));
|
|
736
|
+
}
|
|
737
|
+
}
|
|
550
738
|
var LinkService = class {
|
|
551
739
|
constructor(client) {
|
|
552
740
|
this.client = client;
|
|
553
741
|
}
|
|
742
|
+
// --------------------------------------------------------------------------
|
|
743
|
+
// AUTHENTICATION
|
|
744
|
+
// --------------------------------------------------------------------------
|
|
554
745
|
async requestOtp(input) {
|
|
555
|
-
return this.client.linkPost("/v1/link/auth/request-otp", input);
|
|
746
|
+
return safe3(this.client.linkPost("/v1/link/auth/request-otp", input));
|
|
556
747
|
}
|
|
557
748
|
async verifyOtp(input) {
|
|
558
|
-
const
|
|
559
|
-
|
|
560
|
-
|
|
749
|
+
const result = await safe3(
|
|
750
|
+
this.client.linkPost("/v1/link/auth/verify-otp", input)
|
|
751
|
+
);
|
|
752
|
+
if (result.ok && result.value.session_token) {
|
|
753
|
+
this.client.setSessionToken(result.value.session_token);
|
|
561
754
|
}
|
|
562
|
-
return
|
|
755
|
+
return result;
|
|
563
756
|
}
|
|
564
757
|
async logout() {
|
|
565
|
-
const result = await this.client.linkPost("/v1/link/auth/logout");
|
|
566
|
-
|
|
758
|
+
const result = await safe3(this.client.linkPost("/v1/link/auth/logout"));
|
|
759
|
+
if (result.ok) {
|
|
760
|
+
this.client.clearSession();
|
|
761
|
+
}
|
|
567
762
|
return result;
|
|
568
763
|
}
|
|
764
|
+
// --------------------------------------------------------------------------
|
|
765
|
+
// STATUS & DATA
|
|
766
|
+
// --------------------------------------------------------------------------
|
|
569
767
|
async checkStatus(contact) {
|
|
570
|
-
return
|
|
571
|
-
|
|
572
|
-
|
|
768
|
+
return safe3(
|
|
769
|
+
this.client.call(LINK_MUTATION.CHECK_STATUS, {
|
|
770
|
+
contact
|
|
771
|
+
})
|
|
772
|
+
);
|
|
573
773
|
}
|
|
574
774
|
async getLinkData() {
|
|
575
|
-
return this.client.query(LINK_QUERY.DATA);
|
|
775
|
+
return safe3(this.client.query(LINK_QUERY.DATA));
|
|
576
776
|
}
|
|
577
777
|
async getAddresses() {
|
|
578
|
-
return this.client.query(LINK_QUERY.ADDRESSES);
|
|
778
|
+
return safe3(this.client.query(LINK_QUERY.ADDRESSES));
|
|
579
779
|
}
|
|
580
780
|
async getMobileMoney() {
|
|
581
|
-
return this.client.query(LINK_QUERY.MOBILE_MONEY);
|
|
781
|
+
return safe3(this.client.query(LINK_QUERY.MOBILE_MONEY));
|
|
582
782
|
}
|
|
583
783
|
async getPreferences() {
|
|
584
|
-
return this.client.query(LINK_QUERY.PREFERENCES);
|
|
784
|
+
return safe3(this.client.query(LINK_QUERY.PREFERENCES));
|
|
585
785
|
}
|
|
786
|
+
// --------------------------------------------------------------------------
|
|
787
|
+
// ENROLLMENT
|
|
788
|
+
// --------------------------------------------------------------------------
|
|
586
789
|
async enroll(data) {
|
|
587
|
-
return this.client.call(LINK_MUTATION.ENROLL, data);
|
|
790
|
+
return safe3(this.client.call(LINK_MUTATION.ENROLL, data));
|
|
588
791
|
}
|
|
589
792
|
async enrollAndLinkOrder(data) {
|
|
590
|
-
return
|
|
793
|
+
return safe3(
|
|
794
|
+
this.client.call(LINK_MUTATION.ENROLL_AND_LINK_ORDER, data)
|
|
795
|
+
);
|
|
591
796
|
}
|
|
797
|
+
// --------------------------------------------------------------------------
|
|
798
|
+
// PREFERENCES
|
|
799
|
+
// --------------------------------------------------------------------------
|
|
592
800
|
async updatePreferences(preferences) {
|
|
593
|
-
return this.client.call(LINK_MUTATION.UPDATE_PREFERENCES, preferences);
|
|
801
|
+
return safe3(this.client.call(LINK_MUTATION.UPDATE_PREFERENCES, preferences));
|
|
594
802
|
}
|
|
803
|
+
// --------------------------------------------------------------------------
|
|
804
|
+
// ADDRESSES
|
|
805
|
+
// --------------------------------------------------------------------------
|
|
595
806
|
async createAddress(input) {
|
|
596
|
-
return this.client.call(LINK_MUTATION.CREATE_ADDRESS, input);
|
|
807
|
+
return safe3(this.client.call(LINK_MUTATION.CREATE_ADDRESS, input));
|
|
597
808
|
}
|
|
598
809
|
async updateAddress(input) {
|
|
599
|
-
return this.client.call(LINK_MUTATION.UPDATE_ADDRESS, input);
|
|
810
|
+
return safe3(this.client.call(LINK_MUTATION.UPDATE_ADDRESS, input));
|
|
600
811
|
}
|
|
601
812
|
async deleteAddress(addressId) {
|
|
602
|
-
return this.client.call(LINK_MUTATION.DELETE_ADDRESS, addressId);
|
|
813
|
+
return safe3(this.client.call(LINK_MUTATION.DELETE_ADDRESS, addressId));
|
|
603
814
|
}
|
|
604
815
|
async setDefaultAddress(addressId) {
|
|
605
|
-
return this.client.call(LINK_MUTATION.SET_DEFAULT_ADDRESS, addressId);
|
|
816
|
+
return safe3(this.client.call(LINK_MUTATION.SET_DEFAULT_ADDRESS, addressId));
|
|
606
817
|
}
|
|
607
818
|
async trackAddressUsage(addressId) {
|
|
608
|
-
return
|
|
609
|
-
|
|
610
|
-
|
|
819
|
+
return safe3(
|
|
820
|
+
this.client.call(LINK_MUTATION.TRACK_ADDRESS_USAGE, {
|
|
821
|
+
address_id: addressId
|
|
822
|
+
})
|
|
823
|
+
);
|
|
611
824
|
}
|
|
825
|
+
// --------------------------------------------------------------------------
|
|
826
|
+
// MOBILE MONEY
|
|
827
|
+
// --------------------------------------------------------------------------
|
|
612
828
|
async createMobileMoney(input) {
|
|
613
|
-
return this.client.call(LINK_MUTATION.CREATE_MOBILE_MONEY, input);
|
|
829
|
+
return safe3(this.client.call(LINK_MUTATION.CREATE_MOBILE_MONEY, input));
|
|
614
830
|
}
|
|
615
831
|
async deleteMobileMoney(mobileMoneyId) {
|
|
616
|
-
return this.client.call(LINK_MUTATION.DELETE_MOBILE_MONEY, mobileMoneyId);
|
|
832
|
+
return safe3(this.client.call(LINK_MUTATION.DELETE_MOBILE_MONEY, mobileMoneyId));
|
|
617
833
|
}
|
|
618
834
|
async setDefaultMobileMoney(mobileMoneyId) {
|
|
619
|
-
return
|
|
835
|
+
return safe3(
|
|
836
|
+
this.client.call(LINK_MUTATION.SET_DEFAULT_MOBILE_MONEY, mobileMoneyId)
|
|
837
|
+
);
|
|
620
838
|
}
|
|
621
839
|
async trackMobileMoneyUsage(mobileMoneyId) {
|
|
622
|
-
return
|
|
623
|
-
|
|
624
|
-
|
|
840
|
+
return safe3(
|
|
841
|
+
this.client.call(LINK_MUTATION.TRACK_MOBILE_MONEY_USAGE, {
|
|
842
|
+
mobile_money_id: mobileMoneyId
|
|
843
|
+
})
|
|
844
|
+
);
|
|
625
845
|
}
|
|
626
846
|
async verifyMobileMoney(mobileMoneyId) {
|
|
627
|
-
return
|
|
847
|
+
return safe3(
|
|
848
|
+
this.client.call(LINK_MUTATION.VERIFY_MOBILE_MONEY, mobileMoneyId)
|
|
849
|
+
);
|
|
628
850
|
}
|
|
851
|
+
// --------------------------------------------------------------------------
|
|
852
|
+
// SESSIONS
|
|
853
|
+
// --------------------------------------------------------------------------
|
|
629
854
|
async getSessions() {
|
|
630
|
-
return this.client.linkGet("/v1/link/sessions");
|
|
855
|
+
return safe3(this.client.linkGet("/v1/link/sessions"));
|
|
631
856
|
}
|
|
632
857
|
async revokeSession(sessionId) {
|
|
633
|
-
return this.client.linkDelete(`/v1/link/sessions/${sessionId}`);
|
|
858
|
+
return safe3(this.client.linkDelete(`/v1/link/sessions/${sessionId}`));
|
|
634
859
|
}
|
|
635
860
|
async revokeAllSessions() {
|
|
636
|
-
return this.client.linkDelete("/v1/link/sessions");
|
|
861
|
+
return safe3(this.client.linkDelete("/v1/link/sessions"));
|
|
637
862
|
}
|
|
863
|
+
// --------------------------------------------------------------------------
|
|
864
|
+
// REST ALTERNATIVES (for direct API access)
|
|
865
|
+
// --------------------------------------------------------------------------
|
|
638
866
|
async getAddressesRest() {
|
|
639
|
-
return this.client.linkGet("/v1/link/addresses");
|
|
867
|
+
return safe3(this.client.linkGet("/v1/link/addresses"));
|
|
640
868
|
}
|
|
641
869
|
async createAddressRest(input) {
|
|
642
|
-
return this.client.linkPost("/v1/link/addresses", input);
|
|
870
|
+
return safe3(this.client.linkPost("/v1/link/addresses", input));
|
|
643
871
|
}
|
|
644
872
|
async deleteAddressRest(addressId) {
|
|
645
|
-
return this.client.linkDelete(`/v1/link/addresses/${addressId}`);
|
|
873
|
+
return safe3(this.client.linkDelete(`/v1/link/addresses/${addressId}`));
|
|
646
874
|
}
|
|
647
875
|
async setDefaultAddressRest(addressId) {
|
|
648
|
-
return this.client.linkPost(`/v1/link/addresses/${addressId}/default`);
|
|
876
|
+
return safe3(this.client.linkPost(`/v1/link/addresses/${addressId}/default`));
|
|
649
877
|
}
|
|
650
878
|
async getMobileMoneyRest() {
|
|
651
|
-
return this.client.linkGet("/v1/link/mobile-money");
|
|
879
|
+
return safe3(this.client.linkGet("/v1/link/mobile-money"));
|
|
652
880
|
}
|
|
653
881
|
async createMobileMoneyRest(input) {
|
|
654
|
-
return this.client.linkPost("/v1/link/mobile-money", input);
|
|
882
|
+
return safe3(this.client.linkPost("/v1/link/mobile-money", input));
|
|
655
883
|
}
|
|
656
884
|
async deleteMobileMoneyRest(mobileMoneyId) {
|
|
657
|
-
return this.client.linkDelete(`/v1/link/mobile-money/${mobileMoneyId}`);
|
|
885
|
+
return safe3(this.client.linkDelete(`/v1/link/mobile-money/${mobileMoneyId}`));
|
|
658
886
|
}
|
|
659
887
|
async setDefaultMobileMoneyRest(mobileMoneyId) {
|
|
660
|
-
return
|
|
888
|
+
return safe3(
|
|
889
|
+
this.client.linkPost(`/v1/link/mobile-money/${mobileMoneyId}/default`)
|
|
890
|
+
);
|
|
661
891
|
}
|
|
662
892
|
};
|
|
663
893
|
|
|
@@ -1818,27 +2048,41 @@ exports.PICKUP_TIME_TYPE = PICKUP_TIME_TYPE;
|
|
|
1818
2048
|
exports.QueryBuilder = QueryBuilder;
|
|
1819
2049
|
exports.SchedulingService = SchedulingService;
|
|
1820
2050
|
exports.categorizePaymentError = categorizePaymentError;
|
|
2051
|
+
exports.combine = combine;
|
|
2052
|
+
exports.combineObject = combineObject;
|
|
1821
2053
|
exports.createCimplifyClient = createCimplifyClient;
|
|
1822
2054
|
exports.detectMobileMoneyProvider = detectMobileMoneyProvider;
|
|
2055
|
+
exports.err = err;
|
|
1823
2056
|
exports.extractPriceInfo = extractPriceInfo;
|
|
2057
|
+
exports.flatMap = flatMap;
|
|
1824
2058
|
exports.formatMoney = formatMoney;
|
|
1825
2059
|
exports.formatNumberCompact = formatNumberCompact;
|
|
1826
2060
|
exports.formatPrice = formatPrice;
|
|
1827
2061
|
exports.formatPriceAdjustment = formatPriceAdjustment;
|
|
1828
2062
|
exports.formatPriceCompact = formatPriceCompact;
|
|
1829
2063
|
exports.formatProductPrice = formatProductPrice;
|
|
2064
|
+
exports.fromPromise = fromPromise;
|
|
1830
2065
|
exports.getBasePrice = getBasePrice;
|
|
1831
2066
|
exports.getCurrencySymbol = getCurrencySymbol;
|
|
1832
2067
|
exports.getDiscountPercentage = getDiscountPercentage;
|
|
1833
2068
|
exports.getDisplayPrice = getDisplayPrice;
|
|
1834
2069
|
exports.getMarkupPercentage = getMarkupPercentage;
|
|
2070
|
+
exports.getOrElse = getOrElse;
|
|
1835
2071
|
exports.getProductCurrency = getProductCurrency;
|
|
1836
2072
|
exports.isCimplifyError = isCimplifyError;
|
|
2073
|
+
exports.isErr = isErr;
|
|
2074
|
+
exports.isOk = isOk;
|
|
1837
2075
|
exports.isOnSale = isOnSale;
|
|
1838
2076
|
exports.isRetryableError = isRetryableError;
|
|
2077
|
+
exports.mapError = mapError;
|
|
2078
|
+
exports.mapResult = mapResult;
|
|
1839
2079
|
exports.normalizePaymentResponse = normalizePaymentResponse;
|
|
1840
2080
|
exports.normalizeStatusResponse = normalizeStatusResponse;
|
|
2081
|
+
exports.ok = ok;
|
|
1841
2082
|
exports.parsePrice = parsePrice;
|
|
1842
2083
|
exports.parsePricePath = parsePricePath;
|
|
1843
2084
|
exports.parsedPriceToPriceInfo = parsedPriceToPriceInfo;
|
|
1844
2085
|
exports.query = query;
|
|
2086
|
+
exports.toNullable = toNullable;
|
|
2087
|
+
exports.tryCatch = tryCatch;
|
|
2088
|
+
exports.unwrap = unwrap;
|