@squonk/account-server-client 1.0.2-rc.3 → 1.0.3-rc.1

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 (48) hide show
  1. package/asset/asset.cjs +34 -18
  2. package/asset/asset.cjs.map +1 -1
  3. package/asset/asset.d.ts +16 -16
  4. package/asset/asset.js +35 -19
  5. package/asset/asset.js.map +1 -1
  6. package/{custom-instance-b8075093.d.ts → custom-instance-93fb01eb.d.ts} +22 -20
  7. package/index.cjs.map +1 -1
  8. package/index.d.ts +1 -1
  9. package/index.js.map +1 -1
  10. package/merchant/merchant.cjs +15 -13
  11. package/merchant/merchant.cjs.map +1 -1
  12. package/merchant/merchant.d.ts +1 -1
  13. package/merchant/merchant.js +16 -14
  14. package/merchant/merchant.js.map +1 -1
  15. package/organisation/organisation.cjs +18 -6
  16. package/organisation/organisation.cjs.map +1 -1
  17. package/organisation/organisation.d.ts +7 -7
  18. package/organisation/organisation.js +19 -7
  19. package/organisation/organisation.js.map +1 -1
  20. package/package.json +1 -1
  21. package/product/product.cjs +47 -38
  22. package/product/product.cjs.map +1 -1
  23. package/product/product.d.ts +10 -10
  24. package/product/product.js +48 -39
  25. package/product/product.js.map +1 -1
  26. package/src/account-server-api.schemas.ts +73 -87
  27. package/src/asset/asset.ts +248 -345
  28. package/src/merchant/merchant.ts +62 -84
  29. package/src/organisation/organisation.ts +131 -184
  30. package/src/product/product.ts +279 -422
  31. package/src/state/state.ts +36 -42
  32. package/src/unit/unit.ts +218 -301
  33. package/src/user/user.ts +224 -327
  34. package/state/state.cjs +9 -9
  35. package/state/state.cjs.map +1 -1
  36. package/state/state.d.ts +1 -1
  37. package/state/state.js +10 -10
  38. package/state/state.js.map +1 -1
  39. package/unit/unit.cjs +40 -25
  40. package/unit/unit.cjs.map +1 -1
  41. package/unit/unit.d.ts +10 -10
  42. package/unit/unit.js +41 -26
  43. package/unit/unit.js.map +1 -1
  44. package/user/user.cjs +38 -20
  45. package/user/user.cjs.map +1 -1
  46. package/user/user.d.ts +10 -10
  47. package/user/user.js +39 -21
  48. package/user/user.js.map +1 -1
@@ -8,15 +8,18 @@ A service that provides access to the Account Server, which gives *registered* u
8
8
 
9
9
  * OpenAPI spec version: 1.0
10
10
  */
11
- import { useQuery, useMutation } from "react-query";
11
+ import {
12
+ useQuery,
13
+ useMutation
14
+ } from 'react-query'
12
15
  import type {
13
16
  UseQueryOptions,
14
17
  UseMutationOptions,
15
18
  QueryFunction,
16
19
  MutationFunction,
17
20
  UseQueryResult,
18
- QueryKey,
19
- } from "react-query";
21
+ QueryKey
22
+ } from 'react-query'
20
23
  import type {
21
24
  ProductsGetTypesResponse,
22
25
  AsError,
@@ -26,15 +29,16 @@ import type {
26
29
  ProductUnitGetResponse,
27
30
  ProductPatchBodyBody,
28
31
  ProductChargesGetResponse,
29
- GetProductChargesParams,
30
- } from "../account-server-api.schemas";
31
- import { customInstance } from ".././custom-instance";
32
- import type { ErrorType } from ".././custom-instance";
32
+ GetProductChargesParams
33
+ } from '../account-server-api.schemas'
34
+ import { customInstance } from '.././custom-instance'
35
+ import type { ErrorType } from '.././custom-instance'
36
+
33
37
 
34
38
  // eslint-disable-next-line
35
- type SecondParameter<T extends (...args: any) => any> = T extends (
39
+ type SecondParameter<T extends (...args: any) => any> = T extends (
36
40
  config: any,
37
- args: infer P
41
+ args: infer P,
38
42
  ) => any
39
43
  ? P
40
44
  : never;
@@ -45,53 +49,41 @@ type SecondParameter<T extends (...args: any) => any> = T extends (
45
49
  * @summary Gets all Product Types
46
50
  */
47
51
  export const getProductTypes = (
48
- options?: SecondParameter<typeof customInstance>,
49
- signal?: AbortSignal
52
+
53
+ options?: SecondParameter<typeof customInstance>,signal?: AbortSignal
50
54
  ) => {
51
- return customInstance<ProductsGetTypesResponse>(
52
- { url: `/product-type`, method: "get", signal },
53
- options
54
- );
55
- };
55
+ return customInstance<ProductsGetTypesResponse>(
56
+ {url: `/product-type`, method: 'get', signal
57
+ },
58
+ options);
59
+ }
60
+
56
61
 
57
62
  export const getGetProductTypesQueryKey = () => [`/product-type`];
58
63
 
59
- export type GetProductTypesQueryResult = NonNullable<
60
- Awaited<ReturnType<typeof getProductTypes>>
61
- >;
62
- export type GetProductTypesQueryError = ErrorType<AsError | void>;
63
-
64
- export const useGetProductTypes = <
65
- TData = Awaited<ReturnType<typeof getProductTypes>>,
66
- TError = ErrorType<AsError | void>
67
- >(options?: {
68
- query?: UseQueryOptions<
69
- Awaited<ReturnType<typeof getProductTypes>>,
70
- TError,
71
- TData
72
- >;
73
- request?: SecondParameter<typeof customInstance>;
74
- }): UseQueryResult<TData, TError> & { queryKey: QueryKey } => {
75
- const { query: queryOptions, request: requestOptions } = options ?? {};
64
+
65
+ export type GetProductTypesQueryResult = NonNullable<Awaited<ReturnType<typeof getProductTypes>>>
66
+ export type GetProductTypesQueryError = ErrorType<AsError | void>
67
+
68
+ export const useGetProductTypes = <TData = Awaited<ReturnType<typeof getProductTypes>>, TError = ErrorType<AsError | void>>(
69
+ options?: { query?:UseQueryOptions<Awaited<ReturnType<typeof getProductTypes>>, TError, TData>, request?: SecondParameter<typeof customInstance>}
70
+
71
+ ): UseQueryResult<TData, TError> & { queryKey: QueryKey } => {
72
+
73
+ const {query: queryOptions, request: requestOptions} = options ?? {}
76
74
 
77
75
  const queryKey = queryOptions?.queryKey ?? getGetProductTypesQueryKey();
78
76
 
79
- const queryFn: QueryFunction<Awaited<ReturnType<typeof getProductTypes>>> = ({
80
- signal,
81
- }) => getProductTypes(requestOptions, signal);
77
+
78
+
79
+ const queryFn: QueryFunction<Awaited<ReturnType<typeof getProductTypes>>> = ({ signal }) => getProductTypes(requestOptions, signal);
82
80
 
83
- const query = useQuery<
84
- Awaited<ReturnType<typeof getProductTypes>>,
85
- TError,
86
- TData
87
- >(queryKey, queryFn, queryOptions) as UseQueryResult<TData, TError> & {
88
- queryKey: QueryKey;
89
- };
81
+ const query = useQuery<Awaited<ReturnType<typeof getProductTypes>>, TError, TData>(queryKey, queryFn, queryOptions) as UseQueryResult<TData, TError> & { queryKey: QueryKey };
90
82
 
91
83
  query.queryKey = queryKey;
92
84
 
93
85
  return query;
94
- };
86
+ }
95
87
 
96
88
  /**
97
89
  * Gets products you have access to, across all Units and Organisations
@@ -99,53 +91,41 @@ export const useGetProductTypes = <
99
91
  * @summary Gets all Products
100
92
  */
101
93
  export const getProducts = (
102
- options?: SecondParameter<typeof customInstance>,
103
- signal?: AbortSignal
94
+
95
+ options?: SecondParameter<typeof customInstance>,signal?: AbortSignal
104
96
  ) => {
105
- return customInstance<ProductsGetResponse>(
106
- { url: `/product`, method: "get", signal },
107
- options
108
- );
109
- };
97
+ return customInstance<ProductsGetResponse>(
98
+ {url: `/product`, method: 'get', signal
99
+ },
100
+ options);
101
+ }
102
+
110
103
 
111
104
  export const getGetProductsQueryKey = () => [`/product`];
112
105
 
113
- export type GetProductsQueryResult = NonNullable<
114
- Awaited<ReturnType<typeof getProducts>>
115
- >;
116
- export type GetProductsQueryError = ErrorType<AsError | void>;
117
-
118
- export const useGetProducts = <
119
- TData = Awaited<ReturnType<typeof getProducts>>,
120
- TError = ErrorType<AsError | void>
121
- >(options?: {
122
- query?: UseQueryOptions<
123
- Awaited<ReturnType<typeof getProducts>>,
124
- TError,
125
- TData
126
- >;
127
- request?: SecondParameter<typeof customInstance>;
128
- }): UseQueryResult<TData, TError> & { queryKey: QueryKey } => {
129
- const { query: queryOptions, request: requestOptions } = options ?? {};
106
+
107
+ export type GetProductsQueryResult = NonNullable<Awaited<ReturnType<typeof getProducts>>>
108
+ export type GetProductsQueryError = ErrorType<AsError | void>
109
+
110
+ export const useGetProducts = <TData = Awaited<ReturnType<typeof getProducts>>, TError = ErrorType<AsError | void>>(
111
+ options?: { query?:UseQueryOptions<Awaited<ReturnType<typeof getProducts>>, TError, TData>, request?: SecondParameter<typeof customInstance>}
112
+
113
+ ): UseQueryResult<TData, TError> & { queryKey: QueryKey } => {
114
+
115
+ const {query: queryOptions, request: requestOptions} = options ?? {}
130
116
 
131
117
  const queryKey = queryOptions?.queryKey ?? getGetProductsQueryKey();
132
118
 
133
- const queryFn: QueryFunction<Awaited<ReturnType<typeof getProducts>>> = ({
134
- signal,
135
- }) => getProducts(requestOptions, signal);
119
+
120
+
121
+ const queryFn: QueryFunction<Awaited<ReturnType<typeof getProducts>>> = ({ signal }) => getProducts(requestOptions, signal);
136
122
 
137
- const query = useQuery<
138
- Awaited<ReturnType<typeof getProducts>>,
139
- TError,
140
- TData
141
- >(queryKey, queryFn, queryOptions) as UseQueryResult<TData, TError> & {
142
- queryKey: QueryKey;
143
- };
123
+ const query = useQuery<Awaited<ReturnType<typeof getProducts>>, TError, TData>(queryKey, queryFn, queryOptions) as UseQueryResult<TData, TError> & { queryKey: QueryKey };
144
124
 
145
125
  query.queryKey = queryKey;
146
126
 
147
127
  return query;
148
- };
128
+ }
149
129
 
150
130
  /**
151
131
  * Gets products you have access to based on an Organisation
@@ -153,61 +133,41 @@ export const useGetProducts = <
153
133
  * @summary Gets Products for an Organisation
154
134
  */
155
135
  export const getProductsForOrganisation = (
156
- orgId: string,
157
- options?: SecondParameter<typeof customInstance>,
158
- signal?: AbortSignal
136
+ orgId: string,
137
+ options?: SecondParameter<typeof customInstance>,signal?: AbortSignal
159
138
  ) => {
160
- return customInstance<ProductsGetResponse>(
161
- { url: `/product/organisation/${orgId}`, method: "get", signal },
162
- options
163
- );
164
- };
165
-
166
- export const getGetProductsForOrganisationQueryKey = (orgId: string) => [
167
- `/product/organisation/${orgId}`,
168
- ];
169
-
170
- export type GetProductsForOrganisationQueryResult = NonNullable<
171
- Awaited<ReturnType<typeof getProductsForOrganisation>>
172
- >;
173
- export type GetProductsForOrganisationQueryError = ErrorType<void | AsError>;
174
-
175
- export const useGetProductsForOrganisation = <
176
- TData = Awaited<ReturnType<typeof getProductsForOrganisation>>,
177
- TError = ErrorType<void | AsError>
178
- >(
179
- orgId: string,
180
- options?: {
181
- query?: UseQueryOptions<
182
- Awaited<ReturnType<typeof getProductsForOrganisation>>,
183
- TError,
184
- TData
185
- >;
186
- request?: SecondParameter<typeof customInstance>;
187
- }
188
- ): UseQueryResult<TData, TError> & { queryKey: QueryKey } => {
189
- const { query: queryOptions, request: requestOptions } = options ?? {};
190
-
191
- const queryKey =
192
- queryOptions?.queryKey ?? getGetProductsForOrganisationQueryKey(orgId);
193
-
194
- const queryFn: QueryFunction<
195
- Awaited<ReturnType<typeof getProductsForOrganisation>>
196
- > = ({ signal }) => getProductsForOrganisation(orgId, requestOptions, signal);
197
-
198
- const query = useQuery<
199
- Awaited<ReturnType<typeof getProductsForOrganisation>>,
200
- TError,
201
- TData
202
- >(queryKey, queryFn, { enabled: !!orgId, ...queryOptions }) as UseQueryResult<
203
- TData,
204
- TError
205
- > & { queryKey: QueryKey };
139
+ return customInstance<ProductsGetResponse>(
140
+ {url: `/product/organisation/${orgId}`, method: 'get', signal
141
+ },
142
+ options);
143
+ }
144
+
145
+
146
+ export const getGetProductsForOrganisationQueryKey = (orgId: string,) => [`/product/organisation/${orgId}`];
147
+
148
+
149
+ export type GetProductsForOrganisationQueryResult = NonNullable<Awaited<ReturnType<typeof getProductsForOrganisation>>>
150
+ export type GetProductsForOrganisationQueryError = ErrorType<void | AsError>
151
+
152
+ export const useGetProductsForOrganisation = <TData = Awaited<ReturnType<typeof getProductsForOrganisation>>, TError = ErrorType<void | AsError>>(
153
+ orgId: string, options?: { query?:UseQueryOptions<Awaited<ReturnType<typeof getProductsForOrganisation>>, TError, TData>, request?: SecondParameter<typeof customInstance>}
154
+
155
+ ): UseQueryResult<TData, TError> & { queryKey: QueryKey } => {
156
+
157
+ const {query: queryOptions, request: requestOptions} = options ?? {}
158
+
159
+ const queryKey = queryOptions?.queryKey ?? getGetProductsForOrganisationQueryKey(orgId);
160
+
161
+
162
+
163
+ const queryFn: QueryFunction<Awaited<ReturnType<typeof getProductsForOrganisation>>> = ({ signal }) => getProductsForOrganisation(orgId, requestOptions, signal);
164
+
165
+ const query = useQuery<Awaited<ReturnType<typeof getProductsForOrganisation>>, TError, TData>(queryKey, queryFn, {enabled: !!(orgId), ...queryOptions}) as UseQueryResult<TData, TError> & { queryKey: QueryKey };
206
166
 
207
167
  query.queryKey = queryKey;
208
168
 
209
169
  return query;
210
- };
170
+ }
211
171
 
212
172
  /**
213
173
  * Products are **Subscriptions** that you create in a Unit and use **Merchant** services like the `DATA_MANAGER`.
@@ -219,118 +179,81 @@ Some subscriptions, like the `DATA_MANAGER_PROJECT_TIER_SUBSCRIPTION` are availa
219
179
  * @summary Creates a Product for an Organisational Unit
220
180
  */
221
181
  export const createUnitProduct = (
222
- unitId: string,
223
- unitProductPostBodyBody: UnitProductPostBodyBody,
224
- options?: SecondParameter<typeof customInstance>
225
- ) => {
226
- return customInstance<UnitProductPostResponse>(
227
- {
228
- url: `/product/unit/${unitId}`,
229
- method: "post",
230
- headers: { "Content-Type": "application/json" },
231
- data: unitProductPostBodyBody,
182
+ unitId: string,
183
+ unitProductPostBodyBody: UnitProductPostBodyBody,
184
+ options?: SecondParameter<typeof customInstance>,) => {
185
+ return customInstance<UnitProductPostResponse>(
186
+ {url: `/product/unit/${unitId}`, method: 'post',
187
+ headers: {'Content-Type': 'application/json', },
188
+ data: unitProductPostBodyBody
232
189
  },
233
- options
234
- );
235
- };
236
-
237
- export type CreateUnitProductMutationResult = NonNullable<
238
- Awaited<ReturnType<typeof createUnitProduct>>
239
- >;
240
- export type CreateUnitProductMutationBody = UnitProductPostBodyBody;
241
- export type CreateUnitProductMutationError = ErrorType<AsError | void>;
242
-
243
- export const useCreateUnitProduct = <
244
- TError = ErrorType<AsError | void>,
245
- TContext = unknown
246
- >(options?: {
247
- mutation?: UseMutationOptions<
248
- Awaited<ReturnType<typeof createUnitProduct>>,
249
- TError,
250
- { unitId: string; data: UnitProductPostBodyBody },
251
- TContext
252
- >;
253
- request?: SecondParameter<typeof customInstance>;
254
- }) => {
255
- const { mutation: mutationOptions, request: requestOptions } = options ?? {};
256
-
257
- const mutationFn: MutationFunction<
258
- Awaited<ReturnType<typeof createUnitProduct>>,
259
- { unitId: string; data: UnitProductPostBodyBody }
260
- > = (props) => {
261
- const { unitId, data } = props ?? {};
262
-
263
- return createUnitProduct(unitId, data, requestOptions);
264
- };
265
-
266
- return useMutation<
267
- Awaited<ReturnType<typeof createUnitProduct>>,
268
- TError,
269
- { unitId: string; data: UnitProductPostBodyBody },
270
- TContext
271
- >(mutationFn, mutationOptions);
272
- };
273
- /**
190
+ options);
191
+ }
192
+
193
+
194
+
195
+ export type CreateUnitProductMutationResult = NonNullable<Awaited<ReturnType<typeof createUnitProduct>>>
196
+ export type CreateUnitProductMutationBody = UnitProductPostBodyBody
197
+ export type CreateUnitProductMutationError = ErrorType<AsError | void>
198
+
199
+ export const useCreateUnitProduct = <TError = ErrorType<AsError | void>,
200
+
201
+ TContext = unknown>(options?: { mutation?:UseMutationOptions<Awaited<ReturnType<typeof createUnitProduct>>, TError,{unitId: string;data: UnitProductPostBodyBody}, TContext>, request?: SecondParameter<typeof customInstance>}
202
+ ) => {
203
+ const {mutation: mutationOptions, request: requestOptions} = options ?? {}
204
+
205
+
206
+
207
+
208
+ const mutationFn: MutationFunction<Awaited<ReturnType<typeof createUnitProduct>>, {unitId: string;data: UnitProductPostBodyBody}> = (props) => {
209
+ const {unitId,data} = props ?? {};
210
+
211
+ return createUnitProduct(unitId,data,requestOptions)
212
+ }
213
+
214
+ return useMutation<Awaited<ReturnType<typeof createUnitProduct>>, TError, {unitId: string;data: UnitProductPostBodyBody}, TContext>(mutationFn, mutationOptions)
215
+ }
216
+ /**
274
217
  * Gets products you have access to based on an Organisational Unit
275
218
 
276
219
  * @summary Gets Products for an Organisational Unit
277
220
  */
278
221
  export const getProductsForUnit = (
279
- unitId: string,
280
- options?: SecondParameter<typeof customInstance>,
281
- signal?: AbortSignal
222
+ unitId: string,
223
+ options?: SecondParameter<typeof customInstance>,signal?: AbortSignal
282
224
  ) => {
283
- return customInstance<ProductsGetResponse>(
284
- { url: `/product/unit/${unitId}`, method: "get", signal },
285
- options
286
- );
287
- };
288
-
289
- export const getGetProductsForUnitQueryKey = (unitId: string) => [
290
- `/product/unit/${unitId}`,
291
- ];
292
-
293
- export type GetProductsForUnitQueryResult = NonNullable<
294
- Awaited<ReturnType<typeof getProductsForUnit>>
295
- >;
296
- export type GetProductsForUnitQueryError = ErrorType<void | AsError>;
297
-
298
- export const useGetProductsForUnit = <
299
- TData = Awaited<ReturnType<typeof getProductsForUnit>>,
300
- TError = ErrorType<void | AsError>
301
- >(
302
- unitId: string,
303
- options?: {
304
- query?: UseQueryOptions<
305
- Awaited<ReturnType<typeof getProductsForUnit>>,
306
- TError,
307
- TData
308
- >;
309
- request?: SecondParameter<typeof customInstance>;
310
- }
311
- ): UseQueryResult<TData, TError> & { queryKey: QueryKey } => {
312
- const { query: queryOptions, request: requestOptions } = options ?? {};
313
-
314
- const queryKey =
315
- queryOptions?.queryKey ?? getGetProductsForUnitQueryKey(unitId);
316
-
317
- const queryFn: QueryFunction<
318
- Awaited<ReturnType<typeof getProductsForUnit>>
319
- > = ({ signal }) => getProductsForUnit(unitId, requestOptions, signal);
320
-
321
- const query = useQuery<
322
- Awaited<ReturnType<typeof getProductsForUnit>>,
323
- TError,
324
- TData
325
- >(queryKey, queryFn, {
326
- enabled: !!unitId,
327
- ...queryOptions,
328
- }) as UseQueryResult<TData, TError> & { queryKey: QueryKey };
225
+ return customInstance<ProductsGetResponse>(
226
+ {url: `/product/unit/${unitId}`, method: 'get', signal
227
+ },
228
+ options);
229
+ }
230
+
231
+
232
+ export const getGetProductsForUnitQueryKey = (unitId: string,) => [`/product/unit/${unitId}`];
233
+
234
+
235
+ export type GetProductsForUnitQueryResult = NonNullable<Awaited<ReturnType<typeof getProductsForUnit>>>
236
+ export type GetProductsForUnitQueryError = ErrorType<void | AsError>
237
+
238
+ export const useGetProductsForUnit = <TData = Awaited<ReturnType<typeof getProductsForUnit>>, TError = ErrorType<void | AsError>>(
239
+ unitId: string, options?: { query?:UseQueryOptions<Awaited<ReturnType<typeof getProductsForUnit>>, TError, TData>, request?: SecondParameter<typeof customInstance>}
240
+
241
+ ): UseQueryResult<TData, TError> & { queryKey: QueryKey } => {
242
+
243
+ const {query: queryOptions, request: requestOptions} = options ?? {}
244
+
245
+ const queryKey = queryOptions?.queryKey ?? getGetProductsForUnitQueryKey(unitId);
246
+
247
+
248
+
249
+ const queryFn: QueryFunction<Awaited<ReturnType<typeof getProductsForUnit>>> = ({ signal }) => getProductsForUnit(unitId, requestOptions, signal);
250
+
251
+ const query = useQuery<Awaited<ReturnType<typeof getProductsForUnit>>, TError, TData>(queryKey, queryFn, {enabled: !!(unitId), ...queryOptions}) as UseQueryResult<TData, TError> & { queryKey: QueryKey };
329
252
 
330
253
  query.queryKey = queryKey;
331
254
 
332
255
  return query;
333
- };
256
+ }
334
257
 
335
258
  /**
336
259
  * Gets a Product
@@ -338,165 +261,118 @@ export const useGetProductsForUnit = <
338
261
  * @summary Gets a Product
339
262
  */
340
263
  export const getProduct = (
341
- productId: string,
342
- options?: SecondParameter<typeof customInstance>,
343
- signal?: AbortSignal
264
+ productId: string,
265
+ options?: SecondParameter<typeof customInstance>,signal?: AbortSignal
344
266
  ) => {
345
- return customInstance<ProductUnitGetResponse>(
346
- { url: `/product/${productId}`, method: "get", signal },
347
- options
348
- );
349
- };
350
-
351
- export const getGetProductQueryKey = (productId: string) => [
352
- `/product/${productId}`,
353
- ];
354
-
355
- export type GetProductQueryResult = NonNullable<
356
- Awaited<ReturnType<typeof getProduct>>
357
- >;
358
- export type GetProductQueryError = ErrorType<AsError | void>;
359
-
360
- export const useGetProduct = <
361
- TData = Awaited<ReturnType<typeof getProduct>>,
362
- TError = ErrorType<AsError | void>
363
- >(
364
- productId: string,
365
- options?: {
366
- query?: UseQueryOptions<
367
- Awaited<ReturnType<typeof getProduct>>,
368
- TError,
369
- TData
370
- >;
371
- request?: SecondParameter<typeof customInstance>;
372
- }
373
- ): UseQueryResult<TData, TError> & { queryKey: QueryKey } => {
374
- const { query: queryOptions, request: requestOptions } = options ?? {};
267
+ return customInstance<ProductUnitGetResponse>(
268
+ {url: `/product/${productId}`, method: 'get', signal
269
+ },
270
+ options);
271
+ }
272
+
273
+
274
+ export const getGetProductQueryKey = (productId: string,) => [`/product/${productId}`];
275
+
276
+
277
+ export type GetProductQueryResult = NonNullable<Awaited<ReturnType<typeof getProduct>>>
278
+ export type GetProductQueryError = ErrorType<AsError | void>
279
+
280
+ export const useGetProduct = <TData = Awaited<ReturnType<typeof getProduct>>, TError = ErrorType<AsError | void>>(
281
+ productId: string, options?: { query?:UseQueryOptions<Awaited<ReturnType<typeof getProduct>>, TError, TData>, request?: SecondParameter<typeof customInstance>}
282
+
283
+ ): UseQueryResult<TData, TError> & { queryKey: QueryKey } => {
284
+
285
+ const {query: queryOptions, request: requestOptions} = options ?? {}
375
286
 
376
287
  const queryKey = queryOptions?.queryKey ?? getGetProductQueryKey(productId);
377
288
 
378
- const queryFn: QueryFunction<Awaited<ReturnType<typeof getProduct>>> = ({
379
- signal,
380
- }) => getProduct(productId, requestOptions, signal);
289
+
290
+
291
+ const queryFn: QueryFunction<Awaited<ReturnType<typeof getProduct>>> = ({ signal }) => getProduct(productId, requestOptions, signal);
381
292
 
382
- const query = useQuery<Awaited<ReturnType<typeof getProduct>>, TError, TData>(
383
- queryKey,
384
- queryFn,
385
- { enabled: !!productId, ...queryOptions }
386
- ) as UseQueryResult<TData, TError> & { queryKey: QueryKey };
293
+ const query = useQuery<Awaited<ReturnType<typeof getProduct>>, TError, TData>(queryKey, queryFn, {enabled: !!(productId), ...queryOptions}) as UseQueryResult<TData, TError> & { queryKey: QueryKey };
387
294
 
388
295
  query.queryKey = queryKey;
389
296
 
390
297
  return query;
391
- };
298
+ }
392
299
 
393
300
  /**
394
301
  * @summary Deletes an existing Product
395
302
  */
396
303
  export const deleteProduct = (
397
- productId: string,
398
- options?: SecondParameter<typeof customInstance>
304
+ productId: string,
305
+ options?: SecondParameter<typeof customInstance>,) => {
306
+ return customInstance<void>(
307
+ {url: `/product/${productId}`, method: 'delete'
308
+ },
309
+ options);
310
+ }
311
+
312
+
313
+
314
+ export type DeleteProductMutationResult = NonNullable<Awaited<ReturnType<typeof deleteProduct>>>
315
+
316
+ export type DeleteProductMutationError = ErrorType<AsError>
317
+
318
+ export const useDeleteProduct = <TError = ErrorType<AsError>,
319
+
320
+ TContext = unknown>(options?: { mutation?:UseMutationOptions<Awaited<ReturnType<typeof deleteProduct>>, TError,{productId: string}, TContext>, request?: SecondParameter<typeof customInstance>}
399
321
  ) => {
400
- return customInstance<void>(
401
- { url: `/product/${productId}`, method: "delete" },
402
- options
403
- );
404
- };
405
-
406
- export type DeleteProductMutationResult = NonNullable<
407
- Awaited<ReturnType<typeof deleteProduct>>
408
- >;
409
-
410
- export type DeleteProductMutationError = ErrorType<AsError>;
411
-
412
- export const useDeleteProduct = <
413
- TError = ErrorType<AsError>,
414
- TContext = unknown
415
- >(options?: {
416
- mutation?: UseMutationOptions<
417
- Awaited<ReturnType<typeof deleteProduct>>,
418
- TError,
419
- { productId: string },
420
- TContext
421
- >;
422
- request?: SecondParameter<typeof customInstance>;
423
- }) => {
424
- const { mutation: mutationOptions, request: requestOptions } = options ?? {};
425
-
426
- const mutationFn: MutationFunction<
427
- Awaited<ReturnType<typeof deleteProduct>>,
428
- { productId: string }
429
- > = (props) => {
430
- const { productId } = props ?? {};
431
-
432
- return deleteProduct(productId, requestOptions);
433
- };
434
-
435
- return useMutation<
436
- Awaited<ReturnType<typeof deleteProduct>>,
437
- TError,
438
- { productId: string },
439
- TContext
440
- >(mutationFn, mutationOptions);
441
- };
442
- /**
322
+ const {mutation: mutationOptions, request: requestOptions} = options ?? {}
323
+
324
+
325
+
326
+
327
+ const mutationFn: MutationFunction<Awaited<ReturnType<typeof deleteProduct>>, {productId: string}> = (props) => {
328
+ const {productId} = props ?? {};
329
+
330
+ return deleteProduct(productId,requestOptions)
331
+ }
332
+
333
+ return useMutation<Awaited<ReturnType<typeof deleteProduct>>, TError, {productId: string}, TContext>(mutationFn, mutationOptions)
334
+ }
335
+ /**
443
336
  * Used to update some adjustable parameters of a Product, i.e. to extend the Allowance or Limit. At the moment Data Manager products can be patched by changing the `name`, it's coin `allowance` or `limit`
444
337
 
445
338
  * @summary Adjust an existing Product
446
339
  */
447
340
  export const patchProduct = (
448
- productId: string,
449
- productPatchBodyBody: ProductPatchBodyBody,
450
- options?: SecondParameter<typeof customInstance>
451
- ) => {
452
- return customInstance<void>(
453
- {
454
- url: `/product/${productId}`,
455
- method: "patch",
456
- headers: { "Content-Type": "application/json" },
457
- data: productPatchBodyBody,
341
+ productId: string,
342
+ productPatchBodyBody: ProductPatchBodyBody,
343
+ options?: SecondParameter<typeof customInstance>,) => {
344
+ return customInstance<void>(
345
+ {url: `/product/${productId}`, method: 'patch',
346
+ headers: {'Content-Type': 'application/json', },
347
+ data: productPatchBodyBody
458
348
  },
459
- options
460
- );
461
- };
462
-
463
- export type PatchProductMutationResult = NonNullable<
464
- Awaited<ReturnType<typeof patchProduct>>
465
- >;
466
- export type PatchProductMutationBody = ProductPatchBodyBody;
467
- export type PatchProductMutationError = ErrorType<AsError>;
468
-
469
- export const usePatchProduct = <
470
- TError = ErrorType<AsError>,
471
- TContext = unknown
472
- >(options?: {
473
- mutation?: UseMutationOptions<
474
- Awaited<ReturnType<typeof patchProduct>>,
475
- TError,
476
- { productId: string; data: ProductPatchBodyBody },
477
- TContext
478
- >;
479
- request?: SecondParameter<typeof customInstance>;
480
- }) => {
481
- const { mutation: mutationOptions, request: requestOptions } = options ?? {};
482
-
483
- const mutationFn: MutationFunction<
484
- Awaited<ReturnType<typeof patchProduct>>,
485
- { productId: string; data: ProductPatchBodyBody }
486
- > = (props) => {
487
- const { productId, data } = props ?? {};
488
-
489
- return patchProduct(productId, data, requestOptions);
490
- };
491
-
492
- return useMutation<
493
- Awaited<ReturnType<typeof patchProduct>>,
494
- TError,
495
- { productId: string; data: ProductPatchBodyBody },
496
- TContext
497
- >(mutationFn, mutationOptions);
498
- };
499
- /**
349
+ options);
350
+ }
351
+
352
+
353
+
354
+ export type PatchProductMutationResult = NonNullable<Awaited<ReturnType<typeof patchProduct>>>
355
+ export type PatchProductMutationBody = ProductPatchBodyBody
356
+ export type PatchProductMutationError = ErrorType<AsError>
357
+
358
+ export const usePatchProduct = <TError = ErrorType<AsError>,
359
+
360
+ TContext = unknown>(options?: { mutation?:UseMutationOptions<Awaited<ReturnType<typeof patchProduct>>, TError,{productId: string;data: ProductPatchBodyBody}, TContext>, request?: SecondParameter<typeof customInstance>}
361
+ ) => {
362
+ const {mutation: mutationOptions, request: requestOptions} = options ?? {}
363
+
364
+
365
+
366
+
367
+ const mutationFn: MutationFunction<Awaited<ReturnType<typeof patchProduct>>, {productId: string;data: ProductPatchBodyBody}> = (props) => {
368
+ const {productId,data} = props ?? {};
369
+
370
+ return patchProduct(productId,data,requestOptions)
371
+ }
372
+
373
+ return useMutation<Awaited<ReturnType<typeof patchProduct>>, TError, {productId: string;data: ProductPatchBodyBody}, TContext>(mutationFn, mutationOptions)
374
+ }
375
+ /**
500
376
  * Get the charges made against a product with optional **from** (inclusive) and **until** (exclusive) dates. If no dates are provided, the charges for the current billing period are returned.
501
377
 
502
378
  Dates are interpreted using the Python dateutil parser so the input strings are extremely flexible, i.e. `1 December 2021` is an acceptable format.
@@ -507,62 +383,43 @@ You need **admin** rights to use this method
507
383
  * @summary Get charges made against a Product
508
384
  */
509
385
  export const getProductCharges = (
510
- productId: string,
511
- params?: GetProductChargesParams,
512
- options?: SecondParameter<typeof customInstance>,
513
- signal?: AbortSignal
386
+ productId: string,
387
+ params?: GetProductChargesParams,
388
+ options?: SecondParameter<typeof customInstance>,signal?: AbortSignal
514
389
  ) => {
515
- return customInstance<ProductChargesGetResponse>(
516
- { url: `/product/${productId}/charges`, method: "get", params, signal },
517
- options
518
- );
519
- };
520
-
521
- export const getGetProductChargesQueryKey = (
522
- productId: string,
523
- params?: GetProductChargesParams
524
- ) => [`/product/${productId}/charges`, ...(params ? [params] : [])];
525
-
526
- export type GetProductChargesQueryResult = NonNullable<
527
- Awaited<ReturnType<typeof getProductCharges>>
528
- >;
529
- export type GetProductChargesQueryError = ErrorType<AsError | void>;
530
-
531
- export const useGetProductCharges = <
532
- TData = Awaited<ReturnType<typeof getProductCharges>>,
533
- TError = ErrorType<AsError | void>
534
- >(
535
- productId: string,
536
- params?: GetProductChargesParams,
537
- options?: {
538
- query?: UseQueryOptions<
539
- Awaited<ReturnType<typeof getProductCharges>>,
540
- TError,
541
- TData
542
- >;
543
- request?: SecondParameter<typeof customInstance>;
544
- }
545
- ): UseQueryResult<TData, TError> & { queryKey: QueryKey } => {
546
- const { query: queryOptions, request: requestOptions } = options ?? {};
547
-
548
- const queryKey =
549
- queryOptions?.queryKey ?? getGetProductChargesQueryKey(productId, params);
550
-
551
- const queryFn: QueryFunction<
552
- Awaited<ReturnType<typeof getProductCharges>>
553
- > = ({ signal }) =>
554
- getProductCharges(productId, params, requestOptions, signal);
555
-
556
- const query = useQuery<
557
- Awaited<ReturnType<typeof getProductCharges>>,
558
- TError,
559
- TData
560
- >(queryKey, queryFn, {
561
- enabled: !!productId,
562
- ...queryOptions,
563
- }) as UseQueryResult<TData, TError> & { queryKey: QueryKey };
390
+ return customInstance<ProductChargesGetResponse>(
391
+ {url: `/product/${productId}/charges`, method: 'get',
392
+ params, signal
393
+ },
394
+ options);
395
+ }
396
+
397
+
398
+ export const getGetProductChargesQueryKey = (productId: string,
399
+ params?: GetProductChargesParams,) => [`/product/${productId}/charges`, ...(params ? [params]: [])];
400
+
401
+
402
+ export type GetProductChargesQueryResult = NonNullable<Awaited<ReturnType<typeof getProductCharges>>>
403
+ export type GetProductChargesQueryError = ErrorType<AsError | void>
404
+
405
+ export const useGetProductCharges = <TData = Awaited<ReturnType<typeof getProductCharges>>, TError = ErrorType<AsError | void>>(
406
+ productId: string,
407
+ params?: GetProductChargesParams, options?: { query?:UseQueryOptions<Awaited<ReturnType<typeof getProductCharges>>, TError, TData>, request?: SecondParameter<typeof customInstance>}
408
+
409
+ ): UseQueryResult<TData, TError> & { queryKey: QueryKey } => {
410
+
411
+ const {query: queryOptions, request: requestOptions} = options ?? {}
412
+
413
+ const queryKey = queryOptions?.queryKey ?? getGetProductChargesQueryKey(productId,params);
414
+
415
+
416
+
417
+ const queryFn: QueryFunction<Awaited<ReturnType<typeof getProductCharges>>> = ({ signal }) => getProductCharges(productId,params, requestOptions, signal);
418
+
419
+ const query = useQuery<Awaited<ReturnType<typeof getProductCharges>>, TError, TData>(queryKey, queryFn, {enabled: !!(productId), ...queryOptions}) as UseQueryResult<TData, TError> & { queryKey: QueryKey };
564
420
 
565
421
  query.queryKey = queryKey;
566
422
 
567
423
  return query;
568
- };
424
+ }
425
+