@spotsdev/sdk 1.5.0 → 1.5.3

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.cjs CHANGED
@@ -56,6 +56,7 @@ __export(index_exports, {
56
56
  miscKeys: () => miscKeys,
57
57
  notificationKeys: () => notificationKeys,
58
58
  orderKeys: () => orderKeys,
59
+ paymentKeys: () => paymentKeys,
59
60
  postKeys: () => postKeys,
60
61
  productKeys: () => productKeys,
61
62
  spotKeys: () => spotKeys,
@@ -102,6 +103,7 @@ __export(index_exports, {
102
103
  useNotifications: () => useNotifications,
103
104
  useOrder: () => useOrder,
104
105
  useOwnedSpots: () => useOwnedSpots,
106
+ usePaymentConfig: () => usePaymentConfig,
105
107
  usePost: () => usePost,
106
108
  usePostResponses: () => usePostResponses,
107
109
  usePostStatus: () => usePostStatus,
@@ -1225,6 +1227,25 @@ function useSpotRedemptions(spotId, params, options) {
1225
1227
  ...options
1226
1228
  });
1227
1229
  }
1230
+ var paymentKeys = {
1231
+ all: ["payments"],
1232
+ config: () => [...paymentKeys.all, "config"]
1233
+ };
1234
+ function usePaymentConfig(options) {
1235
+ return reactQuery.useQuery({
1236
+ queryKey: paymentKeys.config(),
1237
+ queryFn: async () => {
1238
+ const client = getApiClient();
1239
+ const response = await client.get(
1240
+ "/payments/config"
1241
+ );
1242
+ return response.data.data;
1243
+ },
1244
+ staleTime: 1e3 * 60 * 60,
1245
+ // 1 hour - config rarely changes
1246
+ ...options
1247
+ });
1248
+ }
1228
1249
  function useUpdateProfile(options) {
1229
1250
  const queryClient = reactQuery.useQueryClient();
1230
1251
  return reactQuery.useMutation({
@@ -1833,15 +1854,19 @@ function useRemoveDeviceToken(options) {
1833
1854
  ...options
1834
1855
  });
1835
1856
  }
1857
+ function generateSlug(name) {
1858
+ return name.toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/^-|-$/g, "").slice(0, 100);
1859
+ }
1836
1860
  function useCreateProduct(options) {
1837
1861
  const queryClient = reactQuery.useQueryClient();
1838
1862
  return reactQuery.useMutation({
1839
1863
  mutationFn: async (data) => {
1840
1864
  const client = getApiClient();
1841
- const { spotId, ...productData } = data;
1865
+ const { spotId, slug, ...productData } = data;
1866
+ const productSlug = slug || generateSlug(productData.name);
1842
1867
  const response = await client.post(
1843
1868
  `/spots/${spotId}/products`,
1844
- productData
1869
+ { ...productData, slug: productSlug }
1845
1870
  );
1846
1871
  return response.data.data;
1847
1872
  },
@@ -2026,6 +2051,7 @@ exports.getConfig = getConfig;
2026
2051
  exports.miscKeys = miscKeys;
2027
2052
  exports.notificationKeys = notificationKeys;
2028
2053
  exports.orderKeys = orderKeys;
2054
+ exports.paymentKeys = paymentKeys;
2029
2055
  exports.postKeys = postKeys;
2030
2056
  exports.productKeys = productKeys;
2031
2057
  exports.spotKeys = spotKeys;
@@ -2072,6 +2098,7 @@ exports.useMyOrders = useMyOrders;
2072
2098
  exports.useNotifications = useNotifications;
2073
2099
  exports.useOrder = useOrder;
2074
2100
  exports.useOwnedSpots = useOwnedSpots;
2101
+ exports.usePaymentConfig = usePaymentConfig;
2075
2102
  exports.usePost = usePost;
2076
2103
  exports.usePostResponses = usePostResponses;
2077
2104
  exports.usePostStatus = usePostStatus;