@squonk/account-server-client 2.4.1 → 3.0.0-rc.2
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/asset/package.json +6 -6
- package/charges/charges.cjs +188 -0
- package/charges/charges.cjs.map +1 -0
- package/charges/charges.d.cts +184 -0
- package/charges/charges.d.ts +184 -0
- package/charges/charges.js +188 -0
- package/charges/charges.js.map +1 -0
- package/charges/package.json +7 -0
- package/event-stream/package.json +6 -6
- package/index.cjs.map +1 -1
- package/index.d.cts +2 -2
- package/index.d.ts +2 -2
- package/index.js.map +1 -1
- package/merchant/package.json +6 -6
- package/organisation/organisation.cjs +1 -45
- package/organisation/organisation.cjs.map +1 -1
- package/organisation/organisation.d.cts +5 -48
- package/organisation/organisation.d.ts +5 -48
- package/organisation/organisation.js +0 -44
- package/organisation/organisation.js.map +1 -1
- package/organisation/package.json +6 -6
- package/package.json +1 -1
- package/product/package.json +6 -6
- package/product/product.cjs +1 -45
- package/product/product.cjs.map +1 -1
- package/product/product.d.cts +2 -48
- package/product/product.d.ts +2 -48
- package/product/product.js +0 -44
- package/product/product.js.map +1 -1
- package/src/account-server-api.schemas.ts +2 -2
- package/src/charges/charges.ts +487 -0
- package/src/organisation/organisation.ts +0 -114
- package/src/product/product.ts +1 -117
- package/src/unit/unit.ts +1 -116
- package/state/package.json +6 -6
- package/unit/package.json +6 -6
- package/unit/unit.cjs +1 -45
- package/unit/unit.cjs.map +1 -1
- package/unit/unit.d.cts +2 -47
- package/unit/unit.d.ts +2 -47
- package/unit/unit.js +0 -44
- package/unit/unit.js.map +1 -1
- package/user/package.json +6 -6
- package/admin/admin.cjs +0 -56
- package/admin/admin.cjs.map +0 -1
- package/admin/admin.d.cts +0 -50
- package/admin/admin.d.ts +0 -50
- package/admin/admin.js +0 -56
- package/admin/admin.js.map +0 -1
- package/admin/package.json +0 -7
- package/src/admin/admin.ts +0 -140
|
@@ -0,0 +1,487 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Generated by orval v6.25.0 🍺
|
|
3
|
+
* Do not edit manually.
|
|
4
|
+
* Account Server API
|
|
5
|
+
* The Informatics Matters Account Server API.
|
|
6
|
+
|
|
7
|
+
A service that provides access to the Account Server, which gives *registered* users access to and management of **Organisations**, **Units**, **Products**, **Users**, and **Assets**.
|
|
8
|
+
|
|
9
|
+
* OpenAPI spec version: 2.4
|
|
10
|
+
*/
|
|
11
|
+
import {
|
|
12
|
+
useQuery,
|
|
13
|
+
useSuspenseQuery
|
|
14
|
+
} from '@tanstack/react-query'
|
|
15
|
+
import type {
|
|
16
|
+
QueryFunction,
|
|
17
|
+
QueryKey,
|
|
18
|
+
UseQueryOptions,
|
|
19
|
+
UseQueryResult,
|
|
20
|
+
UseSuspenseQueryOptions,
|
|
21
|
+
UseSuspenseQueryResult
|
|
22
|
+
} from '@tanstack/react-query'
|
|
23
|
+
import type {
|
|
24
|
+
AsError,
|
|
25
|
+
ChargesGetResponse,
|
|
26
|
+
GetChargesParams,
|
|
27
|
+
GetOrganisationChargesParams,
|
|
28
|
+
GetProductChargesParams,
|
|
29
|
+
GetUnitChargesParams,
|
|
30
|
+
OrganisationChargesGetResponse,
|
|
31
|
+
ProductChargesGetResponse,
|
|
32
|
+
UnitChargesGetResponse
|
|
33
|
+
} from '../account-server-api.schemas'
|
|
34
|
+
import { customInstance } from '.././custom-instance';
|
|
35
|
+
import type { ErrorType } from '.././custom-instance';
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
type SecondParameter<T extends (...args: any) => any> = Parameters<T>[1];
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* Gets global Charges.
|
|
43
|
+
|
|
44
|
+
You need admin rights to use this path.
|
|
45
|
+
|
|
46
|
+
* @summary Gets charges for all Organisations
|
|
47
|
+
*/
|
|
48
|
+
export const getCharges = (
|
|
49
|
+
params?: GetChargesParams,
|
|
50
|
+
options?: SecondParameter<typeof customInstance>,signal?: AbortSignal
|
|
51
|
+
) => {
|
|
52
|
+
|
|
53
|
+
|
|
54
|
+
return customInstance<ChargesGetResponse>(
|
|
55
|
+
{url: `/charges`, method: 'GET',
|
|
56
|
+
params, signal
|
|
57
|
+
},
|
|
58
|
+
options);
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
|
|
62
|
+
export const getGetChargesQueryKey = (params?: GetChargesParams,) => {
|
|
63
|
+
return ["account-server-api", `/charges`, ...(params ? [params]: [])] as const;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
|
|
67
|
+
export const getGetChargesQueryOptions = <TData = Awaited<ReturnType<typeof getCharges>>, TError = ErrorType<void | AsError>>(params?: GetChargesParams, options?: { query?:Partial<UseQueryOptions<Awaited<ReturnType<typeof getCharges>>, TError, TData>>, request?: SecondParameter<typeof customInstance>}
|
|
68
|
+
) => {
|
|
69
|
+
|
|
70
|
+
const {query: queryOptions, request: requestOptions} = options ?? {};
|
|
71
|
+
|
|
72
|
+
const queryKey = queryOptions?.queryKey ?? getGetChargesQueryKey(params);
|
|
73
|
+
|
|
74
|
+
|
|
75
|
+
|
|
76
|
+
const queryFn: QueryFunction<Awaited<ReturnType<typeof getCharges>>> = ({ signal }) => getCharges(params, requestOptions, signal);
|
|
77
|
+
|
|
78
|
+
|
|
79
|
+
|
|
80
|
+
|
|
81
|
+
|
|
82
|
+
return { queryKey, queryFn, ...queryOptions} as UseQueryOptions<Awaited<ReturnType<typeof getCharges>>, TError, TData> & { queryKey: QueryKey }
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
export type GetChargesQueryResult = NonNullable<Awaited<ReturnType<typeof getCharges>>>
|
|
86
|
+
export type GetChargesQueryError = ErrorType<void | AsError>
|
|
87
|
+
|
|
88
|
+
/**
|
|
89
|
+
* @summary Gets charges for all Organisations
|
|
90
|
+
*/
|
|
91
|
+
export const useGetCharges = <TData = Awaited<ReturnType<typeof getCharges>>, TError = ErrorType<void | AsError>>(
|
|
92
|
+
params?: GetChargesParams, options?: { query?:Partial<UseQueryOptions<Awaited<ReturnType<typeof getCharges>>, TError, TData>>, request?: SecondParameter<typeof customInstance>}
|
|
93
|
+
|
|
94
|
+
): UseQueryResult<TData, TError> & { queryKey: QueryKey } => {
|
|
95
|
+
|
|
96
|
+
const queryOptions = getGetChargesQueryOptions(params,options)
|
|
97
|
+
|
|
98
|
+
const query = useQuery(queryOptions) as UseQueryResult<TData, TError> & { queryKey: QueryKey };
|
|
99
|
+
|
|
100
|
+
query.queryKey = queryOptions.queryKey ;
|
|
101
|
+
|
|
102
|
+
return query;
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
|
|
106
|
+
|
|
107
|
+
export const getGetChargesSuspenseQueryOptions = <TData = Awaited<ReturnType<typeof getCharges>>, TError = ErrorType<void | AsError>>(params?: GetChargesParams, options?: { query?:Partial<UseSuspenseQueryOptions<Awaited<ReturnType<typeof getCharges>>, TError, TData>>, request?: SecondParameter<typeof customInstance>}
|
|
108
|
+
) => {
|
|
109
|
+
|
|
110
|
+
const {query: queryOptions, request: requestOptions} = options ?? {};
|
|
111
|
+
|
|
112
|
+
const queryKey = queryOptions?.queryKey ?? getGetChargesQueryKey(params);
|
|
113
|
+
|
|
114
|
+
|
|
115
|
+
|
|
116
|
+
const queryFn: QueryFunction<Awaited<ReturnType<typeof getCharges>>> = ({ signal }) => getCharges(params, requestOptions, signal);
|
|
117
|
+
|
|
118
|
+
|
|
119
|
+
|
|
120
|
+
|
|
121
|
+
|
|
122
|
+
return { queryKey, queryFn, ...queryOptions} as UseSuspenseQueryOptions<Awaited<ReturnType<typeof getCharges>>, TError, TData> & { queryKey: QueryKey }
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
export type GetChargesSuspenseQueryResult = NonNullable<Awaited<ReturnType<typeof getCharges>>>
|
|
126
|
+
export type GetChargesSuspenseQueryError = ErrorType<void | AsError>
|
|
127
|
+
|
|
128
|
+
/**
|
|
129
|
+
* @summary Gets charges for all Organisations
|
|
130
|
+
*/
|
|
131
|
+
export const useGetChargesSuspense = <TData = Awaited<ReturnType<typeof getCharges>>, TError = ErrorType<void | AsError>>(
|
|
132
|
+
params?: GetChargesParams, options?: { query?:Partial<UseSuspenseQueryOptions<Awaited<ReturnType<typeof getCharges>>, TError, TData>>, request?: SecondParameter<typeof customInstance>}
|
|
133
|
+
|
|
134
|
+
): UseSuspenseQueryResult<TData, TError> & { queryKey: QueryKey } => {
|
|
135
|
+
|
|
136
|
+
const queryOptions = getGetChargesSuspenseQueryOptions(params,options)
|
|
137
|
+
|
|
138
|
+
const query = useSuspenseQuery(queryOptions) as UseSuspenseQueryResult<TData, TError> & { queryKey: QueryKey };
|
|
139
|
+
|
|
140
|
+
query.queryKey = queryOptions.queryKey ;
|
|
141
|
+
|
|
142
|
+
return query;
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
|
|
146
|
+
|
|
147
|
+
/**
|
|
148
|
+
* Gets a Organisation charges.
|
|
149
|
+
|
|
150
|
+
The Organisation cannot be the **Default Organisation** and you need to be a member of the Organisation to use this endpoint
|
|
151
|
+
|
|
152
|
+
* @summary Gets charges for all Units in an Organisation
|
|
153
|
+
*/
|
|
154
|
+
export const getOrganisationCharges = (
|
|
155
|
+
orgId: string,
|
|
156
|
+
params?: GetOrganisationChargesParams,
|
|
157
|
+
options?: SecondParameter<typeof customInstance>,signal?: AbortSignal
|
|
158
|
+
) => {
|
|
159
|
+
|
|
160
|
+
|
|
161
|
+
return customInstance<OrganisationChargesGetResponse>(
|
|
162
|
+
{url: `/charges/organisation/${orgId}`, method: 'GET',
|
|
163
|
+
params, signal
|
|
164
|
+
},
|
|
165
|
+
options);
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
|
|
169
|
+
export const getGetOrganisationChargesQueryKey = (orgId: string,
|
|
170
|
+
params?: GetOrganisationChargesParams,) => {
|
|
171
|
+
return ["account-server-api", `/charges/organisation/${orgId}`, ...(params ? [params]: [])] as const;
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
|
|
175
|
+
export const getGetOrganisationChargesQueryOptions = <TData = Awaited<ReturnType<typeof getOrganisationCharges>>, TError = ErrorType<void | AsError>>(orgId: string,
|
|
176
|
+
params?: GetOrganisationChargesParams, options?: { query?:Partial<UseQueryOptions<Awaited<ReturnType<typeof getOrganisationCharges>>, TError, TData>>, request?: SecondParameter<typeof customInstance>}
|
|
177
|
+
) => {
|
|
178
|
+
|
|
179
|
+
const {query: queryOptions, request: requestOptions} = options ?? {};
|
|
180
|
+
|
|
181
|
+
const queryKey = queryOptions?.queryKey ?? getGetOrganisationChargesQueryKey(orgId,params);
|
|
182
|
+
|
|
183
|
+
|
|
184
|
+
|
|
185
|
+
const queryFn: QueryFunction<Awaited<ReturnType<typeof getOrganisationCharges>>> = ({ signal }) => getOrganisationCharges(orgId,params, requestOptions, signal);
|
|
186
|
+
|
|
187
|
+
|
|
188
|
+
|
|
189
|
+
|
|
190
|
+
|
|
191
|
+
return { queryKey, queryFn, enabled: !!(orgId), ...queryOptions} as UseQueryOptions<Awaited<ReturnType<typeof getOrganisationCharges>>, TError, TData> & { queryKey: QueryKey }
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
export type GetOrganisationChargesQueryResult = NonNullable<Awaited<ReturnType<typeof getOrganisationCharges>>>
|
|
195
|
+
export type GetOrganisationChargesQueryError = ErrorType<void | AsError>
|
|
196
|
+
|
|
197
|
+
/**
|
|
198
|
+
* @summary Gets charges for all Units in an Organisation
|
|
199
|
+
*/
|
|
200
|
+
export const useGetOrganisationCharges = <TData = Awaited<ReturnType<typeof getOrganisationCharges>>, TError = ErrorType<void | AsError>>(
|
|
201
|
+
orgId: string,
|
|
202
|
+
params?: GetOrganisationChargesParams, options?: { query?:Partial<UseQueryOptions<Awaited<ReturnType<typeof getOrganisationCharges>>, TError, TData>>, request?: SecondParameter<typeof customInstance>}
|
|
203
|
+
|
|
204
|
+
): UseQueryResult<TData, TError> & { queryKey: QueryKey } => {
|
|
205
|
+
|
|
206
|
+
const queryOptions = getGetOrganisationChargesQueryOptions(orgId,params,options)
|
|
207
|
+
|
|
208
|
+
const query = useQuery(queryOptions) as UseQueryResult<TData, TError> & { queryKey: QueryKey };
|
|
209
|
+
|
|
210
|
+
query.queryKey = queryOptions.queryKey ;
|
|
211
|
+
|
|
212
|
+
return query;
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
|
|
216
|
+
|
|
217
|
+
export const getGetOrganisationChargesSuspenseQueryOptions = <TData = Awaited<ReturnType<typeof getOrganisationCharges>>, TError = ErrorType<void | AsError>>(orgId: string,
|
|
218
|
+
params?: GetOrganisationChargesParams, options?: { query?:Partial<UseSuspenseQueryOptions<Awaited<ReturnType<typeof getOrganisationCharges>>, TError, TData>>, request?: SecondParameter<typeof customInstance>}
|
|
219
|
+
) => {
|
|
220
|
+
|
|
221
|
+
const {query: queryOptions, request: requestOptions} = options ?? {};
|
|
222
|
+
|
|
223
|
+
const queryKey = queryOptions?.queryKey ?? getGetOrganisationChargesQueryKey(orgId,params);
|
|
224
|
+
|
|
225
|
+
|
|
226
|
+
|
|
227
|
+
const queryFn: QueryFunction<Awaited<ReturnType<typeof getOrganisationCharges>>> = ({ signal }) => getOrganisationCharges(orgId,params, requestOptions, signal);
|
|
228
|
+
|
|
229
|
+
|
|
230
|
+
|
|
231
|
+
|
|
232
|
+
|
|
233
|
+
return { queryKey, queryFn, enabled: !!(orgId), ...queryOptions} as UseSuspenseQueryOptions<Awaited<ReturnType<typeof getOrganisationCharges>>, TError, TData> & { queryKey: QueryKey }
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
export type GetOrganisationChargesSuspenseQueryResult = NonNullable<Awaited<ReturnType<typeof getOrganisationCharges>>>
|
|
237
|
+
export type GetOrganisationChargesSuspenseQueryError = ErrorType<void | AsError>
|
|
238
|
+
|
|
239
|
+
/**
|
|
240
|
+
* @summary Gets charges for all Units in an Organisation
|
|
241
|
+
*/
|
|
242
|
+
export const useGetOrganisationChargesSuspense = <TData = Awaited<ReturnType<typeof getOrganisationCharges>>, TError = ErrorType<void | AsError>>(
|
|
243
|
+
orgId: string,
|
|
244
|
+
params?: GetOrganisationChargesParams, options?: { query?:Partial<UseSuspenseQueryOptions<Awaited<ReturnType<typeof getOrganisationCharges>>, TError, TData>>, request?: SecondParameter<typeof customInstance>}
|
|
245
|
+
|
|
246
|
+
): UseSuspenseQueryResult<TData, TError> & { queryKey: QueryKey } => {
|
|
247
|
+
|
|
248
|
+
const queryOptions = getGetOrganisationChargesSuspenseQueryOptions(orgId,params,options)
|
|
249
|
+
|
|
250
|
+
const query = useSuspenseQuery(queryOptions) as UseSuspenseQueryResult<TData, TError> & { queryKey: QueryKey };
|
|
251
|
+
|
|
252
|
+
query.queryKey = queryOptions.queryKey ;
|
|
253
|
+
|
|
254
|
+
return query;
|
|
255
|
+
}
|
|
256
|
+
|
|
257
|
+
|
|
258
|
+
|
|
259
|
+
/**
|
|
260
|
+
* 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.
|
|
261
|
+
|
|
262
|
+
Dates are interpreted using the Python `dateutil` parser, so the input strings are extremely flexible with, for example, `1 December 2021` as an acceptable input.
|
|
263
|
+
|
|
264
|
+
**From** must be a date (day) prior to **until**. For example, to see the charges for the 11th July 2022 set **from** to `11 July 2022` and **until** to `12 July 2022`. As an alternative to **From** and **Until** you can provide a **Prior Billing Period**, a value that identifies the prior period to retrieve. A value of `-1` would indicate the *prior period* (month) with an oldest retrieval value of `-23` allowing you to obtain charges for up to two years.
|
|
265
|
+
|
|
266
|
+
You need to be part of the **Unit** or **Organisation** to use this method
|
|
267
|
+
* @summary Get charges made against a Product
|
|
268
|
+
*/
|
|
269
|
+
export const getProductCharges = (
|
|
270
|
+
productId: string,
|
|
271
|
+
params?: GetProductChargesParams,
|
|
272
|
+
options?: SecondParameter<typeof customInstance>,signal?: AbortSignal
|
|
273
|
+
) => {
|
|
274
|
+
|
|
275
|
+
|
|
276
|
+
return customInstance<ProductChargesGetResponse>(
|
|
277
|
+
{url: `/charges/product/${productId}`, method: 'GET',
|
|
278
|
+
params, signal
|
|
279
|
+
},
|
|
280
|
+
options);
|
|
281
|
+
}
|
|
282
|
+
|
|
283
|
+
|
|
284
|
+
export const getGetProductChargesQueryKey = (productId: string,
|
|
285
|
+
params?: GetProductChargesParams,) => {
|
|
286
|
+
return ["account-server-api", `/charges/product/${productId}`, ...(params ? [params]: [])] as const;
|
|
287
|
+
}
|
|
288
|
+
|
|
289
|
+
|
|
290
|
+
export const getGetProductChargesQueryOptions = <TData = Awaited<ReturnType<typeof getProductCharges>>, TError = ErrorType<AsError | void>>(productId: string,
|
|
291
|
+
params?: GetProductChargesParams, options?: { query?:Partial<UseQueryOptions<Awaited<ReturnType<typeof getProductCharges>>, TError, TData>>, request?: SecondParameter<typeof customInstance>}
|
|
292
|
+
) => {
|
|
293
|
+
|
|
294
|
+
const {query: queryOptions, request: requestOptions} = options ?? {};
|
|
295
|
+
|
|
296
|
+
const queryKey = queryOptions?.queryKey ?? getGetProductChargesQueryKey(productId,params);
|
|
297
|
+
|
|
298
|
+
|
|
299
|
+
|
|
300
|
+
const queryFn: QueryFunction<Awaited<ReturnType<typeof getProductCharges>>> = ({ signal }) => getProductCharges(productId,params, requestOptions, signal);
|
|
301
|
+
|
|
302
|
+
|
|
303
|
+
|
|
304
|
+
|
|
305
|
+
|
|
306
|
+
return { queryKey, queryFn, enabled: !!(productId), ...queryOptions} as UseQueryOptions<Awaited<ReturnType<typeof getProductCharges>>, TError, TData> & { queryKey: QueryKey }
|
|
307
|
+
}
|
|
308
|
+
|
|
309
|
+
export type GetProductChargesQueryResult = NonNullable<Awaited<ReturnType<typeof getProductCharges>>>
|
|
310
|
+
export type GetProductChargesQueryError = ErrorType<AsError | void>
|
|
311
|
+
|
|
312
|
+
/**
|
|
313
|
+
* @summary Get charges made against a Product
|
|
314
|
+
*/
|
|
315
|
+
export const useGetProductCharges = <TData = Awaited<ReturnType<typeof getProductCharges>>, TError = ErrorType<AsError | void>>(
|
|
316
|
+
productId: string,
|
|
317
|
+
params?: GetProductChargesParams, options?: { query?:Partial<UseQueryOptions<Awaited<ReturnType<typeof getProductCharges>>, TError, TData>>, request?: SecondParameter<typeof customInstance>}
|
|
318
|
+
|
|
319
|
+
): UseQueryResult<TData, TError> & { queryKey: QueryKey } => {
|
|
320
|
+
|
|
321
|
+
const queryOptions = getGetProductChargesQueryOptions(productId,params,options)
|
|
322
|
+
|
|
323
|
+
const query = useQuery(queryOptions) as UseQueryResult<TData, TError> & { queryKey: QueryKey };
|
|
324
|
+
|
|
325
|
+
query.queryKey = queryOptions.queryKey ;
|
|
326
|
+
|
|
327
|
+
return query;
|
|
328
|
+
}
|
|
329
|
+
|
|
330
|
+
|
|
331
|
+
|
|
332
|
+
export const getGetProductChargesSuspenseQueryOptions = <TData = Awaited<ReturnType<typeof getProductCharges>>, TError = ErrorType<AsError | void>>(productId: string,
|
|
333
|
+
params?: GetProductChargesParams, options?: { query?:Partial<UseSuspenseQueryOptions<Awaited<ReturnType<typeof getProductCharges>>, TError, TData>>, request?: SecondParameter<typeof customInstance>}
|
|
334
|
+
) => {
|
|
335
|
+
|
|
336
|
+
const {query: queryOptions, request: requestOptions} = options ?? {};
|
|
337
|
+
|
|
338
|
+
const queryKey = queryOptions?.queryKey ?? getGetProductChargesQueryKey(productId,params);
|
|
339
|
+
|
|
340
|
+
|
|
341
|
+
|
|
342
|
+
const queryFn: QueryFunction<Awaited<ReturnType<typeof getProductCharges>>> = ({ signal }) => getProductCharges(productId,params, requestOptions, signal);
|
|
343
|
+
|
|
344
|
+
|
|
345
|
+
|
|
346
|
+
|
|
347
|
+
|
|
348
|
+
return { queryKey, queryFn, enabled: !!(productId), ...queryOptions} as UseSuspenseQueryOptions<Awaited<ReturnType<typeof getProductCharges>>, TError, TData> & { queryKey: QueryKey }
|
|
349
|
+
}
|
|
350
|
+
|
|
351
|
+
export type GetProductChargesSuspenseQueryResult = NonNullable<Awaited<ReturnType<typeof getProductCharges>>>
|
|
352
|
+
export type GetProductChargesSuspenseQueryError = ErrorType<AsError | void>
|
|
353
|
+
|
|
354
|
+
/**
|
|
355
|
+
* @summary Get charges made against a Product
|
|
356
|
+
*/
|
|
357
|
+
export const useGetProductChargesSuspense = <TData = Awaited<ReturnType<typeof getProductCharges>>, TError = ErrorType<AsError | void>>(
|
|
358
|
+
productId: string,
|
|
359
|
+
params?: GetProductChargesParams, options?: { query?:Partial<UseSuspenseQueryOptions<Awaited<ReturnType<typeof getProductCharges>>, TError, TData>>, request?: SecondParameter<typeof customInstance>}
|
|
360
|
+
|
|
361
|
+
): UseSuspenseQueryResult<TData, TError> & { queryKey: QueryKey } => {
|
|
362
|
+
|
|
363
|
+
const queryOptions = getGetProductChargesSuspenseQueryOptions(productId,params,options)
|
|
364
|
+
|
|
365
|
+
const query = useSuspenseQuery(queryOptions) as UseSuspenseQueryResult<TData, TError> & { queryKey: QueryKey };
|
|
366
|
+
|
|
367
|
+
query.queryKey = queryOptions.queryKey ;
|
|
368
|
+
|
|
369
|
+
return query;
|
|
370
|
+
}
|
|
371
|
+
|
|
372
|
+
|
|
373
|
+
|
|
374
|
+
/**
|
|
375
|
+
* Get the charges made against a Unit with optional **from** (inclusive) and **until** (exclusive) dates. If no dates are provided, the charges for the current billing period are returned.
|
|
376
|
+
Dates are interpreted using the Python `dateutil` parser, so the input strings are extremely flexible with, for example, `1 December 2021` as an acceptable input.
|
|
377
|
+
|
|
378
|
+
**From** must be a date (day) prior to **until**. For example, to see the charges for the 11th July 2022 set **from** to `11 July 2022` and **until** to `12 July 2022`. As an alternative to **From** and **Until** you can provide a **Prior Billing Period**, a value that identifies the prior period to retrieve. A value of `-1` would indicate the *prior period* (month) with an oldest retrieval value of `-23` allowing you to obtain charges for up to two years.
|
|
379
|
+
|
|
380
|
+
You need to be part of the **Unit** or **Organisation** to use this method
|
|
381
|
+
* @summary Get charges made against a Unit
|
|
382
|
+
*/
|
|
383
|
+
export const getUnitCharges = (
|
|
384
|
+
unitId: string,
|
|
385
|
+
params?: GetUnitChargesParams,
|
|
386
|
+
options?: SecondParameter<typeof customInstance>,signal?: AbortSignal
|
|
387
|
+
) => {
|
|
388
|
+
|
|
389
|
+
|
|
390
|
+
return customInstance<UnitChargesGetResponse>(
|
|
391
|
+
{url: `/charges/unit/${unitId}`, method: 'GET',
|
|
392
|
+
params, signal
|
|
393
|
+
},
|
|
394
|
+
options);
|
|
395
|
+
}
|
|
396
|
+
|
|
397
|
+
|
|
398
|
+
export const getGetUnitChargesQueryKey = (unitId: string,
|
|
399
|
+
params?: GetUnitChargesParams,) => {
|
|
400
|
+
return ["account-server-api", `/charges/unit/${unitId}`, ...(params ? [params]: [])] as const;
|
|
401
|
+
}
|
|
402
|
+
|
|
403
|
+
|
|
404
|
+
export const getGetUnitChargesQueryOptions = <TData = Awaited<ReturnType<typeof getUnitCharges>>, TError = ErrorType<AsError | void>>(unitId: string,
|
|
405
|
+
params?: GetUnitChargesParams, options?: { query?:Partial<UseQueryOptions<Awaited<ReturnType<typeof getUnitCharges>>, TError, TData>>, request?: SecondParameter<typeof customInstance>}
|
|
406
|
+
) => {
|
|
407
|
+
|
|
408
|
+
const {query: queryOptions, request: requestOptions} = options ?? {};
|
|
409
|
+
|
|
410
|
+
const queryKey = queryOptions?.queryKey ?? getGetUnitChargesQueryKey(unitId,params);
|
|
411
|
+
|
|
412
|
+
|
|
413
|
+
|
|
414
|
+
const queryFn: QueryFunction<Awaited<ReturnType<typeof getUnitCharges>>> = ({ signal }) => getUnitCharges(unitId,params, requestOptions, signal);
|
|
415
|
+
|
|
416
|
+
|
|
417
|
+
|
|
418
|
+
|
|
419
|
+
|
|
420
|
+
return { queryKey, queryFn, enabled: !!(unitId), ...queryOptions} as UseQueryOptions<Awaited<ReturnType<typeof getUnitCharges>>, TError, TData> & { queryKey: QueryKey }
|
|
421
|
+
}
|
|
422
|
+
|
|
423
|
+
export type GetUnitChargesQueryResult = NonNullable<Awaited<ReturnType<typeof getUnitCharges>>>
|
|
424
|
+
export type GetUnitChargesQueryError = ErrorType<AsError | void>
|
|
425
|
+
|
|
426
|
+
/**
|
|
427
|
+
* @summary Get charges made against a Unit
|
|
428
|
+
*/
|
|
429
|
+
export const useGetUnitCharges = <TData = Awaited<ReturnType<typeof getUnitCharges>>, TError = ErrorType<AsError | void>>(
|
|
430
|
+
unitId: string,
|
|
431
|
+
params?: GetUnitChargesParams, options?: { query?:Partial<UseQueryOptions<Awaited<ReturnType<typeof getUnitCharges>>, TError, TData>>, request?: SecondParameter<typeof customInstance>}
|
|
432
|
+
|
|
433
|
+
): UseQueryResult<TData, TError> & { queryKey: QueryKey } => {
|
|
434
|
+
|
|
435
|
+
const queryOptions = getGetUnitChargesQueryOptions(unitId,params,options)
|
|
436
|
+
|
|
437
|
+
const query = useQuery(queryOptions) as UseQueryResult<TData, TError> & { queryKey: QueryKey };
|
|
438
|
+
|
|
439
|
+
query.queryKey = queryOptions.queryKey ;
|
|
440
|
+
|
|
441
|
+
return query;
|
|
442
|
+
}
|
|
443
|
+
|
|
444
|
+
|
|
445
|
+
|
|
446
|
+
export const getGetUnitChargesSuspenseQueryOptions = <TData = Awaited<ReturnType<typeof getUnitCharges>>, TError = ErrorType<AsError | void>>(unitId: string,
|
|
447
|
+
params?: GetUnitChargesParams, options?: { query?:Partial<UseSuspenseQueryOptions<Awaited<ReturnType<typeof getUnitCharges>>, TError, TData>>, request?: SecondParameter<typeof customInstance>}
|
|
448
|
+
) => {
|
|
449
|
+
|
|
450
|
+
const {query: queryOptions, request: requestOptions} = options ?? {};
|
|
451
|
+
|
|
452
|
+
const queryKey = queryOptions?.queryKey ?? getGetUnitChargesQueryKey(unitId,params);
|
|
453
|
+
|
|
454
|
+
|
|
455
|
+
|
|
456
|
+
const queryFn: QueryFunction<Awaited<ReturnType<typeof getUnitCharges>>> = ({ signal }) => getUnitCharges(unitId,params, requestOptions, signal);
|
|
457
|
+
|
|
458
|
+
|
|
459
|
+
|
|
460
|
+
|
|
461
|
+
|
|
462
|
+
return { queryKey, queryFn, enabled: !!(unitId), ...queryOptions} as UseSuspenseQueryOptions<Awaited<ReturnType<typeof getUnitCharges>>, TError, TData> & { queryKey: QueryKey }
|
|
463
|
+
}
|
|
464
|
+
|
|
465
|
+
export type GetUnitChargesSuspenseQueryResult = NonNullable<Awaited<ReturnType<typeof getUnitCharges>>>
|
|
466
|
+
export type GetUnitChargesSuspenseQueryError = ErrorType<AsError | void>
|
|
467
|
+
|
|
468
|
+
/**
|
|
469
|
+
* @summary Get charges made against a Unit
|
|
470
|
+
*/
|
|
471
|
+
export const useGetUnitChargesSuspense = <TData = Awaited<ReturnType<typeof getUnitCharges>>, TError = ErrorType<AsError | void>>(
|
|
472
|
+
unitId: string,
|
|
473
|
+
params?: GetUnitChargesParams, options?: { query?:Partial<UseSuspenseQueryOptions<Awaited<ReturnType<typeof getUnitCharges>>, TError, TData>>, request?: SecondParameter<typeof customInstance>}
|
|
474
|
+
|
|
475
|
+
): UseSuspenseQueryResult<TData, TError> & { queryKey: QueryKey } => {
|
|
476
|
+
|
|
477
|
+
const queryOptions = getGetUnitChargesSuspenseQueryOptions(unitId,params,options)
|
|
478
|
+
|
|
479
|
+
const query = useSuspenseQuery(queryOptions) as UseSuspenseQueryResult<TData, TError> & { queryKey: QueryKey };
|
|
480
|
+
|
|
481
|
+
query.queryKey = queryOptions.queryKey ;
|
|
482
|
+
|
|
483
|
+
return query;
|
|
484
|
+
}
|
|
485
|
+
|
|
486
|
+
|
|
487
|
+
|
|
@@ -25,9 +25,7 @@ import type {
|
|
|
25
25
|
} from '@tanstack/react-query'
|
|
26
26
|
import type {
|
|
27
27
|
AsError,
|
|
28
|
-
GetOrganisationChargesParams,
|
|
29
28
|
OrganisationAllDetail,
|
|
30
|
-
OrganisationChargesGetResponse,
|
|
31
29
|
OrganisationGetDefaultResponse,
|
|
32
30
|
OrganisationPatchBodyBody,
|
|
33
31
|
OrganisationPostBodyBody,
|
|
@@ -421,118 +419,6 @@ export const useDeleteOrganisation = <TError = ErrorType<AsError>,
|
|
|
421
419
|
return useMutation(mutationOptions);
|
|
422
420
|
}
|
|
423
421
|
/**
|
|
424
|
-
* Gets a Organisation charges.
|
|
425
|
-
|
|
426
|
-
The Organisation cannot be the **Default Organisation** and you need to be a member of the Organisation to use this endpoint
|
|
427
|
-
|
|
428
|
-
* @summary Gets charges for all Units in an Organisation
|
|
429
|
-
*/
|
|
430
|
-
export const getOrganisationCharges = (
|
|
431
|
-
orgId: string,
|
|
432
|
-
params?: GetOrganisationChargesParams,
|
|
433
|
-
options?: SecondParameter<typeof customInstance>,signal?: AbortSignal
|
|
434
|
-
) => {
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
return customInstance<OrganisationChargesGetResponse>(
|
|
438
|
-
{url: `/organisation/${orgId}/charges`, method: 'GET',
|
|
439
|
-
params, signal
|
|
440
|
-
},
|
|
441
|
-
options);
|
|
442
|
-
}
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
export const getGetOrganisationChargesQueryKey = (orgId: string,
|
|
446
|
-
params?: GetOrganisationChargesParams,) => {
|
|
447
|
-
return ["account-server-api", `/organisation/${orgId}/charges`, ...(params ? [params]: [])] as const;
|
|
448
|
-
}
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
export const getGetOrganisationChargesQueryOptions = <TData = Awaited<ReturnType<typeof getOrganisationCharges>>, TError = ErrorType<void | AsError>>(orgId: string,
|
|
452
|
-
params?: GetOrganisationChargesParams, options?: { query?:Partial<UseQueryOptions<Awaited<ReturnType<typeof getOrganisationCharges>>, TError, TData>>, request?: SecondParameter<typeof customInstance>}
|
|
453
|
-
) => {
|
|
454
|
-
|
|
455
|
-
const {query: queryOptions, request: requestOptions} = options ?? {};
|
|
456
|
-
|
|
457
|
-
const queryKey = queryOptions?.queryKey ?? getGetOrganisationChargesQueryKey(orgId,params);
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
const queryFn: QueryFunction<Awaited<ReturnType<typeof getOrganisationCharges>>> = ({ signal }) => getOrganisationCharges(orgId,params, requestOptions, signal);
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
return { queryKey, queryFn, enabled: !!(orgId), ...queryOptions} as UseQueryOptions<Awaited<ReturnType<typeof getOrganisationCharges>>, TError, TData> & { queryKey: QueryKey }
|
|
468
|
-
}
|
|
469
|
-
|
|
470
|
-
export type GetOrganisationChargesQueryResult = NonNullable<Awaited<ReturnType<typeof getOrganisationCharges>>>
|
|
471
|
-
export type GetOrganisationChargesQueryError = ErrorType<void | AsError>
|
|
472
|
-
|
|
473
|
-
/**
|
|
474
|
-
* @summary Gets charges for all Units in an Organisation
|
|
475
|
-
*/
|
|
476
|
-
export const useGetOrganisationCharges = <TData = Awaited<ReturnType<typeof getOrganisationCharges>>, TError = ErrorType<void | AsError>>(
|
|
477
|
-
orgId: string,
|
|
478
|
-
params?: GetOrganisationChargesParams, options?: { query?:Partial<UseQueryOptions<Awaited<ReturnType<typeof getOrganisationCharges>>, TError, TData>>, request?: SecondParameter<typeof customInstance>}
|
|
479
|
-
|
|
480
|
-
): UseQueryResult<TData, TError> & { queryKey: QueryKey } => {
|
|
481
|
-
|
|
482
|
-
const queryOptions = getGetOrganisationChargesQueryOptions(orgId,params,options)
|
|
483
|
-
|
|
484
|
-
const query = useQuery(queryOptions) as UseQueryResult<TData, TError> & { queryKey: QueryKey };
|
|
485
|
-
|
|
486
|
-
query.queryKey = queryOptions.queryKey ;
|
|
487
|
-
|
|
488
|
-
return query;
|
|
489
|
-
}
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
export const getGetOrganisationChargesSuspenseQueryOptions = <TData = Awaited<ReturnType<typeof getOrganisationCharges>>, TError = ErrorType<void | AsError>>(orgId: string,
|
|
494
|
-
params?: GetOrganisationChargesParams, options?: { query?:Partial<UseSuspenseQueryOptions<Awaited<ReturnType<typeof getOrganisationCharges>>, TError, TData>>, request?: SecondParameter<typeof customInstance>}
|
|
495
|
-
) => {
|
|
496
|
-
|
|
497
|
-
const {query: queryOptions, request: requestOptions} = options ?? {};
|
|
498
|
-
|
|
499
|
-
const queryKey = queryOptions?.queryKey ?? getGetOrganisationChargesQueryKey(orgId,params);
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
const queryFn: QueryFunction<Awaited<ReturnType<typeof getOrganisationCharges>>> = ({ signal }) => getOrganisationCharges(orgId,params, requestOptions, signal);
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
return { queryKey, queryFn, enabled: !!(orgId), ...queryOptions} as UseSuspenseQueryOptions<Awaited<ReturnType<typeof getOrganisationCharges>>, TError, TData> & { queryKey: QueryKey }
|
|
510
|
-
}
|
|
511
|
-
|
|
512
|
-
export type GetOrganisationChargesSuspenseQueryResult = NonNullable<Awaited<ReturnType<typeof getOrganisationCharges>>>
|
|
513
|
-
export type GetOrganisationChargesSuspenseQueryError = ErrorType<void | AsError>
|
|
514
|
-
|
|
515
|
-
/**
|
|
516
|
-
* @summary Gets charges for all Units in an Organisation
|
|
517
|
-
*/
|
|
518
|
-
export const useGetOrganisationChargesSuspense = <TData = Awaited<ReturnType<typeof getOrganisationCharges>>, TError = ErrorType<void | AsError>>(
|
|
519
|
-
orgId: string,
|
|
520
|
-
params?: GetOrganisationChargesParams, options?: { query?:Partial<UseSuspenseQueryOptions<Awaited<ReturnType<typeof getOrganisationCharges>>, TError, TData>>, request?: SecondParameter<typeof customInstance>}
|
|
521
|
-
|
|
522
|
-
): UseSuspenseQueryResult<TData, TError> & { queryKey: QueryKey } => {
|
|
523
|
-
|
|
524
|
-
const queryOptions = getGetOrganisationChargesSuspenseQueryOptions(orgId,params,options)
|
|
525
|
-
|
|
526
|
-
const query = useSuspenseQuery(queryOptions) as UseSuspenseQueryResult<TData, TError> & { queryKey: QueryKey };
|
|
527
|
-
|
|
528
|
-
query.queryKey = queryOptions.queryKey ;
|
|
529
|
-
|
|
530
|
-
return query;
|
|
531
|
-
}
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
/**
|
|
536
422
|
* Gets the Default Organisation, a built-in Organisation used exclusively for **Personal Units**.
|
|
537
423
|
|
|
538
424
|
Any authorised user can see the Default Organisation.
|