@cimplify/sdk 0.2.4 → 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.mjs CHANGED
@@ -1,4 +1,43 @@
1
1
  // src/types/common.ts
2
+ var ErrorCode = {
3
+ // General
4
+ UNKNOWN_ERROR: "UNKNOWN_ERROR",
5
+ NETWORK_ERROR: "NETWORK_ERROR",
6
+ TIMEOUT: "TIMEOUT",
7
+ UNAUTHORIZED: "UNAUTHORIZED",
8
+ FORBIDDEN: "FORBIDDEN",
9
+ NOT_FOUND: "NOT_FOUND",
10
+ VALIDATION_ERROR: "VALIDATION_ERROR",
11
+ // Cart
12
+ CART_EMPTY: "CART_EMPTY",
13
+ CART_EXPIRED: "CART_EXPIRED",
14
+ CART_NOT_FOUND: "CART_NOT_FOUND",
15
+ ITEM_UNAVAILABLE: "ITEM_UNAVAILABLE",
16
+ VARIANT_NOT_FOUND: "VARIANT_NOT_FOUND",
17
+ VARIANT_OUT_OF_STOCK: "VARIANT_OUT_OF_STOCK",
18
+ ADDON_REQUIRED: "ADDON_REQUIRED",
19
+ ADDON_MAX_EXCEEDED: "ADDON_MAX_EXCEEDED",
20
+ // Checkout
21
+ CHECKOUT_VALIDATION_FAILED: "CHECKOUT_VALIDATION_FAILED",
22
+ DELIVERY_ADDRESS_REQUIRED: "DELIVERY_ADDRESS_REQUIRED",
23
+ CUSTOMER_INFO_REQUIRED: "CUSTOMER_INFO_REQUIRED",
24
+ // Payment
25
+ PAYMENT_FAILED: "PAYMENT_FAILED",
26
+ PAYMENT_CANCELLED: "PAYMENT_CANCELLED",
27
+ INSUFFICIENT_FUNDS: "INSUFFICIENT_FUNDS",
28
+ CARD_DECLINED: "CARD_DECLINED",
29
+ INVALID_OTP: "INVALID_OTP",
30
+ OTP_EXPIRED: "OTP_EXPIRED",
31
+ AUTHORIZATION_FAILED: "AUTHORIZATION_FAILED",
32
+ PAYMENT_ACTION_NOT_COMPLETED: "PAYMENT_ACTION_NOT_COMPLETED",
33
+ // Scheduling
34
+ SLOT_UNAVAILABLE: "SLOT_UNAVAILABLE",
35
+ BOOKING_CONFLICT: "BOOKING_CONFLICT",
36
+ SERVICE_NOT_FOUND: "SERVICE_NOT_FOUND",
37
+ // Inventory
38
+ OUT_OF_STOCK: "OUT_OF_STOCK",
39
+ INSUFFICIENT_QUANTITY: "INSUFFICIENT_QUANTITY"
40
+ };
2
41
  var CimplifyError = class extends Error {
3
42
  constructor(code, message, retryable = false) {
4
43
  super(message);
@@ -6,7 +45,24 @@ var CimplifyError = class extends Error {
6
45
  this.retryable = retryable;
7
46
  this.name = "CimplifyError";
8
47
  }
48
+ /** User-friendly message safe to display */
49
+ get userMessage() {
50
+ return this.message;
51
+ }
9
52
  };
53
+ function isCimplifyError(error) {
54
+ return error instanceof CimplifyError;
55
+ }
56
+ function isRetryableError(error) {
57
+ if (isCimplifyError(error)) {
58
+ return error.retryable;
59
+ }
60
+ if (error instanceof Error) {
61
+ const msg = error.message.toLowerCase();
62
+ return msg.includes("network") || msg.includes("timeout") || msg.includes("fetch");
63
+ }
64
+ return false;
65
+ }
10
66
 
11
67
  // src/catalogue.ts
12
68
  var CatalogueQueries = class {
@@ -218,7 +274,91 @@ var CatalogueQueries = class {
218
274
  }
219
275
  };
220
276
 
277
+ // src/types/result.ts
278
+ function ok(value) {
279
+ return { ok: true, value };
280
+ }
281
+ function err(error) {
282
+ return { ok: false, error };
283
+ }
284
+ function isOk(result) {
285
+ return result.ok === true;
286
+ }
287
+ function isErr(result) {
288
+ return result.ok === false;
289
+ }
290
+ function mapResult(result, fn) {
291
+ return result.ok ? ok(fn(result.value)) : result;
292
+ }
293
+ function mapError(result, fn) {
294
+ return result.ok ? result : err(fn(result.error));
295
+ }
296
+ function flatMap(result, fn) {
297
+ return result.ok ? fn(result.value) : result;
298
+ }
299
+ function getOrElse(result, defaultFn) {
300
+ return result.ok ? result.value : defaultFn();
301
+ }
302
+ function unwrap(result) {
303
+ if (result.ok) {
304
+ return result.value;
305
+ }
306
+ throw result.error;
307
+ }
308
+ function toNullable(result) {
309
+ return result.ok ? result.value : void 0;
310
+ }
311
+ async function fromPromise(promise, mapError2) {
312
+ try {
313
+ const value = await promise;
314
+ return ok(value);
315
+ } catch (error) {
316
+ return err(mapError2(error));
317
+ }
318
+ }
319
+ function tryCatch(fn, mapError2) {
320
+ try {
321
+ return ok(fn());
322
+ } catch (error) {
323
+ return err(mapError2(error));
324
+ }
325
+ }
326
+ function combine(results) {
327
+ const values = [];
328
+ for (const result of results) {
329
+ if (!result.ok) {
330
+ return result;
331
+ }
332
+ values.push(result.value);
333
+ }
334
+ return ok(values);
335
+ }
336
+ function combineObject(results) {
337
+ const values = {};
338
+ for (const [key, result] of Object.entries(results)) {
339
+ if (!result.ok) {
340
+ return result;
341
+ }
342
+ values[key] = result.value;
343
+ }
344
+ return ok(values);
345
+ }
346
+
221
347
  // src/cart.ts
348
+ function toCimplifyError(error) {
349
+ if (error instanceof CimplifyError) return error;
350
+ if (error instanceof Error) {
351
+ return new CimplifyError("UNKNOWN_ERROR", error.message, false);
352
+ }
353
+ return new CimplifyError("UNKNOWN_ERROR", String(error), false);
354
+ }
355
+ async function safe(promise) {
356
+ try {
357
+ return ok(await promise);
358
+ } catch (error) {
359
+ return err(toCimplifyError(error));
360
+ }
361
+ }
222
362
  var CartOperations = class {
223
363
  constructor(client) {
224
364
  this.client = client;
@@ -231,23 +371,25 @@ var CartOperations = class {
231
371
  * This is the main method for storefront display.
232
372
  */
233
373
  async get() {
234
- return this.client.query("cart#enriched");
374
+ return safe(this.client.query("cart#enriched"));
235
375
  }
236
376
  async getRaw() {
237
- return this.client.query("cart");
377
+ return safe(this.client.query("cart"));
238
378
  }
239
379
  async getItems() {
240
- return this.client.query("cart_items");
380
+ return safe(this.client.query("cart_items"));
241
381
  }
242
382
  async getCount() {
243
- return this.client.query("cart#count");
383
+ return safe(this.client.query("cart#count"));
244
384
  }
245
385
  async getTotal() {
246
- return this.client.query("cart#total");
386
+ return safe(this.client.query("cart#total"));
247
387
  }
248
388
  async getSummary() {
249
- const cart = await this.get();
250
- return {
389
+ const cartResult = await this.get();
390
+ if (!cartResult.ok) return cartResult;
391
+ const cart = cartResult.value;
392
+ return ok({
251
393
  item_count: cart.items.length,
252
394
  total_items: cart.items.reduce((sum, item) => sum + item.quantity, 0),
253
395
  subtotal: cart.pricing.subtotal,
@@ -255,55 +397,89 @@ var CartOperations = class {
255
397
  tax_amount: cart.pricing.tax_amount,
256
398
  total: cart.pricing.total_price,
257
399
  currency: cart.pricing.currency
258
- };
400
+ });
259
401
  }
260
402
  // --------------------------------------------------------------------------
261
403
  // CART MUTATIONS
262
404
  // --------------------------------------------------------------------------
405
+ /**
406
+ * Add an item to the cart.
407
+ *
408
+ * @example
409
+ * ```typescript
410
+ * const result = await client.cart.addItem({
411
+ * item_id: "prod_burger",
412
+ * quantity: 2,
413
+ * variant_id: "var_large",
414
+ * add_on_options: ["addon_cheese", "addon_bacon"],
415
+ * });
416
+ *
417
+ * if (!result.ok) {
418
+ * switch (result.error.code) {
419
+ * case ErrorCode.ITEM_UNAVAILABLE:
420
+ * toast.error("Item no longer available");
421
+ * break;
422
+ * case ErrorCode.VARIANT_OUT_OF_STOCK:
423
+ * toast.error("Selected option is out of stock");
424
+ * break;
425
+ * }
426
+ * }
427
+ * ```
428
+ */
263
429
  async addItem(input) {
264
- return this.client.call("cart.addItem", input);
430
+ return safe(this.client.call("cart.addItem", input));
265
431
  }
266
432
  async updateItem(cartItemId, updates) {
267
- return this.client.call("cart.updateItem", {
268
- cart_item_id: cartItemId,
269
- ...updates
270
- });
433
+ return safe(
434
+ this.client.call("cart.updateItem", {
435
+ cart_item_id: cartItemId,
436
+ ...updates
437
+ })
438
+ );
271
439
  }
272
440
  async updateQuantity(cartItemId, quantity) {
273
- return this.client.call("cart.updateItemQuantity", {
274
- cart_item_id: cartItemId,
275
- quantity
276
- });
441
+ return safe(
442
+ this.client.call("cart.updateItemQuantity", {
443
+ cart_item_id: cartItemId,
444
+ quantity
445
+ })
446
+ );
277
447
  }
278
448
  async removeItem(cartItemId) {
279
- return this.client.call("cart.removeItem", {
280
- cart_item_id: cartItemId
281
- });
449
+ return safe(
450
+ this.client.call("cart.removeItem", {
451
+ cart_item_id: cartItemId
452
+ })
453
+ );
282
454
  }
283
455
  async clear() {
284
- return this.client.call("cart.clearCart");
456
+ return safe(this.client.call("cart.clearCart"));
285
457
  }
286
458
  // --------------------------------------------------------------------------
287
459
  // COUPONS & DISCOUNTS
288
460
  // --------------------------------------------------------------------------
289
461
  async applyCoupon(code) {
290
- return this.client.call("cart.applyCoupon", {
291
- coupon_code: code
292
- });
462
+ return safe(
463
+ this.client.call("cart.applyCoupon", {
464
+ coupon_code: code
465
+ })
466
+ );
293
467
  }
294
468
  async removeCoupon() {
295
- return this.client.call("cart.removeCoupon");
469
+ return safe(this.client.call("cart.removeCoupon"));
296
470
  }
297
471
  // --------------------------------------------------------------------------
298
472
  // CONVENIENCE METHODS
299
473
  // --------------------------------------------------------------------------
300
474
  async isEmpty() {
301
- const count = await this.getCount();
302
- return count === 0;
475
+ const countResult = await this.getCount();
476
+ if (!countResult.ok) return countResult;
477
+ return ok(countResult.value === 0);
303
478
  }
304
479
  async hasItem(productId, variantId) {
305
- const items = await this.getItems();
306
- return items.some((item) => {
480
+ const itemsResult = await this.getItems();
481
+ if (!itemsResult.ok) return itemsResult;
482
+ const found = itemsResult.value.some((item) => {
307
483
  const matchesProduct = item.item_id === productId;
308
484
  if (!variantId) return matchesProduct;
309
485
  const config = item.configuration;
@@ -312,10 +488,12 @@ var CartOperations = class {
312
488
  }
313
489
  return matchesProduct;
314
490
  });
491
+ return ok(found);
315
492
  }
316
493
  async findItem(productId, variantId) {
317
- const items = await this.getItems();
318
- return items.find((item) => {
494
+ const itemsResult = await this.getItems();
495
+ if (!itemsResult.ok) return itemsResult;
496
+ const found = itemsResult.value.find((item) => {
319
497
  const matchesProduct = item.item_id === productId;
320
498
  if (!variantId) return matchesProduct;
321
499
  const config = item.configuration;
@@ -324,6 +502,7 @@ var CartOperations = class {
324
502
  }
325
503
  return matchesProduct;
326
504
  });
505
+ return ok(found);
327
506
  }
328
507
  };
329
508
 
@@ -418,37 +597,88 @@ var DEFAULT_CURRENCY = "GHS";
418
597
  var DEFAULT_COUNTRY = "GHA";
419
598
 
420
599
  // src/checkout.ts
600
+ function toCimplifyError2(error) {
601
+ if (error instanceof CimplifyError) return error;
602
+ if (error instanceof Error) {
603
+ return new CimplifyError("UNKNOWN_ERROR", error.message, false);
604
+ }
605
+ return new CimplifyError("UNKNOWN_ERROR", String(error), false);
606
+ }
607
+ async function safe2(promise) {
608
+ try {
609
+ return ok(await promise);
610
+ } catch (error) {
611
+ return err(toCimplifyError2(error));
612
+ }
613
+ }
421
614
  var CheckoutService = class {
422
615
  constructor(client) {
423
616
  this.client = client;
424
617
  }
618
+ /**
619
+ * Process checkout with cart data.
620
+ *
621
+ * @example
622
+ * ```typescript
623
+ * const result = await client.checkout.process({
624
+ * cart_id: cart.id,
625
+ * customer: { name, email, phone, save_details: true },
626
+ * order_type: "pickup",
627
+ * payment_method: "mobile_money",
628
+ * mobile_money_details: { phone_number, provider: "mtn" },
629
+ * });
630
+ *
631
+ * if (!result.ok) {
632
+ * switch (result.error.code) {
633
+ * case ErrorCode.CART_EMPTY:
634
+ * toast.error("Your cart is empty");
635
+ * break;
636
+ * case ErrorCode.PAYMENT_FAILED:
637
+ * toast.error("Payment failed. Please try again.");
638
+ * break;
639
+ * }
640
+ * }
641
+ * ```
642
+ */
425
643
  async process(data) {
426
- return this.client.call(CHECKOUT_MUTATION.PROCESS, {
427
- checkout_data: data
428
- });
644
+ return safe2(
645
+ this.client.call(CHECKOUT_MUTATION.PROCESS, {
646
+ checkout_data: data
647
+ })
648
+ );
429
649
  }
430
650
  async initializePayment(orderId, method) {
431
- return this.client.call("order.initializePayment", {
432
- order_id: orderId,
433
- payment_method: method
434
- });
651
+ return safe2(
652
+ this.client.call("order.initializePayment", {
653
+ order_id: orderId,
654
+ payment_method: method
655
+ })
656
+ );
435
657
  }
436
658
  async submitAuthorization(input) {
437
- return this.client.call(PAYMENT_MUTATION.SUBMIT_AUTHORIZATION, input);
659
+ return safe2(
660
+ this.client.call(PAYMENT_MUTATION.SUBMIT_AUTHORIZATION, input)
661
+ );
438
662
  }
439
663
  async pollPaymentStatus(orderId) {
440
- return this.client.call(PAYMENT_MUTATION.CHECK_STATUS, orderId);
664
+ return safe2(
665
+ this.client.call(PAYMENT_MUTATION.CHECK_STATUS, orderId)
666
+ );
441
667
  }
442
668
  async updateOrderCustomer(orderId, customer) {
443
- return this.client.call(ORDER_MUTATION.UPDATE_CUSTOMER, {
444
- order_id: orderId,
445
- ...customer
446
- });
669
+ return safe2(
670
+ this.client.call(ORDER_MUTATION.UPDATE_CUSTOMER, {
671
+ order_id: orderId,
672
+ ...customer
673
+ })
674
+ );
447
675
  }
448
676
  async verifyPayment(orderId) {
449
- return this.client.call("order.verifyPayment", {
450
- order_id: orderId
451
- });
677
+ return safe2(
678
+ this.client.call("order.verifyPayment", {
679
+ order_id: orderId
680
+ })
681
+ );
452
682
  }
453
683
  };
454
684
 
@@ -489,117 +719,173 @@ var OrderQueries = class {
489
719
  };
490
720
 
491
721
  // src/link.ts
722
+ function toCimplifyError3(error) {
723
+ if (error instanceof CimplifyError) return error;
724
+ if (error instanceof Error) {
725
+ return new CimplifyError("UNKNOWN_ERROR", error.message, false);
726
+ }
727
+ return new CimplifyError("UNKNOWN_ERROR", String(error), false);
728
+ }
729
+ async function safe3(promise) {
730
+ try {
731
+ return ok(await promise);
732
+ } catch (error) {
733
+ return err(toCimplifyError3(error));
734
+ }
735
+ }
492
736
  var LinkService = class {
493
737
  constructor(client) {
494
738
  this.client = client;
495
739
  }
740
+ // --------------------------------------------------------------------------
741
+ // AUTHENTICATION
742
+ // --------------------------------------------------------------------------
496
743
  async requestOtp(input) {
497
- return this.client.linkPost("/v1/link/auth/request-otp", input);
744
+ return safe3(this.client.linkPost("/v1/link/auth/request-otp", input));
498
745
  }
499
746
  async verifyOtp(input) {
500
- const response = await this.client.linkPost("/v1/link/auth/verify-otp", input);
501
- if (response.session_token) {
502
- this.client.setSessionToken(response.session_token);
747
+ const result = await safe3(
748
+ this.client.linkPost("/v1/link/auth/verify-otp", input)
749
+ );
750
+ if (result.ok && result.value.session_token) {
751
+ this.client.setSessionToken(result.value.session_token);
503
752
  }
504
- return response;
753
+ return result;
505
754
  }
506
755
  async logout() {
507
- const result = await this.client.linkPost("/v1/link/auth/logout");
508
- this.client.clearSession();
756
+ const result = await safe3(this.client.linkPost("/v1/link/auth/logout"));
757
+ if (result.ok) {
758
+ this.client.clearSession();
759
+ }
509
760
  return result;
510
761
  }
762
+ // --------------------------------------------------------------------------
763
+ // STATUS & DATA
764
+ // --------------------------------------------------------------------------
511
765
  async checkStatus(contact) {
512
- return this.client.call(LINK_MUTATION.CHECK_STATUS, {
513
- contact
514
- });
766
+ return safe3(
767
+ this.client.call(LINK_MUTATION.CHECK_STATUS, {
768
+ contact
769
+ })
770
+ );
515
771
  }
516
772
  async getLinkData() {
517
- return this.client.query(LINK_QUERY.DATA);
773
+ return safe3(this.client.query(LINK_QUERY.DATA));
518
774
  }
519
775
  async getAddresses() {
520
- return this.client.query(LINK_QUERY.ADDRESSES);
776
+ return safe3(this.client.query(LINK_QUERY.ADDRESSES));
521
777
  }
522
778
  async getMobileMoney() {
523
- return this.client.query(LINK_QUERY.MOBILE_MONEY);
779
+ return safe3(this.client.query(LINK_QUERY.MOBILE_MONEY));
524
780
  }
525
781
  async getPreferences() {
526
- return this.client.query(LINK_QUERY.PREFERENCES);
782
+ return safe3(this.client.query(LINK_QUERY.PREFERENCES));
527
783
  }
784
+ // --------------------------------------------------------------------------
785
+ // ENROLLMENT
786
+ // --------------------------------------------------------------------------
528
787
  async enroll(data) {
529
- return this.client.call(LINK_MUTATION.ENROLL, data);
788
+ return safe3(this.client.call(LINK_MUTATION.ENROLL, data));
530
789
  }
531
790
  async enrollAndLinkOrder(data) {
532
- return this.client.call(LINK_MUTATION.ENROLL_AND_LINK_ORDER, data);
791
+ return safe3(
792
+ this.client.call(LINK_MUTATION.ENROLL_AND_LINK_ORDER, data)
793
+ );
533
794
  }
795
+ // --------------------------------------------------------------------------
796
+ // PREFERENCES
797
+ // --------------------------------------------------------------------------
534
798
  async updatePreferences(preferences) {
535
- return this.client.call(LINK_MUTATION.UPDATE_PREFERENCES, preferences);
799
+ return safe3(this.client.call(LINK_MUTATION.UPDATE_PREFERENCES, preferences));
536
800
  }
801
+ // --------------------------------------------------------------------------
802
+ // ADDRESSES
803
+ // --------------------------------------------------------------------------
537
804
  async createAddress(input) {
538
- return this.client.call(LINK_MUTATION.CREATE_ADDRESS, input);
805
+ return safe3(this.client.call(LINK_MUTATION.CREATE_ADDRESS, input));
539
806
  }
540
807
  async updateAddress(input) {
541
- return this.client.call(LINK_MUTATION.UPDATE_ADDRESS, input);
808
+ return safe3(this.client.call(LINK_MUTATION.UPDATE_ADDRESS, input));
542
809
  }
543
810
  async deleteAddress(addressId) {
544
- return this.client.call(LINK_MUTATION.DELETE_ADDRESS, addressId);
811
+ return safe3(this.client.call(LINK_MUTATION.DELETE_ADDRESS, addressId));
545
812
  }
546
813
  async setDefaultAddress(addressId) {
547
- return this.client.call(LINK_MUTATION.SET_DEFAULT_ADDRESS, addressId);
814
+ return safe3(this.client.call(LINK_MUTATION.SET_DEFAULT_ADDRESS, addressId));
548
815
  }
549
816
  async trackAddressUsage(addressId) {
550
- return this.client.call(LINK_MUTATION.TRACK_ADDRESS_USAGE, {
551
- address_id: addressId
552
- });
817
+ return safe3(
818
+ this.client.call(LINK_MUTATION.TRACK_ADDRESS_USAGE, {
819
+ address_id: addressId
820
+ })
821
+ );
553
822
  }
823
+ // --------------------------------------------------------------------------
824
+ // MOBILE MONEY
825
+ // --------------------------------------------------------------------------
554
826
  async createMobileMoney(input) {
555
- return this.client.call(LINK_MUTATION.CREATE_MOBILE_MONEY, input);
827
+ return safe3(this.client.call(LINK_MUTATION.CREATE_MOBILE_MONEY, input));
556
828
  }
557
829
  async deleteMobileMoney(mobileMoneyId) {
558
- return this.client.call(LINK_MUTATION.DELETE_MOBILE_MONEY, mobileMoneyId);
830
+ return safe3(this.client.call(LINK_MUTATION.DELETE_MOBILE_MONEY, mobileMoneyId));
559
831
  }
560
832
  async setDefaultMobileMoney(mobileMoneyId) {
561
- return this.client.call(LINK_MUTATION.SET_DEFAULT_MOBILE_MONEY, mobileMoneyId);
833
+ return safe3(
834
+ this.client.call(LINK_MUTATION.SET_DEFAULT_MOBILE_MONEY, mobileMoneyId)
835
+ );
562
836
  }
563
837
  async trackMobileMoneyUsage(mobileMoneyId) {
564
- return this.client.call(LINK_MUTATION.TRACK_MOBILE_MONEY_USAGE, {
565
- mobile_money_id: mobileMoneyId
566
- });
838
+ return safe3(
839
+ this.client.call(LINK_MUTATION.TRACK_MOBILE_MONEY_USAGE, {
840
+ mobile_money_id: mobileMoneyId
841
+ })
842
+ );
567
843
  }
568
844
  async verifyMobileMoney(mobileMoneyId) {
569
- return this.client.call(LINK_MUTATION.VERIFY_MOBILE_MONEY, mobileMoneyId);
845
+ return safe3(
846
+ this.client.call(LINK_MUTATION.VERIFY_MOBILE_MONEY, mobileMoneyId)
847
+ );
570
848
  }
849
+ // --------------------------------------------------------------------------
850
+ // SESSIONS
851
+ // --------------------------------------------------------------------------
571
852
  async getSessions() {
572
- return this.client.linkGet("/v1/link/sessions");
853
+ return safe3(this.client.linkGet("/v1/link/sessions"));
573
854
  }
574
855
  async revokeSession(sessionId) {
575
- return this.client.linkDelete(`/v1/link/sessions/${sessionId}`);
856
+ return safe3(this.client.linkDelete(`/v1/link/sessions/${sessionId}`));
576
857
  }
577
858
  async revokeAllSessions() {
578
- return this.client.linkDelete("/v1/link/sessions");
859
+ return safe3(this.client.linkDelete("/v1/link/sessions"));
579
860
  }
861
+ // --------------------------------------------------------------------------
862
+ // REST ALTERNATIVES (for direct API access)
863
+ // --------------------------------------------------------------------------
580
864
  async getAddressesRest() {
581
- return this.client.linkGet("/v1/link/addresses");
865
+ return safe3(this.client.linkGet("/v1/link/addresses"));
582
866
  }
583
867
  async createAddressRest(input) {
584
- return this.client.linkPost("/v1/link/addresses", input);
868
+ return safe3(this.client.linkPost("/v1/link/addresses", input));
585
869
  }
586
870
  async deleteAddressRest(addressId) {
587
- return this.client.linkDelete(`/v1/link/addresses/${addressId}`);
871
+ return safe3(this.client.linkDelete(`/v1/link/addresses/${addressId}`));
588
872
  }
589
873
  async setDefaultAddressRest(addressId) {
590
- return this.client.linkPost(`/v1/link/addresses/${addressId}/default`);
874
+ return safe3(this.client.linkPost(`/v1/link/addresses/${addressId}/default`));
591
875
  }
592
876
  async getMobileMoneyRest() {
593
- return this.client.linkGet("/v1/link/mobile-money");
877
+ return safe3(this.client.linkGet("/v1/link/mobile-money"));
594
878
  }
595
879
  async createMobileMoneyRest(input) {
596
- return this.client.linkPost("/v1/link/mobile-money", input);
880
+ return safe3(this.client.linkPost("/v1/link/mobile-money", input));
597
881
  }
598
882
  async deleteMobileMoneyRest(mobileMoneyId) {
599
- return this.client.linkDelete(`/v1/link/mobile-money/${mobileMoneyId}`);
883
+ return safe3(this.client.linkDelete(`/v1/link/mobile-money/${mobileMoneyId}`));
600
884
  }
601
885
  async setDefaultMobileMoneyRest(mobileMoneyId) {
602
- return this.client.linkPost(`/v1/link/mobile-money/${mobileMoneyId}/default`);
886
+ return safe3(
887
+ this.client.linkPost(`/v1/link/mobile-money/${mobileMoneyId}/default`)
888
+ );
603
889
  }
604
890
  };
605
891
 
@@ -1726,4 +2012,4 @@ function detectMobileMoneyProvider(phoneNumber) {
1726
2012
  return null;
1727
2013
  }
1728
2014
 
1729
- export { AUTHORIZATION_TYPE, AUTH_MUTATION, AuthService, BusinessService, CHECKOUT_MODE, CHECKOUT_MUTATION, CHECKOUT_STEP, CURRENCY_SYMBOLS, CartOperations, CatalogueQueries, CheckoutService as CheckoutOperations, CheckoutService, CimplifyClient, CimplifyError, DEFAULT_COUNTRY, DEFAULT_CURRENCY, InventoryService, LINK_MUTATION, LINK_QUERY, LinkService, LiteService, MOBILE_MONEY_PROVIDER, MOBILE_MONEY_PROVIDERS, ORDER_MUTATION, ORDER_TYPE, OrderQueries, PAYMENT_METHOD, PAYMENT_MUTATION, PAYMENT_STATE, PICKUP_TIME_TYPE, QueryBuilder, SchedulingService, categorizePaymentError, createCimplifyClient, detectMobileMoneyProvider, extractPriceInfo, formatMoney, formatNumberCompact, formatPrice, formatPriceAdjustment, formatPriceCompact, formatProductPrice, getBasePrice, getCurrencySymbol, getDiscountPercentage, getDisplayPrice, getMarkupPercentage, getProductCurrency, isOnSale, normalizePaymentResponse, normalizeStatusResponse, parsePrice, parsePricePath, parsedPriceToPriceInfo, query };
2015
+ export { AUTHORIZATION_TYPE, AUTH_MUTATION, AuthService, BusinessService, CHECKOUT_MODE, CHECKOUT_MUTATION, CHECKOUT_STEP, CURRENCY_SYMBOLS, CartOperations, CatalogueQueries, CheckoutService as CheckoutOperations, CheckoutService, CimplifyClient, CimplifyError, DEFAULT_COUNTRY, DEFAULT_CURRENCY, ErrorCode, InventoryService, LINK_MUTATION, LINK_QUERY, LinkService, LiteService, MOBILE_MONEY_PROVIDER, MOBILE_MONEY_PROVIDERS, ORDER_MUTATION, ORDER_TYPE, OrderQueries, PAYMENT_METHOD, PAYMENT_MUTATION, PAYMENT_STATE, PICKUP_TIME_TYPE, QueryBuilder, SchedulingService, categorizePaymentError, combine, combineObject, createCimplifyClient, detectMobileMoneyProvider, err, extractPriceInfo, flatMap, formatMoney, formatNumberCompact, formatPrice, formatPriceAdjustment, formatPriceCompact, formatProductPrice, fromPromise, getBasePrice, getCurrencySymbol, getDiscountPercentage, getDisplayPrice, getMarkupPercentage, getOrElse, getProductCurrency, isCimplifyError, isErr, isOk, isOnSale, isRetryableError, mapError, mapResult, normalizePaymentResponse, normalizeStatusResponse, ok, parsePrice, parsePricePath, parsedPriceToPriceInfo, query, toNullable, tryCatch, unwrap };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cimplify/sdk",
3
- "version": "0.2.4",
3
+ "version": "0.3.0",
4
4
  "description": "Cimplify Commerce SDK for storefronts",
5
5
  "keywords": [
6
6
  "cimplify",