@smartbills/react-hooks-sdk 0.0.2-alpha.28 → 0.0.2-alpha.30

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.
Files changed (28) hide show
  1. package/dist/@types/index.d.ts +21 -7
  2. package/dist/cjs/apis/SBApiKeys.cjs +4 -0
  3. package/dist/cjs/apis/SBApiKeys.cjs.map +1 -1
  4. package/dist/cjs/apis/customers/CustomerAPI.cjs +29 -40
  5. package/dist/cjs/apis/customers/CustomerAPI.cjs.map +1 -1
  6. package/dist/cjs/apis/customers/CustomerBalanceTransactionsAPI.cjs +26 -0
  7. package/dist/cjs/apis/customers/CustomerBalanceTransactionsAPI.cjs.map +1 -0
  8. package/dist/cjs/apis/customers/CustomerPaymentMethodsAPI.cjs +26 -0
  9. package/dist/cjs/apis/customers/CustomerPaymentMethodsAPI.cjs.map +1 -0
  10. package/dist/cjs/apis/vendors/VendorsAPI.cjs +106 -0
  11. package/dist/cjs/apis/vendors/VendorsAPI.cjs.map +1 -0
  12. package/dist/cjs/index.cjs +11 -1
  13. package/dist/cjs/index.cjs.map +1 -1
  14. package/dist/esm/apis/SBApiKeys.mjs +4 -0
  15. package/dist/esm/apis/SBApiKeys.mjs.map +1 -1
  16. package/dist/esm/apis/customers/CustomerAPI.mjs +30 -40
  17. package/dist/esm/apis/customers/CustomerAPI.mjs.map +1 -1
  18. package/dist/esm/apis/customers/CustomerBalanceTransactionsAPI.mjs +23 -0
  19. package/dist/esm/apis/customers/CustomerBalanceTransactionsAPI.mjs.map +1 -0
  20. package/dist/esm/apis/customers/CustomerPaymentMethodsAPI.mjs +23 -0
  21. package/dist/esm/apis/customers/CustomerPaymentMethodsAPI.mjs.map +1 -0
  22. package/dist/esm/apis/vendors/VendorsAPI.mjs +101 -0
  23. package/dist/esm/apis/vendors/VendorsAPI.mjs.map +1 -0
  24. package/dist/esm/index.mjs +4 -1
  25. package/dist/esm/index.mjs.map +1 -1
  26. package/dist/umd/index.js +168 -40
  27. package/dist/umd/index.js.map +1 -1
  28. package/package.json +4 -4
package/dist/umd/index.js CHANGED
@@ -29,6 +29,9 @@
29
29
  SBApiKeys["BankTransactions"] = "BANK_TRANSACTIONS";
30
30
  SBApiKeys["BankInstitutions"] = "BANK_INSTITUTIONS";
31
31
  SBApiKeys["Cards"] = "CARDS";
32
+ SBApiKeys["Customers"] = "CUSTOMERS";
33
+ SBApiKeys["CustomerPaymentMethods"] = "CUSTOMER_PAYMENT_METHODS";
34
+ SBApiKeys["CustomerBalanceTransactions"] = "CUSTOMER_BALANCE_TRANSACTIONS";
32
35
  SBApiKeys["CardSetupIntents"] = "CARDS_SETUP_INTENTS";
33
36
  SBApiKeys["Documents"] = "DOCUMENTS";
34
37
  SBApiKeys["Organizations"] = "ORGANIZATIONS";
@@ -42,6 +45,7 @@
42
45
  SBApiKeys["PaymentMethods"] = "PAYMENT_METHODS";
43
46
  SBApiKeys["Taxes"] = "TAXES";
44
47
  SBApiKeys["Friends"] = "FRIENDS";
48
+ SBApiKeys["Vendors"] = "VENDORS";
45
49
  })(SBApiKeys || (SBApiKeys = {}));
46
50
 
47
51
  const useGetLogById = (id, options, config) => {
@@ -646,11 +650,10 @@
646
650
  });
647
651
  };
648
652
 
649
- const CUSTOMER_KEY = "customers";
650
653
  const useGetCustomerById = (id, options) => {
651
654
  const client = useApiClient();
652
655
  return reactQuery.useQuery({
653
- queryKey: [CUSTOMER_KEY, id],
656
+ queryKey: [SBApiKeys.Customers, id],
654
657
  queryFn: async () => {
655
658
  try {
656
659
  return await client.customers.getById(id, options);
@@ -660,17 +663,11 @@
660
663
  }
661
664
  });
662
665
  };
663
- const useListCustomers = (request, options) => {
666
+ const useListCustomers = (request, options, config) => {
664
667
  const client = useApiClient();
665
668
  return reactQuery.useInfiniteQuery({
666
- queryKey: [CUSTOMER_KEY],
667
- queryFn: async () => {
668
- try {
669
- return await client.customers.list(request, options);
670
- } catch (exception) {
671
- throw exception;
672
- }
673
- },
669
+ queryKey: [SBApiKeys.Customers],
670
+ queryFn: async () => await client.customers.list(request, options, config),
674
671
  initialPageParam: 1,
675
672
  getNextPageParam: (lastPage, allPages, lastPageParam) => {
676
673
  if (lastPage.pagination.currentPage === lastPage.pagination.pageCount) {
@@ -686,71 +683,101 @@
686
683
  }
687
684
  });
688
685
  };
689
- const useCreateCustomerMutation = (request, options) => {
686
+ const useCreateCustomerMutation = () => {
690
687
  const client = useApiClient();
691
688
  return reactQuery.useMutation({
692
- mutationKey: [CUSTOMER_KEY],
693
- mutationFn: async () => {
694
- try {
695
- return await client.customers.create(request, options);
696
- } catch (exception) {
697
- throw exception;
698
- }
699
- },
700
- onMutate: async Customer => {
689
+ mutationKey: [SBApiKeys.Customers],
690
+ mutationFn: client.customers.create,
691
+ onMutate: async customer => {
701
692
  await queryClient.cancelQueries({
702
- queryKey: [CUSTOMER_KEY]
693
+ queryKey: [SBApiKeys.Customers]
703
694
  });
704
- const previousTodos = queryClient.getQueryData([CUSTOMER_KEY]);
705
- // queryClient.setQueryData([CUSTOMER_KEY], (old) => [...old, newTodo])
695
+ const previousTodos = queryClient.getQueryData([SBApiKeys.Customers]);
696
+ // queryClient.setQueryData([SBApiKeys.Customers], (old) => [...old, newTodo])
706
697
  // Return a context object with the snapshotted value
707
698
  return {
708
699
  previousTodos
709
700
  };
710
701
  },
711
702
  onError: (err, newTodo, context) => {
712
- queryClient.setQueryData([CUSTOMER_KEY], context.previousTodos);
703
+ queryClient.setQueryData([SBApiKeys.Customers], context.previousTodos);
713
704
  },
714
705
  onSettled: () => {
715
706
  queryClient.invalidateQueries({
716
- queryKey: [CUSTOMER_KEY]
707
+ queryKey: [SBApiKeys.Customers]
717
708
  });
718
709
  }
719
710
  });
720
711
  };
721
- const useDeleteCustomerMutation = (id, options) => {
712
+ const useDeleteCustomerMutation = () => {
722
713
  const client = useApiClient();
723
714
  return reactQuery.useMutation({
724
- mutationKey: [CUSTOMER_KEY, id],
725
- mutationFn: async () => {
726
- try {
727
- return await client.customers.delete(id, options);
728
- } catch (exception) {
729
- throw exception;
730
- }
715
+ mutationKey: [SBApiKeys.Customers],
716
+ mutationFn: client.customers.delete,
717
+ onSuccess: async (response, id) => {
718
+ await queryClient.invalidateQueries({
719
+ queryKey: [SBApiKeys.Customers, id]
720
+ });
721
+ queryClient.removeQueries({
722
+ queryKey: [SBApiKeys.Customers, id]
723
+ });
731
724
  },
732
725
  onMutate: async Customer => {
733
726
  await queryClient.cancelQueries({
734
- queryKey: [CUSTOMER_KEY]
727
+ queryKey: [SBApiKeys.Customers]
735
728
  });
736
- const previousTodos = queryClient.getQueryData([CUSTOMER_KEY]);
737
- // queryClient.setQueryData([CUSTOMER_KEY], (old) => [...old, newTodo])
729
+ const previousTodos = queryClient.getQueryData([SBApiKeys.Customers]);
730
+ // queryClient.setQueryData([SBApiKeys.Customers], (old) => [...old, newTodo])
738
731
  // Return a context object with the snapshotted value
739
732
  return {
740
733
  previousTodos
741
734
  };
742
735
  },
743
736
  onError: (err, newTodo, context) => {
744
- queryClient.setQueryData([CUSTOMER_KEY], context.previousTodos);
737
+ queryClient.setQueryData([SBApiKeys.Customers], context.previousTodos);
745
738
  },
746
739
  onSettled: () => {
747
740
  queryClient.invalidateQueries({
748
- queryKey: [CUSTOMER_KEY]
741
+ queryKey: [SBApiKeys.Customers]
749
742
  });
750
743
  }
751
744
  });
752
745
  };
753
746
 
747
+ const useListCustomerPaymentMethods = (customerId, request, options, config, queryOptions) => {
748
+ const client = useApiClient();
749
+ return reactQuery.useQuery({
750
+ queryKey: [SBApiKeys.Customers, customerId, SBApiKeys.CustomerPaymentMethods],
751
+ queryFn: async () => await client.customers.listPaymentMethods(customerId, request, options, config),
752
+ ...queryOptions
753
+ });
754
+ };
755
+ const useGetCustomerPaymentMethodById = (customerId, id, options, config, queryOptions) => {
756
+ const client = useApiClient();
757
+ return reactQuery.useQuery({
758
+ queryKey: [SBApiKeys.Customers, customerId, SBApiKeys.CustomerPaymentMethods, id],
759
+ queryFn: async () => await client.customers.retrievePaymentMethod(customerId, id, options, config),
760
+ ...queryOptions
761
+ });
762
+ };
763
+
764
+ const useListCustomerBalanceTransactions = (customerId, request, options, config, queryOptions) => {
765
+ const client = useApiClient();
766
+ return reactQuery.useQuery({
767
+ queryKey: [SBApiKeys.Customers, customerId, SBApiKeys.CustomerBalanceTransactions],
768
+ queryFn: async () => await client.customers.listBalanceTransactions(customerId, request, options, config),
769
+ ...queryOptions
770
+ });
771
+ };
772
+ const useRetrieveCustomerBalanceTransaction = (customerId, id, options, config, queryOptions) => {
773
+ const client = useApiClient();
774
+ return reactQuery.useQuery({
775
+ queryKey: [SBApiKeys.Customers, customerId, SBApiKeys.CustomerBalanceTransactions, id],
776
+ queryFn: async () => await client.customers.retrieveBalanceTransaction(customerId, id, options, config),
777
+ ...queryOptions
778
+ });
779
+ };
780
+
754
781
  const useListDomains = (request, options, config) => {
755
782
  const client = useApiClient();
756
783
  return reactQuery.useInfiniteQuery({
@@ -1467,11 +1494,104 @@
1467
1494
  });
1468
1495
  };
1469
1496
 
1497
+ const useGetVendorById = (id, options) => {
1498
+ const client = useApiClient();
1499
+ return reactQuery.useQuery({
1500
+ queryKey: [SBApiKeys.Vendors, id],
1501
+ queryFn: async () => {
1502
+ try {
1503
+ return await client.vendors.getById(id, options);
1504
+ } catch (exception) {
1505
+ throw exception;
1506
+ }
1507
+ }
1508
+ });
1509
+ };
1510
+ const useListVendors = (request, options, config) => {
1511
+ const client = useApiClient();
1512
+ return reactQuery.useInfiniteQuery({
1513
+ queryKey: [SBApiKeys.Vendors],
1514
+ queryFn: async () => await client.vendors.list(request, options, config),
1515
+ initialPageParam: 1,
1516
+ getNextPageParam: (lastPage, allPages, lastPageParam) => {
1517
+ if (lastPage.pagination.currentPage === lastPage.pagination.pageCount) {
1518
+ return undefined;
1519
+ }
1520
+ return lastPageParam + 1;
1521
+ },
1522
+ getPreviousPageParam: (firstPage, allPages, firstPageParam) => {
1523
+ if (firstPage.pagination.currentPage <= 1) {
1524
+ return undefined;
1525
+ }
1526
+ return firstPageParam - 1;
1527
+ }
1528
+ });
1529
+ };
1530
+ const useCreateVendorMutation = () => {
1531
+ const client = useApiClient();
1532
+ return reactQuery.useMutation({
1533
+ mutationKey: [SBApiKeys.Vendors],
1534
+ mutationFn: client.vendors.create,
1535
+ onMutate: async vendor => {
1536
+ await queryClient.cancelQueries({
1537
+ queryKey: [SBApiKeys.Vendors]
1538
+ });
1539
+ const previousTodos = queryClient.getQueryData([SBApiKeys.Vendors]);
1540
+ // queryClient.setQueryData([SBApiKeys.Vendors], (old) => [...old, newTodo])
1541
+ // Return a context object with the snapshotted value
1542
+ return {
1543
+ previousTodos
1544
+ };
1545
+ },
1546
+ onError: (err, newTodo, context) => {
1547
+ queryClient.setQueryData([SBApiKeys.Vendors], context.previousTodos);
1548
+ },
1549
+ onSettled: () => {
1550
+ queryClient.invalidateQueries({
1551
+ queryKey: [SBApiKeys.Vendors]
1552
+ });
1553
+ }
1554
+ });
1555
+ };
1556
+ const useDeleteVendorMutation = () => {
1557
+ const client = useApiClient();
1558
+ return reactQuery.useMutation({
1559
+ mutationKey: [SBApiKeys.Vendors],
1560
+ mutationFn: client.vendors.delete,
1561
+ onSuccess: async (response, id) => {
1562
+ await queryClient.invalidateQueries({
1563
+ queryKey: [SBApiKeys.Vendors, id]
1564
+ });
1565
+ queryClient.removeQueries({
1566
+ queryKey: [SBApiKeys.Vendors, id]
1567
+ });
1568
+ },
1569
+ onMutate: async Vendor => {
1570
+ await queryClient.cancelQueries({
1571
+ queryKey: [SBApiKeys.Vendors]
1572
+ });
1573
+ const previousTodos = queryClient.getQueryData([SBApiKeys.Vendors]);
1574
+ // queryClient.setQueryData([SBApiKeys.Vendors], (old) => [...old, newTodo])
1575
+ // Return a context object with the snapshotted value
1576
+ return {
1577
+ previousTodos
1578
+ };
1579
+ },
1580
+ onError: (err, newTodo, context) => {
1581
+ queryClient.setQueryData([SBApiKeys.Vendors], context.previousTodos);
1582
+ },
1583
+ onSettled: () => {
1584
+ queryClient.invalidateQueries({
1585
+ queryKey: [SBApiKeys.Vendors]
1586
+ });
1587
+ }
1588
+ });
1589
+ };
1590
+
1470
1591
  exports.ApiClientProvider = ApiClientProvider;
1471
1592
  exports.BANKS_KEY = BANKS_KEY;
1472
1593
  exports.BANK_ACCOUNTS_KEY = BANK_ACCOUNTS_KEY;
1473
1594
  exports.BANK_TRANSACTIONS_KEY = BANK_TRANSACTIONS_KEY;
1474
- exports.CUSTOMER_KEY = CUSTOMER_KEY;
1475
1595
  exports.RECEIPTS_KEY = RECEIPTS_KEY;
1476
1596
  exports.REVIEWS_KEY = REVIEWS_KEY;
1477
1597
  exports.SmartbillsSDKProvider = SmartbillsSDKProvider;
@@ -1492,6 +1612,7 @@
1492
1612
  exports.useCreatePromoCodeMutation = useCreatePromoCodeMutation;
1493
1613
  exports.useCreateReviewMutation = useCreateReviewMutation;
1494
1614
  exports.useCreateTaxMutation = useCreateTaxMutation;
1615
+ exports.useCreateVendorMutation = useCreateVendorMutation;
1495
1616
  exports.useDeleteBankMutation = useDeleteBankMutation;
1496
1617
  exports.useDeleteCustomerMutation = useDeleteCustomerMutation;
1497
1618
  exports.useDeleteDocumentMutation = useDeleteDocumentMutation;
@@ -1506,6 +1627,7 @@
1506
1627
  exports.useDeleteReceiptMutation = useDeleteReceiptMutation;
1507
1628
  exports.useDeleteReviewMutation = useDeleteReviewMutation;
1508
1629
  exports.useDeleteTaxMutation = useDeleteTaxMutation;
1630
+ exports.useDeleteVendorMutation = useDeleteVendorMutation;
1509
1631
  exports.useDetachCardMutation = useDetachCardMutation;
1510
1632
  exports.useGetAuthorizationCodeMutation = useGetAuthorizationCodeMutation;
1511
1633
  exports.useGetBankAccountById = useGetBankAccountById;
@@ -1521,6 +1643,7 @@
1521
1643
  exports.useGetCards = useGetCards;
1522
1644
  exports.useGetCurrentUser = useGetCurrentUser;
1523
1645
  exports.useGetCustomerById = useGetCustomerById;
1646
+ exports.useGetCustomerPaymentMethodById = useGetCustomerPaymentMethodById;
1524
1647
  exports.useGetDocument = useGetDocument;
1525
1648
  exports.useGetDomainById = useGetDomainById;
1526
1649
  exports.useGetLocationById = useGetLocationById;
@@ -1535,9 +1658,12 @@
1535
1658
  exports.useGetReviewById = useGetReviewById;
1536
1659
  exports.useGetTaxById = useGetTaxById;
1537
1660
  exports.useGetTokenMutation = useGetTokenMutation;
1661
+ exports.useGetVendorById = useGetVendorById;
1538
1662
  exports.useListBankAccountTransactions = useListBankAccountTransactions;
1539
1663
  exports.useListBankAccountTransanctions = useListBankAccountTransanctions;
1540
1664
  exports.useListBankTransactions = useListBankTransactions;
1665
+ exports.useListCustomerBalanceTransactions = useListCustomerBalanceTransactions;
1666
+ exports.useListCustomerPaymentMethods = useListCustomerPaymentMethods;
1541
1667
  exports.useListCustomers = useListCustomers;
1542
1668
  exports.useListDocuments = useListDocuments;
1543
1669
  exports.useListDomains = useListDomains;
@@ -1552,7 +1678,9 @@
1552
1678
  exports.useListRecommandedFriends = useListRecommandedFriends;
1553
1679
  exports.useListReviews = useListReviews;
1554
1680
  exports.useListTaxes = useListTaxes;
1681
+ exports.useListVendors = useListVendors;
1555
1682
  exports.useRefreshTokenMutation = useRefreshTokenMutation;
1683
+ exports.useRetrieveCustomerBalanceTransaction = useRetrieveCustomerBalanceTransaction;
1556
1684
  exports.useSearchUsers = useSearchUsers;
1557
1685
  exports.useSetupPaymentMethodMutation = useSetupPaymentMethodMutation;
1558
1686
  exports.useUpdateLocationMutation = useUpdateLocationMutation;