@smartbills/react-hooks-sdk 0.0.2-alpha.29 → 0.0.2-alpha.31

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 +19 -5
  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 +19 -20
  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 +20 -20
  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 +158 -20
  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,11 +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: client.customers.list,
669
+ queryKey: [SBApiKeys.Customers],
670
+ queryFn: async () => await client.customers.list(request, options, config),
668
671
  initialPageParam: 1,
669
672
  getNextPageParam: (lastPage, allPages, lastPageParam) => {
670
673
  if (lastPage.pagination.currentPage === lastPage.pagination.pageCount) {
@@ -683,25 +686,25 @@
683
686
  const useCreateCustomerMutation = () => {
684
687
  const client = useApiClient();
685
688
  return reactQuery.useMutation({
686
- mutationKey: [CUSTOMER_KEY],
689
+ mutationKey: [SBApiKeys.Customers],
687
690
  mutationFn: client.customers.create,
688
691
  onMutate: async customer => {
689
692
  await queryClient.cancelQueries({
690
- queryKey: [CUSTOMER_KEY]
693
+ queryKey: [SBApiKeys.Customers]
691
694
  });
692
- const previousTodos = queryClient.getQueryData([CUSTOMER_KEY]);
693
- // queryClient.setQueryData([CUSTOMER_KEY], (old) => [...old, newTodo])
695
+ const previousTodos = queryClient.getQueryData([SBApiKeys.Customers]);
696
+ // queryClient.setQueryData([SBApiKeys.Customers], (old) => [...old, newTodo])
694
697
  // Return a context object with the snapshotted value
695
698
  return {
696
699
  previousTodos
697
700
  };
698
701
  },
699
702
  onError: (err, newTodo, context) => {
700
- queryClient.setQueryData([CUSTOMER_KEY], context.previousTodos);
703
+ queryClient.setQueryData([SBApiKeys.Customers], context.previousTodos);
701
704
  },
702
705
  onSettled: () => {
703
706
  queryClient.invalidateQueries({
704
- queryKey: [CUSTOMER_KEY]
707
+ queryKey: [SBApiKeys.Customers]
705
708
  });
706
709
  }
707
710
  });
@@ -709,38 +712,72 @@
709
712
  const useDeleteCustomerMutation = () => {
710
713
  const client = useApiClient();
711
714
  return reactQuery.useMutation({
712
- mutationKey: [CUSTOMER_KEY],
715
+ mutationKey: [SBApiKeys.Customers],
713
716
  mutationFn: client.customers.delete,
714
717
  onSuccess: async (response, id) => {
715
718
  await queryClient.invalidateQueries({
716
- queryKey: [CUSTOMER_KEY, id]
719
+ queryKey: [SBApiKeys.Customers, id]
717
720
  });
718
721
  queryClient.removeQueries({
719
- queryKey: [CUSTOMER_KEY, id]
722
+ queryKey: [SBApiKeys.Customers, id]
720
723
  });
721
724
  },
722
725
  onMutate: async Customer => {
723
726
  await queryClient.cancelQueries({
724
- queryKey: [CUSTOMER_KEY]
727
+ queryKey: [SBApiKeys.Customers]
725
728
  });
726
- const previousTodos = queryClient.getQueryData([CUSTOMER_KEY]);
727
- // queryClient.setQueryData([CUSTOMER_KEY], (old) => [...old, newTodo])
729
+ const previousTodos = queryClient.getQueryData([SBApiKeys.Customers]);
730
+ // queryClient.setQueryData([SBApiKeys.Customers], (old) => [...old, newTodo])
728
731
  // Return a context object with the snapshotted value
729
732
  return {
730
733
  previousTodos
731
734
  };
732
735
  },
733
736
  onError: (err, newTodo, context) => {
734
- queryClient.setQueryData([CUSTOMER_KEY], context.previousTodos);
737
+ queryClient.setQueryData([SBApiKeys.Customers], context.previousTodos);
735
738
  },
736
739
  onSettled: () => {
737
740
  queryClient.invalidateQueries({
738
- queryKey: [CUSTOMER_KEY]
741
+ queryKey: [SBApiKeys.Customers]
739
742
  });
740
743
  }
741
744
  });
742
745
  };
743
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
+
744
781
  const useListDomains = (request, options, config) => {
745
782
  const client = useApiClient();
746
783
  return reactQuery.useInfiniteQuery({
@@ -1457,11 +1494,104 @@
1457
1494
  });
1458
1495
  };
1459
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
+
1460
1591
  exports.ApiClientProvider = ApiClientProvider;
1461
1592
  exports.BANKS_KEY = BANKS_KEY;
1462
1593
  exports.BANK_ACCOUNTS_KEY = BANK_ACCOUNTS_KEY;
1463
1594
  exports.BANK_TRANSACTIONS_KEY = BANK_TRANSACTIONS_KEY;
1464
- exports.CUSTOMER_KEY = CUSTOMER_KEY;
1465
1595
  exports.RECEIPTS_KEY = RECEIPTS_KEY;
1466
1596
  exports.REVIEWS_KEY = REVIEWS_KEY;
1467
1597
  exports.SmartbillsSDKProvider = SmartbillsSDKProvider;
@@ -1482,6 +1612,7 @@
1482
1612
  exports.useCreatePromoCodeMutation = useCreatePromoCodeMutation;
1483
1613
  exports.useCreateReviewMutation = useCreateReviewMutation;
1484
1614
  exports.useCreateTaxMutation = useCreateTaxMutation;
1615
+ exports.useCreateVendorMutation = useCreateVendorMutation;
1485
1616
  exports.useDeleteBankMutation = useDeleteBankMutation;
1486
1617
  exports.useDeleteCustomerMutation = useDeleteCustomerMutation;
1487
1618
  exports.useDeleteDocumentMutation = useDeleteDocumentMutation;
@@ -1496,6 +1627,7 @@
1496
1627
  exports.useDeleteReceiptMutation = useDeleteReceiptMutation;
1497
1628
  exports.useDeleteReviewMutation = useDeleteReviewMutation;
1498
1629
  exports.useDeleteTaxMutation = useDeleteTaxMutation;
1630
+ exports.useDeleteVendorMutation = useDeleteVendorMutation;
1499
1631
  exports.useDetachCardMutation = useDetachCardMutation;
1500
1632
  exports.useGetAuthorizationCodeMutation = useGetAuthorizationCodeMutation;
1501
1633
  exports.useGetBankAccountById = useGetBankAccountById;
@@ -1511,6 +1643,7 @@
1511
1643
  exports.useGetCards = useGetCards;
1512
1644
  exports.useGetCurrentUser = useGetCurrentUser;
1513
1645
  exports.useGetCustomerById = useGetCustomerById;
1646
+ exports.useGetCustomerPaymentMethodById = useGetCustomerPaymentMethodById;
1514
1647
  exports.useGetDocument = useGetDocument;
1515
1648
  exports.useGetDomainById = useGetDomainById;
1516
1649
  exports.useGetLocationById = useGetLocationById;
@@ -1525,9 +1658,12 @@
1525
1658
  exports.useGetReviewById = useGetReviewById;
1526
1659
  exports.useGetTaxById = useGetTaxById;
1527
1660
  exports.useGetTokenMutation = useGetTokenMutation;
1661
+ exports.useGetVendorById = useGetVendorById;
1528
1662
  exports.useListBankAccountTransactions = useListBankAccountTransactions;
1529
1663
  exports.useListBankAccountTransanctions = useListBankAccountTransanctions;
1530
1664
  exports.useListBankTransactions = useListBankTransactions;
1665
+ exports.useListCustomerBalanceTransactions = useListCustomerBalanceTransactions;
1666
+ exports.useListCustomerPaymentMethods = useListCustomerPaymentMethods;
1531
1667
  exports.useListCustomers = useListCustomers;
1532
1668
  exports.useListDocuments = useListDocuments;
1533
1669
  exports.useListDomains = useListDomains;
@@ -1542,7 +1678,9 @@
1542
1678
  exports.useListRecommandedFriends = useListRecommandedFriends;
1543
1679
  exports.useListReviews = useListReviews;
1544
1680
  exports.useListTaxes = useListTaxes;
1681
+ exports.useListVendors = useListVendors;
1545
1682
  exports.useRefreshTokenMutation = useRefreshTokenMutation;
1683
+ exports.useRetrieveCustomerBalanceTransaction = useRetrieveCustomerBalanceTransaction;
1546
1684
  exports.useSearchUsers = useSearchUsers;
1547
1685
  exports.useSetupPaymentMethodMutation = useSetupPaymentMethodMutation;
1548
1686
  exports.useUpdateLocationMutation = useUpdateLocationMutation;