shoal-web-sdk 1.0.135 → 1.0.136
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/sdk/billing/@tanstack/react-query.gen.d.ts +41 -1
- package/dist/sdk/billing/@tanstack/react-query.gen.js +67 -1
- package/dist/sdk/billing/sdk.gen.d.ts +17 -1
- package/dist/sdk/billing/sdk.gen.js +64 -0
- package/dist/sdk/billing/types.gen.d.ts +215 -4
- package/dist/sdk/billing/zod.gen.d.ts +167 -12
- package/dist/sdk/billing/zod.gen.js +79 -4
- package/dist/tanstack-codegen/generated/billing.d.ts +232 -1
- package/dist/tanstack-codegen/generated/billing.js +80 -1
- package/package.json +1 -1
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { type UseMutationOptions } from '@tanstack/react-query';
|
|
2
2
|
import { type Options } from '../sdk.gen';
|
|
3
|
-
import type { CancelSubscriptionData, CancelSubscriptionError, CreateSetupIntentData, CreateSetupIntentError, CreateSetupIntentResponse, CreateSubscriptionData, CreateSubscriptionError, CreateSubscriptionResponse, DeletePaymentMethodData, DeletePaymentMethodError, DeletePaymentMethodResponse, GetCustomerData, GetInvoicesData, GetPlansData, GetUsageData, M2mCreateCustomerData, M2mCreateCustomerError, M2mGetCustomerData, M2mUpdatePlanData, M2mUpdatePlanError, UpdateBillingAddressData, UpdateBillingAddressError, UpdateBillingAddressResponse, UpdateDefaultPaymentMethodData, UpdateDefaultPaymentMethodError, UpdateDefaultPaymentMethodResponse, UpdatePlanData, UpdatePlanError } from '../types.gen';
|
|
3
|
+
import type { CancelSubscriptionData, CancelSubscriptionError, CreateCouponData, CreateCouponError, CreateCouponResponse, CreateSetupIntentData, CreateSetupIntentError, CreateSetupIntentResponse, CreateSubscriptionData, CreateSubscriptionError, CreateSubscriptionResponse, DeleteCouponData, DeleteCouponError, DeleteCouponResponse, DeletePaymentMethodData, DeletePaymentMethodError, DeletePaymentMethodResponse, GetCouponData, GetCustomerData, GetInvoicesData, GetPlansData, GetUsageData, M2mCreateCustomerData, M2mCreateCustomerError, M2mGetCustomerData, M2mUpdatePlanData, M2mUpdatePlanError, RedeemCouponData, RedeemCouponError, RedeemCouponResponse, UpdateBillingAddressData, UpdateBillingAddressError, UpdateBillingAddressResponse, UpdateDefaultPaymentMethodData, UpdateDefaultPaymentMethodError, UpdateDefaultPaymentMethodResponse, UpdatePlanData, UpdatePlanError } from '../types.gen';
|
|
4
4
|
export type QueryKey<TOptions extends Options> = [
|
|
5
5
|
Pick<TOptions, 'baseUrl' | 'body' | 'headers' | 'path' | 'query'> & {
|
|
6
6
|
_id: string;
|
|
@@ -131,6 +131,46 @@ export declare const deletePaymentMethodMutation: (options?: Partial<Options<Del
|
|
|
131
131
|
* Sets the customer's default payment method used for invoices.
|
|
132
132
|
*/
|
|
133
133
|
export declare const updateDefaultPaymentMethodMutation: (options?: Partial<Options<UpdateDefaultPaymentMethodData>>) => UseMutationOptions<UpdateDefaultPaymentMethodResponse, UpdateDefaultPaymentMethodError, Options<UpdateDefaultPaymentMethodData>>;
|
|
134
|
+
export declare const getCouponQueryKey: (options: Options<GetCouponData>) => [Pick<Options<GetCouponData>, "query" | "body" | "headers" | "path" | "baseUrl"> & {
|
|
135
|
+
_id: string;
|
|
136
|
+
_infinite?: boolean;
|
|
137
|
+
tags?: ReadonlyArray<string>;
|
|
138
|
+
}];
|
|
139
|
+
/**
|
|
140
|
+
* Returns a coupon issued to the organisation.
|
|
141
|
+
*/
|
|
142
|
+
export declare const getCouponOptions: (options: Options<GetCouponData>) => import("@tanstack/react-query").OmitKeyof<import("@tanstack/react-query").UseQueryOptions<import("../types.gen").Coupon, Error, import("../types.gen").Coupon, [Pick<Options<GetCouponData>, "query" | "body" | "headers" | "path" | "baseUrl"> & {
|
|
143
|
+
_id: string;
|
|
144
|
+
_infinite?: boolean;
|
|
145
|
+
tags?: ReadonlyArray<string>;
|
|
146
|
+
}]>, "queryFn"> & {
|
|
147
|
+
queryFn?: import("@tanstack/react-query").QueryFunction<import("../types.gen").Coupon, [Pick<Options<GetCouponData>, "query" | "body" | "headers" | "path" | "baseUrl"> & {
|
|
148
|
+
_id: string;
|
|
149
|
+
_infinite?: boolean;
|
|
150
|
+
tags?: ReadonlyArray<string>;
|
|
151
|
+
}], never> | undefined;
|
|
152
|
+
} & {
|
|
153
|
+
queryKey: [Pick<Options<GetCouponData>, "query" | "body" | "headers" | "path" | "baseUrl"> & {
|
|
154
|
+
_id: string;
|
|
155
|
+
_infinite?: boolean;
|
|
156
|
+
tags?: ReadonlyArray<string>;
|
|
157
|
+
}] & {
|
|
158
|
+
[dataTagSymbol]: import("../types.gen").Coupon;
|
|
159
|
+
[dataTagErrorSymbol]: Error;
|
|
160
|
+
};
|
|
161
|
+
};
|
|
162
|
+
/**
|
|
163
|
+
* Redeems a coupon issued to the organisation. The coupon plan must be at or above the current plan.
|
|
164
|
+
*/
|
|
165
|
+
export declare const redeemCouponMutation: (options?: Partial<Options<RedeemCouponData>>) => UseMutationOptions<RedeemCouponResponse, RedeemCouponError, Options<RedeemCouponData>>;
|
|
166
|
+
/**
|
|
167
|
+
* Creates a coupon for any organisation. Requires a platform48.com email.
|
|
168
|
+
*/
|
|
169
|
+
export declare const createCouponMutation: (options?: Partial<Options<CreateCouponData>>) => UseMutationOptions<CreateCouponResponse, CreateCouponError, Options<CreateCouponData>>;
|
|
170
|
+
/**
|
|
171
|
+
* Deletes an unredeemed coupon. Requires a platform48.com email.
|
|
172
|
+
*/
|
|
173
|
+
export declare const deleteCouponMutation: (options?: Partial<Options<DeleteCouponData>>) => UseMutationOptions<DeleteCouponResponse, DeleteCouponError, Options<DeleteCouponData>>;
|
|
134
174
|
export declare const getInvoicesQueryKey: (options: Options<GetInvoicesData>) => [Pick<Options<GetInvoicesData>, "query" | "body" | "headers" | "path" | "baseUrl"> & {
|
|
135
175
|
_id: string;
|
|
136
176
|
_infinite?: boolean;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
// This file is auto-generated by @hey-api/openapi-ts
|
|
2
2
|
import { queryOptions } from '@tanstack/react-query';
|
|
3
3
|
import { client } from '../client.gen';
|
|
4
|
-
import { cancelSubscription, createSetupIntent, createSubscription, deletePaymentMethod, getCustomer, getInvoices, getPlans, getUsage, m2mCreateCustomer, m2mGetCustomer, m2mUpdatePlan, updateBillingAddress, updateDefaultPaymentMethod, updatePlan } from '../sdk.gen';
|
|
4
|
+
import { cancelSubscription, createCoupon, createSetupIntent, createSubscription, deleteCoupon, deletePaymentMethod, getCoupon, getCustomer, getInvoices, getPlans, getUsage, m2mCreateCustomer, m2mGetCustomer, m2mUpdatePlan, redeemCoupon, updateBillingAddress, updateDefaultPaymentMethod, updatePlan } from '../sdk.gen';
|
|
5
5
|
const createQueryKey = (id, options, infinite, tags) => {
|
|
6
6
|
const params = { _id: id, baseUrl: options?.baseUrl || (options?.client ?? client).getConfig().baseUrl };
|
|
7
7
|
if (infinite) {
|
|
@@ -203,6 +203,72 @@ export const updateDefaultPaymentMethodMutation = (options) => {
|
|
|
203
203
|
};
|
|
204
204
|
return mutationOptions;
|
|
205
205
|
};
|
|
206
|
+
export const getCouponQueryKey = (options) => createQueryKey('getCoupon', options);
|
|
207
|
+
/**
|
|
208
|
+
* Returns a coupon issued to the organisation.
|
|
209
|
+
*/
|
|
210
|
+
export const getCouponOptions = (options) => {
|
|
211
|
+
return queryOptions({
|
|
212
|
+
queryFn: async ({ queryKey, signal }) => {
|
|
213
|
+
const { data } = await getCoupon({
|
|
214
|
+
...options,
|
|
215
|
+
...queryKey[0],
|
|
216
|
+
signal,
|
|
217
|
+
throwOnError: true
|
|
218
|
+
});
|
|
219
|
+
return data;
|
|
220
|
+
},
|
|
221
|
+
queryKey: getCouponQueryKey(options)
|
|
222
|
+
});
|
|
223
|
+
};
|
|
224
|
+
/**
|
|
225
|
+
* Redeems a coupon issued to the organisation. The coupon plan must be at or above the current plan.
|
|
226
|
+
*/
|
|
227
|
+
export const redeemCouponMutation = (options) => {
|
|
228
|
+
const mutationOptions = {
|
|
229
|
+
mutationFn: async (fnOptions) => {
|
|
230
|
+
const { data } = await redeemCoupon({
|
|
231
|
+
...options,
|
|
232
|
+
...fnOptions,
|
|
233
|
+
throwOnError: true
|
|
234
|
+
});
|
|
235
|
+
return data;
|
|
236
|
+
}
|
|
237
|
+
};
|
|
238
|
+
return mutationOptions;
|
|
239
|
+
};
|
|
240
|
+
/**
|
|
241
|
+
* Creates a coupon for any organisation. Requires a platform48.com email.
|
|
242
|
+
*/
|
|
243
|
+
export const createCouponMutation = (options) => {
|
|
244
|
+
const mutationOptions = {
|
|
245
|
+
mutationFn: async (fnOptions) => {
|
|
246
|
+
const { data } = await createCoupon({
|
|
247
|
+
...options,
|
|
248
|
+
...fnOptions,
|
|
249
|
+
throwOnError: true
|
|
250
|
+
});
|
|
251
|
+
return data;
|
|
252
|
+
}
|
|
253
|
+
};
|
|
254
|
+
return mutationOptions;
|
|
255
|
+
};
|
|
256
|
+
/**
|
|
257
|
+
* Deletes an unredeemed coupon. Requires a platform48.com email.
|
|
258
|
+
*/
|
|
259
|
+
export const deleteCouponMutation = (options) => {
|
|
260
|
+
const mutationOptions = {
|
|
261
|
+
mutationFn: async (fnOptions) => {
|
|
262
|
+
const { data } = await deleteCoupon({
|
|
263
|
+
...options,
|
|
264
|
+
...fnOptions,
|
|
265
|
+
throwOnError: true
|
|
266
|
+
});
|
|
267
|
+
return data;
|
|
268
|
+
}
|
|
269
|
+
};
|
|
270
|
+
return mutationOptions;
|
|
271
|
+
};
|
|
206
272
|
export const getInvoicesQueryKey = (options) => createQueryKey('getInvoices', options);
|
|
207
273
|
/**
|
|
208
274
|
* Returns a page of the customer's invoices. This response is paginated.
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { Client, Options as Options2, TDataShape } from './client';
|
|
2
|
-
import type { CancelSubscriptionData, CancelSubscriptionErrors, CancelSubscriptionResponses, CreateSetupIntentData, CreateSetupIntentErrors, CreateSetupIntentResponses, CreateSubscriptionData, CreateSubscriptionErrors, CreateSubscriptionResponses, DeletePaymentMethodData, DeletePaymentMethodErrors, DeletePaymentMethodResponses, GetCustomerData, GetCustomerErrors, GetCustomerResponses, GetInvoicesData, GetInvoicesErrors, GetInvoicesResponses, GetPlansData, GetPlansErrors, GetPlansResponses, GetUsageData, GetUsageErrors, GetUsageResponses, M2mCreateCustomerData, M2mCreateCustomerErrors, M2mCreateCustomerResponses, M2mGetCustomerData, M2mGetCustomerErrors, M2mGetCustomerResponses, M2mUpdatePlanData, M2mUpdatePlanErrors, M2mUpdatePlanResponses, UpdateBillingAddressData, UpdateBillingAddressErrors, UpdateBillingAddressResponses, UpdateDefaultPaymentMethodData, UpdateDefaultPaymentMethodErrors, UpdateDefaultPaymentMethodResponses, UpdatePlanData, UpdatePlanErrors, UpdatePlanResponses } from './types.gen';
|
|
2
|
+
import type { CancelSubscriptionData, CancelSubscriptionErrors, CancelSubscriptionResponses, CreateCouponData, CreateCouponErrors, CreateCouponResponses, CreateSetupIntentData, CreateSetupIntentErrors, CreateSetupIntentResponses, CreateSubscriptionData, CreateSubscriptionErrors, CreateSubscriptionResponses, DeleteCouponData, DeleteCouponErrors, DeleteCouponResponses, DeletePaymentMethodData, DeletePaymentMethodErrors, DeletePaymentMethodResponses, GetCouponData, GetCouponErrors, GetCouponResponses, GetCustomerData, GetCustomerErrors, GetCustomerResponses, GetInvoicesData, GetInvoicesErrors, GetInvoicesResponses, GetPlansData, GetPlansErrors, GetPlansResponses, GetUsageData, GetUsageErrors, GetUsageResponses, M2mCreateCustomerData, M2mCreateCustomerErrors, M2mCreateCustomerResponses, M2mGetCustomerData, M2mGetCustomerErrors, M2mGetCustomerResponses, M2mUpdatePlanData, M2mUpdatePlanErrors, M2mUpdatePlanResponses, RedeemCouponData, RedeemCouponErrors, RedeemCouponResponses, UpdateBillingAddressData, UpdateBillingAddressErrors, UpdateBillingAddressResponses, UpdateDefaultPaymentMethodData, UpdateDefaultPaymentMethodErrors, UpdateDefaultPaymentMethodResponses, UpdatePlanData, UpdatePlanErrors, UpdatePlanResponses } from './types.gen';
|
|
3
3
|
export type Options<TData extends TDataShape = TDataShape, ThrowOnError extends boolean = boolean> = Options2<TData, ThrowOnError> & {
|
|
4
4
|
/**
|
|
5
5
|
* You can provide a client instance returned by `createClient()` instead of
|
|
@@ -64,6 +64,22 @@ export declare const deletePaymentMethod: <ThrowOnError extends boolean = false>
|
|
|
64
64
|
* Sets the customer's default payment method used for invoices.
|
|
65
65
|
*/
|
|
66
66
|
export declare const updateDefaultPaymentMethod: <ThrowOnError extends boolean = false>(options: Options<UpdateDefaultPaymentMethodData, ThrowOnError>) => import("./client").RequestResult<UpdateDefaultPaymentMethodResponses, UpdateDefaultPaymentMethodErrors, ThrowOnError, "fields">;
|
|
67
|
+
/**
|
|
68
|
+
* Returns a coupon issued to the organisation.
|
|
69
|
+
*/
|
|
70
|
+
export declare const getCoupon: <ThrowOnError extends boolean = false>(options: Options<GetCouponData, ThrowOnError>) => import("./client").RequestResult<GetCouponResponses, GetCouponErrors, ThrowOnError, "fields">;
|
|
71
|
+
/**
|
|
72
|
+
* Redeems a coupon issued to the organisation. The coupon plan must be at or above the current plan.
|
|
73
|
+
*/
|
|
74
|
+
export declare const redeemCoupon: <ThrowOnError extends boolean = false>(options: Options<RedeemCouponData, ThrowOnError>) => import("./client").RequestResult<RedeemCouponResponses, RedeemCouponErrors, ThrowOnError, "fields">;
|
|
75
|
+
/**
|
|
76
|
+
* Creates a coupon for any organisation. Requires a platform48.com email.
|
|
77
|
+
*/
|
|
78
|
+
export declare const createCoupon: <ThrowOnError extends boolean = false>(options: Options<CreateCouponData, ThrowOnError>) => import("./client").RequestResult<CreateCouponResponses, CreateCouponErrors, ThrowOnError, "fields">;
|
|
79
|
+
/**
|
|
80
|
+
* Deletes an unredeemed coupon. Requires a platform48.com email.
|
|
81
|
+
*/
|
|
82
|
+
export declare const deleteCoupon: <ThrowOnError extends boolean = false>(options: Options<DeleteCouponData, ThrowOnError>) => import("./client").RequestResult<DeleteCouponResponses, DeleteCouponErrors, ThrowOnError, "fields">;
|
|
67
83
|
/**
|
|
68
84
|
* Returns a page of the customer's invoices. This response is paginated.
|
|
69
85
|
*/
|
|
@@ -173,6 +173,70 @@ export const updateDefaultPaymentMethod = (options) => {
|
|
|
173
173
|
...options
|
|
174
174
|
});
|
|
175
175
|
};
|
|
176
|
+
/**
|
|
177
|
+
* Returns a coupon issued to the organisation.
|
|
178
|
+
*/
|
|
179
|
+
export const getCoupon = (options) => {
|
|
180
|
+
return (options.client ?? client).get({
|
|
181
|
+
security: [
|
|
182
|
+
{
|
|
183
|
+
scheme: 'bearer',
|
|
184
|
+
type: 'http'
|
|
185
|
+
}
|
|
186
|
+
],
|
|
187
|
+
url: '/api/v1/coupon/{org}/{code}',
|
|
188
|
+
...options
|
|
189
|
+
});
|
|
190
|
+
};
|
|
191
|
+
/**
|
|
192
|
+
* Redeems a coupon issued to the organisation. The coupon plan must be at or above the current plan.
|
|
193
|
+
*/
|
|
194
|
+
export const redeemCoupon = (options) => {
|
|
195
|
+
return (options.client ?? client).post({
|
|
196
|
+
security: [
|
|
197
|
+
{
|
|
198
|
+
scheme: 'bearer',
|
|
199
|
+
type: 'http'
|
|
200
|
+
}
|
|
201
|
+
],
|
|
202
|
+
url: '/api/v1/coupon/{org}/{code}/redeem',
|
|
203
|
+
...options
|
|
204
|
+
});
|
|
205
|
+
};
|
|
206
|
+
/**
|
|
207
|
+
* Creates a coupon for any organisation. Requires a platform48.com email.
|
|
208
|
+
*/
|
|
209
|
+
export const createCoupon = (options) => {
|
|
210
|
+
return (options.client ?? client).post({
|
|
211
|
+
security: [
|
|
212
|
+
{
|
|
213
|
+
scheme: 'bearer',
|
|
214
|
+
type: 'http'
|
|
215
|
+
}
|
|
216
|
+
],
|
|
217
|
+
url: '/api/v1/admin/coupon',
|
|
218
|
+
...options,
|
|
219
|
+
headers: {
|
|
220
|
+
'Content-Type': 'application/json',
|
|
221
|
+
...options.headers
|
|
222
|
+
}
|
|
223
|
+
});
|
|
224
|
+
};
|
|
225
|
+
/**
|
|
226
|
+
* Deletes an unredeemed coupon. Requires a platform48.com email.
|
|
227
|
+
*/
|
|
228
|
+
export const deleteCoupon = (options) => {
|
|
229
|
+
return (options.client ?? client).delete({
|
|
230
|
+
security: [
|
|
231
|
+
{
|
|
232
|
+
scheme: 'bearer',
|
|
233
|
+
type: 'http'
|
|
234
|
+
}
|
|
235
|
+
],
|
|
236
|
+
url: '/api/v1/admin/coupon/{code}',
|
|
237
|
+
...options
|
|
238
|
+
});
|
|
239
|
+
};
|
|
176
240
|
/**
|
|
177
241
|
* Returns a page of the customer's invoices. This response is paginated.
|
|
178
242
|
*/
|
|
@@ -85,6 +85,46 @@ export type PlanFeatureResponse = {
|
|
|
85
85
|
};
|
|
86
86
|
export type CategoryPeriodResponse = 'day' | 'week' | 'month' | 'year' | 'onetime';
|
|
87
87
|
export type BillingInterval = 'monthly' | 'annual';
|
|
88
|
+
export type CouponPlan = 'solo' | 'indie' | 'pro' | 'enterprise';
|
|
89
|
+
export type Coupon = {
|
|
90
|
+
code: string;
|
|
91
|
+
plan?: CouponPlan;
|
|
92
|
+
planDays: number;
|
|
93
|
+
/**
|
|
94
|
+
* Whether the plan is granted as a trial. Only valid for the pro plan.
|
|
95
|
+
*/
|
|
96
|
+
trial: boolean;
|
|
97
|
+
/**
|
|
98
|
+
* Usage credit in cents.
|
|
99
|
+
*/
|
|
100
|
+
creditUsd: number;
|
|
101
|
+
expiry: string;
|
|
102
|
+
expired: boolean;
|
|
103
|
+
redeemed: boolean;
|
|
104
|
+
};
|
|
105
|
+
export type AdminCoupon = Coupon & {
|
|
106
|
+
/**
|
|
107
|
+
* Kinde organisation id.
|
|
108
|
+
*/
|
|
109
|
+
org: string;
|
|
110
|
+
};
|
|
111
|
+
export type CreateCoupon = {
|
|
112
|
+
/**
|
|
113
|
+
* Kinde organisation id.
|
|
114
|
+
*/
|
|
115
|
+
org: string;
|
|
116
|
+
plan?: CouponPlan;
|
|
117
|
+
planDays: number;
|
|
118
|
+
/**
|
|
119
|
+
* Whether the plan is granted as a trial. Only valid for the pro plan.
|
|
120
|
+
*/
|
|
121
|
+
trial: boolean;
|
|
122
|
+
/**
|
|
123
|
+
* Usage credit in cents.
|
|
124
|
+
*/
|
|
125
|
+
creditUsd: number;
|
|
126
|
+
expiresInDays: number;
|
|
127
|
+
};
|
|
88
128
|
export type UpdatePlan = {
|
|
89
129
|
plan: string;
|
|
90
130
|
billingInterval: BillingInterval;
|
|
@@ -167,7 +207,7 @@ export type CustomerResponse = {
|
|
|
167
207
|
readonly scheduledChangeAt?: number;
|
|
168
208
|
readonly seats: number;
|
|
169
209
|
readonly paymentMethods: Array<PaymentMethodSummary>;
|
|
170
|
-
readonly estimatedCreditBalanceUSD:
|
|
210
|
+
readonly estimatedCreditBalanceUSD: number;
|
|
171
211
|
readonly upcomingInvoiceTotalCents?: number;
|
|
172
212
|
/**
|
|
173
213
|
* The address Stripe Tax uses for the customer's tax location. Null when none is set.
|
|
@@ -178,17 +218,17 @@ export type UsageInfoResponse = {
|
|
|
178
218
|
meters: {
|
|
179
219
|
[key: string]: MeterType;
|
|
180
220
|
};
|
|
181
|
-
total:
|
|
221
|
+
total: number;
|
|
182
222
|
from: string;
|
|
183
223
|
to: string;
|
|
184
224
|
};
|
|
185
225
|
export type UsagePoint = {
|
|
186
226
|
date: string;
|
|
187
|
-
amount:
|
|
227
|
+
amount: number;
|
|
188
228
|
};
|
|
189
229
|
export type MeterType = {
|
|
190
230
|
displayName: string;
|
|
191
|
-
total:
|
|
231
|
+
total: number;
|
|
192
232
|
points: Array<UsagePoint>;
|
|
193
233
|
};
|
|
194
234
|
export type CatalogResponseWritable = {
|
|
@@ -264,6 +304,10 @@ export type PaymentMethodId = string;
|
|
|
264
304
|
* Kinde organisation id.
|
|
265
305
|
*/
|
|
266
306
|
export type OrganisationId = string;
|
|
307
|
+
/**
|
|
308
|
+
* A coupon code.
|
|
309
|
+
*/
|
|
310
|
+
export type CouponCode = string;
|
|
267
311
|
/**
|
|
268
312
|
* A valid currency.
|
|
269
313
|
*/
|
|
@@ -660,6 +704,173 @@ export type UpdateDefaultPaymentMethodResponses = {
|
|
|
660
704
|
204: void;
|
|
661
705
|
};
|
|
662
706
|
export type UpdateDefaultPaymentMethodResponse = UpdateDefaultPaymentMethodResponses[keyof UpdateDefaultPaymentMethodResponses];
|
|
707
|
+
export type GetCouponData = {
|
|
708
|
+
body?: never;
|
|
709
|
+
path: {
|
|
710
|
+
/**
|
|
711
|
+
* Kinde organisation id.
|
|
712
|
+
*/
|
|
713
|
+
org: string;
|
|
714
|
+
/**
|
|
715
|
+
* A coupon code.
|
|
716
|
+
*/
|
|
717
|
+
code: string;
|
|
718
|
+
};
|
|
719
|
+
query?: never;
|
|
720
|
+
url: '/api/v1/coupon/{org}/{code}';
|
|
721
|
+
};
|
|
722
|
+
export type GetCouponErrors = {
|
|
723
|
+
/**
|
|
724
|
+
* Unauthorised user
|
|
725
|
+
*/
|
|
726
|
+
401: _Error;
|
|
727
|
+
/**
|
|
728
|
+
* User does not belong to the organisation
|
|
729
|
+
*/
|
|
730
|
+
403: _Error;
|
|
731
|
+
/**
|
|
732
|
+
* Coupon not found
|
|
733
|
+
*/
|
|
734
|
+
404: _Error;
|
|
735
|
+
/**
|
|
736
|
+
* Unexpected error.
|
|
737
|
+
*/
|
|
738
|
+
500: _Error;
|
|
739
|
+
};
|
|
740
|
+
export type GetCouponError = GetCouponErrors[keyof GetCouponErrors];
|
|
741
|
+
export type GetCouponResponses = {
|
|
742
|
+
/**
|
|
743
|
+
* The coupon
|
|
744
|
+
*/
|
|
745
|
+
200: Coupon;
|
|
746
|
+
};
|
|
747
|
+
export type GetCouponResponse = GetCouponResponses[keyof GetCouponResponses];
|
|
748
|
+
export type RedeemCouponData = {
|
|
749
|
+
body?: never;
|
|
750
|
+
path: {
|
|
751
|
+
/**
|
|
752
|
+
* Kinde organisation id.
|
|
753
|
+
*/
|
|
754
|
+
org: string;
|
|
755
|
+
/**
|
|
756
|
+
* A coupon code.
|
|
757
|
+
*/
|
|
758
|
+
code: string;
|
|
759
|
+
};
|
|
760
|
+
query?: never;
|
|
761
|
+
url: '/api/v1/coupon/{org}/{code}/redeem';
|
|
762
|
+
};
|
|
763
|
+
export type RedeemCouponErrors = {
|
|
764
|
+
/**
|
|
765
|
+
* Unauthorised user
|
|
766
|
+
*/
|
|
767
|
+
401: _Error;
|
|
768
|
+
/**
|
|
769
|
+
* Missing the coupon:write:redeem permission
|
|
770
|
+
*/
|
|
771
|
+
403: _Error;
|
|
772
|
+
/**
|
|
773
|
+
* Account or coupon not found
|
|
774
|
+
*/
|
|
775
|
+
404: _Error;
|
|
776
|
+
/**
|
|
777
|
+
* Coupon already redeemed
|
|
778
|
+
*/
|
|
779
|
+
409: _Error;
|
|
780
|
+
/**
|
|
781
|
+
* Coupon has expired or its plan is below the current plan
|
|
782
|
+
*/
|
|
783
|
+
422: _Error;
|
|
784
|
+
/**
|
|
785
|
+
* Unexpected error.
|
|
786
|
+
*/
|
|
787
|
+
500: _Error;
|
|
788
|
+
};
|
|
789
|
+
export type RedeemCouponError = RedeemCouponErrors[keyof RedeemCouponErrors];
|
|
790
|
+
export type RedeemCouponResponses = {
|
|
791
|
+
/**
|
|
792
|
+
* The redeemed coupon
|
|
793
|
+
*/
|
|
794
|
+
200: Coupon;
|
|
795
|
+
};
|
|
796
|
+
export type RedeemCouponResponse = RedeemCouponResponses[keyof RedeemCouponResponses];
|
|
797
|
+
export type CreateCouponData = {
|
|
798
|
+
body: CreateCoupon;
|
|
799
|
+
path?: never;
|
|
800
|
+
query?: never;
|
|
801
|
+
url: '/api/v1/admin/coupon';
|
|
802
|
+
};
|
|
803
|
+
export type CreateCouponErrors = {
|
|
804
|
+
/**
|
|
805
|
+
* Invalid request body
|
|
806
|
+
*/
|
|
807
|
+
400: _Error;
|
|
808
|
+
/**
|
|
809
|
+
* Unauthorised user
|
|
810
|
+
*/
|
|
811
|
+
401: _Error;
|
|
812
|
+
/**
|
|
813
|
+
* Requires a platform48.com email
|
|
814
|
+
*/
|
|
815
|
+
403: _Error;
|
|
816
|
+
/**
|
|
817
|
+
* Organisation not found
|
|
818
|
+
*/
|
|
819
|
+
404: _Error;
|
|
820
|
+
/**
|
|
821
|
+
* Unexpected error.
|
|
822
|
+
*/
|
|
823
|
+
500: _Error;
|
|
824
|
+
};
|
|
825
|
+
export type CreateCouponError = CreateCouponErrors[keyof CreateCouponErrors];
|
|
826
|
+
export type CreateCouponResponses = {
|
|
827
|
+
/**
|
|
828
|
+
* The new coupon
|
|
829
|
+
*/
|
|
830
|
+
201: AdminCoupon;
|
|
831
|
+
};
|
|
832
|
+
export type CreateCouponResponse = CreateCouponResponses[keyof CreateCouponResponses];
|
|
833
|
+
export type DeleteCouponData = {
|
|
834
|
+
body?: never;
|
|
835
|
+
path: {
|
|
836
|
+
/**
|
|
837
|
+
* A coupon code.
|
|
838
|
+
*/
|
|
839
|
+
code: string;
|
|
840
|
+
};
|
|
841
|
+
query?: never;
|
|
842
|
+
url: '/api/v1/admin/coupon/{code}';
|
|
843
|
+
};
|
|
844
|
+
export type DeleteCouponErrors = {
|
|
845
|
+
/**
|
|
846
|
+
* Unauthorised user
|
|
847
|
+
*/
|
|
848
|
+
401: _Error;
|
|
849
|
+
/**
|
|
850
|
+
* Requires a platform48.com email
|
|
851
|
+
*/
|
|
852
|
+
403: _Error;
|
|
853
|
+
/**
|
|
854
|
+
* Coupon not found
|
|
855
|
+
*/
|
|
856
|
+
404: _Error;
|
|
857
|
+
/**
|
|
858
|
+
* Coupon already redeemed
|
|
859
|
+
*/
|
|
860
|
+
409: _Error;
|
|
861
|
+
/**
|
|
862
|
+
* Unexpected error.
|
|
863
|
+
*/
|
|
864
|
+
500: _Error;
|
|
865
|
+
};
|
|
866
|
+
export type DeleteCouponError = DeleteCouponErrors[keyof DeleteCouponErrors];
|
|
867
|
+
export type DeleteCouponResponses = {
|
|
868
|
+
/**
|
|
869
|
+
* Coupon deleted
|
|
870
|
+
*/
|
|
871
|
+
204: void;
|
|
872
|
+
};
|
|
873
|
+
export type DeleteCouponResponse = DeleteCouponResponses[keyof DeleteCouponResponses];
|
|
663
874
|
export type GetInvoicesData = {
|
|
664
875
|
body?: never;
|
|
665
876
|
path: {
|
|
@@ -2058,6 +2058,57 @@ export declare const zBillingInterval: z.ZodEnum<{
|
|
|
2058
2058
|
monthly: "monthly";
|
|
2059
2059
|
annual: "annual";
|
|
2060
2060
|
}>;
|
|
2061
|
+
export declare const zCouponPlan: z.ZodEnum<{
|
|
2062
|
+
pro: "pro";
|
|
2063
|
+
enterprise: "enterprise";
|
|
2064
|
+
solo: "solo";
|
|
2065
|
+
indie: "indie";
|
|
2066
|
+
}>;
|
|
2067
|
+
export declare const zCoupon: z.ZodObject<{
|
|
2068
|
+
code: z.ZodString;
|
|
2069
|
+
plan: z.ZodOptional<z.ZodEnum<{
|
|
2070
|
+
pro: "pro";
|
|
2071
|
+
enterprise: "enterprise";
|
|
2072
|
+
solo: "solo";
|
|
2073
|
+
indie: "indie";
|
|
2074
|
+
}>>;
|
|
2075
|
+
planDays: z.ZodInt;
|
|
2076
|
+
trial: z.ZodBoolean;
|
|
2077
|
+
creditUsd: z.ZodCoercedBigInt<unknown>;
|
|
2078
|
+
expiry: z.ZodISODateTime;
|
|
2079
|
+
expired: z.ZodBoolean;
|
|
2080
|
+
redeemed: z.ZodBoolean;
|
|
2081
|
+
}, z.core.$strip>;
|
|
2082
|
+
export declare const zAdminCoupon: z.ZodIntersection<z.ZodObject<{
|
|
2083
|
+
code: z.ZodString;
|
|
2084
|
+
plan: z.ZodOptional<z.ZodEnum<{
|
|
2085
|
+
pro: "pro";
|
|
2086
|
+
enterprise: "enterprise";
|
|
2087
|
+
solo: "solo";
|
|
2088
|
+
indie: "indie";
|
|
2089
|
+
}>>;
|
|
2090
|
+
planDays: z.ZodInt;
|
|
2091
|
+
trial: z.ZodBoolean;
|
|
2092
|
+
creditUsd: z.ZodCoercedBigInt<unknown>;
|
|
2093
|
+
expiry: z.ZodISODateTime;
|
|
2094
|
+
expired: z.ZodBoolean;
|
|
2095
|
+
redeemed: z.ZodBoolean;
|
|
2096
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
2097
|
+
org: z.ZodString;
|
|
2098
|
+
}, z.core.$strip>>;
|
|
2099
|
+
export declare const zCreateCoupon: z.ZodObject<{
|
|
2100
|
+
org: z.ZodString;
|
|
2101
|
+
plan: z.ZodOptional<z.ZodEnum<{
|
|
2102
|
+
pro: "pro";
|
|
2103
|
+
enterprise: "enterprise";
|
|
2104
|
+
solo: "solo";
|
|
2105
|
+
indie: "indie";
|
|
2106
|
+
}>>;
|
|
2107
|
+
planDays: z.ZodInt;
|
|
2108
|
+
trial: z.ZodBoolean;
|
|
2109
|
+
creditUsd: z.ZodCoercedBigInt<unknown>;
|
|
2110
|
+
expiresInDays: z.ZodInt;
|
|
2111
|
+
}, z.core.$strip>;
|
|
2061
2112
|
export declare const zUpdatePlan: z.ZodObject<{
|
|
2062
2113
|
plan: z.ZodString;
|
|
2063
2114
|
billingInterval: z.ZodEnum<{
|
|
@@ -3106,7 +3157,7 @@ export declare const zCustomerResponse: z.ZodObject<{
|
|
|
3106
3157
|
expYear: z.ZodReadonly<z.ZodInt>;
|
|
3107
3158
|
isDefault: z.ZodReadonly<z.ZodBoolean>;
|
|
3108
3159
|
}, z.core.$strip>>>;
|
|
3109
|
-
estimatedCreditBalanceUSD: z.ZodReadonly<z.
|
|
3160
|
+
estimatedCreditBalanceUSD: z.ZodReadonly<z.ZodNumber>;
|
|
3110
3161
|
upcomingInvoiceTotalCents: z.ZodOptional<z.ZodReadonly<z.ZodInt>>;
|
|
3111
3162
|
billingAddress: z.ZodOptional<z.ZodObject<{
|
|
3112
3163
|
name: z.ZodString;
|
|
@@ -3120,26 +3171,26 @@ export declare const zCustomerResponse: z.ZodObject<{
|
|
|
3120
3171
|
}, z.core.$strip>;
|
|
3121
3172
|
export declare const zUsagePoint: z.ZodObject<{
|
|
3122
3173
|
date: z.ZodISODateTime;
|
|
3123
|
-
amount: z.
|
|
3174
|
+
amount: z.ZodNumber;
|
|
3124
3175
|
}, z.core.$strip>;
|
|
3125
3176
|
export declare const zMeterType: z.ZodObject<{
|
|
3126
3177
|
displayName: z.ZodString;
|
|
3127
|
-
total: z.
|
|
3178
|
+
total: z.ZodNumber;
|
|
3128
3179
|
points: z.ZodArray<z.ZodObject<{
|
|
3129
3180
|
date: z.ZodISODateTime;
|
|
3130
|
-
amount: z.
|
|
3181
|
+
amount: z.ZodNumber;
|
|
3131
3182
|
}, z.core.$strip>>;
|
|
3132
3183
|
}, z.core.$strip>;
|
|
3133
3184
|
export declare const zUsageInfoResponse: z.ZodObject<{
|
|
3134
3185
|
meters: z.ZodRecord<z.ZodString, z.ZodObject<{
|
|
3135
3186
|
displayName: z.ZodString;
|
|
3136
|
-
total: z.
|
|
3187
|
+
total: z.ZodNumber;
|
|
3137
3188
|
points: z.ZodArray<z.ZodObject<{
|
|
3138
3189
|
date: z.ZodISODateTime;
|
|
3139
|
-
amount: z.
|
|
3190
|
+
amount: z.ZodNumber;
|
|
3140
3191
|
}, z.core.$strip>>;
|
|
3141
3192
|
}, z.core.$strip>>;
|
|
3142
|
-
total: z.
|
|
3193
|
+
total: z.ZodNumber;
|
|
3143
3194
|
from: z.ZodISODateTime;
|
|
3144
3195
|
to: z.ZodISODateTime;
|
|
3145
3196
|
}, z.core.$strip>;
|
|
@@ -4924,6 +4975,10 @@ export declare const zPaymentMethodId: z.ZodString;
|
|
|
4924
4975
|
* Kinde organisation id.
|
|
4925
4976
|
*/
|
|
4926
4977
|
export declare const zOrganisationId: z.ZodString;
|
|
4978
|
+
/**
|
|
4979
|
+
* A coupon code.
|
|
4980
|
+
*/
|
|
4981
|
+
export declare const zCouponCode: z.ZodString;
|
|
4927
4982
|
/**
|
|
4928
4983
|
* A valid currency.
|
|
4929
4984
|
*/
|
|
@@ -5597,7 +5652,7 @@ export declare const zGetCustomerResponse: z.ZodObject<{
|
|
|
5597
5652
|
expYear: z.ZodReadonly<z.ZodInt>;
|
|
5598
5653
|
isDefault: z.ZodReadonly<z.ZodBoolean>;
|
|
5599
5654
|
}, z.core.$strip>>>;
|
|
5600
|
-
estimatedCreditBalanceUSD: z.ZodReadonly<z.
|
|
5655
|
+
estimatedCreditBalanceUSD: z.ZodReadonly<z.ZodNumber>;
|
|
5601
5656
|
upcomingInvoiceTotalCents: z.ZodOptional<z.ZodReadonly<z.ZodInt>>;
|
|
5602
5657
|
billingAddress: z.ZodOptional<z.ZodObject<{
|
|
5603
5658
|
name: z.ZodString;
|
|
@@ -5629,13 +5684,13 @@ export declare const zGetUsageData: z.ZodObject<{
|
|
|
5629
5684
|
export declare const zGetUsageResponse: z.ZodObject<{
|
|
5630
5685
|
meters: z.ZodRecord<z.ZodString, z.ZodObject<{
|
|
5631
5686
|
displayName: z.ZodString;
|
|
5632
|
-
total: z.
|
|
5687
|
+
total: z.ZodNumber;
|
|
5633
5688
|
points: z.ZodArray<z.ZodObject<{
|
|
5634
5689
|
date: z.ZodISODateTime;
|
|
5635
|
-
amount: z.
|
|
5690
|
+
amount: z.ZodNumber;
|
|
5636
5691
|
}, z.core.$strip>>;
|
|
5637
5692
|
}, z.core.$strip>>;
|
|
5638
|
-
total: z.
|
|
5693
|
+
total: z.ZodNumber;
|
|
5639
5694
|
from: z.ZodISODateTime;
|
|
5640
5695
|
to: z.ZodISODateTime;
|
|
5641
5696
|
}, z.core.$strip>;
|
|
@@ -7050,6 +7105,106 @@ export declare const zUpdateDefaultPaymentMethodData: z.ZodObject<{
|
|
|
7050
7105
|
* Default payment method updated
|
|
7051
7106
|
*/
|
|
7052
7107
|
export declare const zUpdateDefaultPaymentMethodResponse: z.ZodVoid;
|
|
7108
|
+
export declare const zGetCouponData: z.ZodObject<{
|
|
7109
|
+
body: z.ZodOptional<z.ZodNever>;
|
|
7110
|
+
path: z.ZodObject<{
|
|
7111
|
+
org: z.ZodString;
|
|
7112
|
+
code: z.ZodString;
|
|
7113
|
+
}, z.core.$strip>;
|
|
7114
|
+
query: z.ZodOptional<z.ZodNever>;
|
|
7115
|
+
}, z.core.$strip>;
|
|
7116
|
+
/**
|
|
7117
|
+
* The coupon
|
|
7118
|
+
*/
|
|
7119
|
+
export declare const zGetCouponResponse: z.ZodObject<{
|
|
7120
|
+
code: z.ZodString;
|
|
7121
|
+
plan: z.ZodOptional<z.ZodEnum<{
|
|
7122
|
+
pro: "pro";
|
|
7123
|
+
enterprise: "enterprise";
|
|
7124
|
+
solo: "solo";
|
|
7125
|
+
indie: "indie";
|
|
7126
|
+
}>>;
|
|
7127
|
+
planDays: z.ZodInt;
|
|
7128
|
+
trial: z.ZodBoolean;
|
|
7129
|
+
creditUsd: z.ZodCoercedBigInt<unknown>;
|
|
7130
|
+
expiry: z.ZodISODateTime;
|
|
7131
|
+
expired: z.ZodBoolean;
|
|
7132
|
+
redeemed: z.ZodBoolean;
|
|
7133
|
+
}, z.core.$strip>;
|
|
7134
|
+
export declare const zRedeemCouponData: z.ZodObject<{
|
|
7135
|
+
body: z.ZodOptional<z.ZodNever>;
|
|
7136
|
+
path: z.ZodObject<{
|
|
7137
|
+
org: z.ZodString;
|
|
7138
|
+
code: z.ZodString;
|
|
7139
|
+
}, z.core.$strip>;
|
|
7140
|
+
query: z.ZodOptional<z.ZodNever>;
|
|
7141
|
+
}, z.core.$strip>;
|
|
7142
|
+
/**
|
|
7143
|
+
* The redeemed coupon
|
|
7144
|
+
*/
|
|
7145
|
+
export declare const zRedeemCouponResponse: z.ZodObject<{
|
|
7146
|
+
code: z.ZodString;
|
|
7147
|
+
plan: z.ZodOptional<z.ZodEnum<{
|
|
7148
|
+
pro: "pro";
|
|
7149
|
+
enterprise: "enterprise";
|
|
7150
|
+
solo: "solo";
|
|
7151
|
+
indie: "indie";
|
|
7152
|
+
}>>;
|
|
7153
|
+
planDays: z.ZodInt;
|
|
7154
|
+
trial: z.ZodBoolean;
|
|
7155
|
+
creditUsd: z.ZodCoercedBigInt<unknown>;
|
|
7156
|
+
expiry: z.ZodISODateTime;
|
|
7157
|
+
expired: z.ZodBoolean;
|
|
7158
|
+
redeemed: z.ZodBoolean;
|
|
7159
|
+
}, z.core.$strip>;
|
|
7160
|
+
export declare const zCreateCouponData: z.ZodObject<{
|
|
7161
|
+
body: z.ZodObject<{
|
|
7162
|
+
org: z.ZodString;
|
|
7163
|
+
plan: z.ZodOptional<z.ZodEnum<{
|
|
7164
|
+
pro: "pro";
|
|
7165
|
+
enterprise: "enterprise";
|
|
7166
|
+
solo: "solo";
|
|
7167
|
+
indie: "indie";
|
|
7168
|
+
}>>;
|
|
7169
|
+
planDays: z.ZodInt;
|
|
7170
|
+
trial: z.ZodBoolean;
|
|
7171
|
+
creditUsd: z.ZodCoercedBigInt<unknown>;
|
|
7172
|
+
expiresInDays: z.ZodInt;
|
|
7173
|
+
}, z.core.$strip>;
|
|
7174
|
+
path: z.ZodOptional<z.ZodNever>;
|
|
7175
|
+
query: z.ZodOptional<z.ZodNever>;
|
|
7176
|
+
}, z.core.$strip>;
|
|
7177
|
+
/**
|
|
7178
|
+
* The new coupon
|
|
7179
|
+
*/
|
|
7180
|
+
export declare const zCreateCouponResponse: z.ZodIntersection<z.ZodObject<{
|
|
7181
|
+
code: z.ZodString;
|
|
7182
|
+
plan: z.ZodOptional<z.ZodEnum<{
|
|
7183
|
+
pro: "pro";
|
|
7184
|
+
enterprise: "enterprise";
|
|
7185
|
+
solo: "solo";
|
|
7186
|
+
indie: "indie";
|
|
7187
|
+
}>>;
|
|
7188
|
+
planDays: z.ZodInt;
|
|
7189
|
+
trial: z.ZodBoolean;
|
|
7190
|
+
creditUsd: z.ZodCoercedBigInt<unknown>;
|
|
7191
|
+
expiry: z.ZodISODateTime;
|
|
7192
|
+
expired: z.ZodBoolean;
|
|
7193
|
+
redeemed: z.ZodBoolean;
|
|
7194
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
7195
|
+
org: z.ZodString;
|
|
7196
|
+
}, z.core.$strip>>;
|
|
7197
|
+
export declare const zDeleteCouponData: z.ZodObject<{
|
|
7198
|
+
body: z.ZodOptional<z.ZodNever>;
|
|
7199
|
+
path: z.ZodObject<{
|
|
7200
|
+
code: z.ZodString;
|
|
7201
|
+
}, z.core.$strip>;
|
|
7202
|
+
query: z.ZodOptional<z.ZodNever>;
|
|
7203
|
+
}, z.core.$strip>;
|
|
7204
|
+
/**
|
|
7205
|
+
* Coupon deleted
|
|
7206
|
+
*/
|
|
7207
|
+
export declare const zDeleteCouponResponse: z.ZodVoid;
|
|
7053
7208
|
export declare const zGetInvoicesData: z.ZodObject<{
|
|
7054
7209
|
body: z.ZodOptional<z.ZodNever>;
|
|
7055
7210
|
path: z.ZodObject<{
|
|
@@ -7738,7 +7893,7 @@ export declare const zM2mGetCustomerResponse: z.ZodObject<{
|
|
|
7738
7893
|
expYear: z.ZodReadonly<z.ZodInt>;
|
|
7739
7894
|
isDefault: z.ZodReadonly<z.ZodBoolean>;
|
|
7740
7895
|
}, z.core.$strip>>>;
|
|
7741
|
-
estimatedCreditBalanceUSD: z.ZodReadonly<z.
|
|
7896
|
+
estimatedCreditBalanceUSD: z.ZodReadonly<z.ZodNumber>;
|
|
7742
7897
|
upcomingInvoiceTotalCents: z.ZodOptional<z.ZodReadonly<z.ZodInt>>;
|
|
7743
7898
|
billingAddress: z.ZodOptional<z.ZodObject<{
|
|
7744
7899
|
name: z.ZodString;
|
|
@@ -110,6 +110,33 @@ export const zBillingInterval = z.enum([
|
|
|
110
110
|
'monthly',
|
|
111
111
|
'annual'
|
|
112
112
|
]);
|
|
113
|
+
export const zCouponPlan = z.enum([
|
|
114
|
+
'solo',
|
|
115
|
+
'indie',
|
|
116
|
+
'pro',
|
|
117
|
+
'enterprise'
|
|
118
|
+
]);
|
|
119
|
+
export const zCoupon = z.object({
|
|
120
|
+
code: z.string(),
|
|
121
|
+
plan: z.optional(zCouponPlan),
|
|
122
|
+
planDays: z.int(),
|
|
123
|
+
trial: z.boolean(),
|
|
124
|
+
creditUsd: z.coerce.bigint(),
|
|
125
|
+
expiry: z.iso.datetime(),
|
|
126
|
+
expired: z.boolean(),
|
|
127
|
+
redeemed: z.boolean()
|
|
128
|
+
});
|
|
129
|
+
export const zAdminCoupon = zCoupon.and(z.object({
|
|
130
|
+
org: z.string()
|
|
131
|
+
}));
|
|
132
|
+
export const zCreateCoupon = z.object({
|
|
133
|
+
org: z.string(),
|
|
134
|
+
plan: z.optional(zCouponPlan),
|
|
135
|
+
planDays: z.int(),
|
|
136
|
+
trial: z.boolean(),
|
|
137
|
+
creditUsd: z.coerce.bigint(),
|
|
138
|
+
expiresInDays: z.int()
|
|
139
|
+
});
|
|
113
140
|
export const zUpdatePlan = z.object({
|
|
114
141
|
plan: z.string(),
|
|
115
142
|
billingInterval: zBillingInterval
|
|
@@ -195,22 +222,22 @@ export const zCustomerResponse = z.object({
|
|
|
195
222
|
scheduledChangeAt: z.optional(z.int().readonly()),
|
|
196
223
|
seats: z.int().readonly(),
|
|
197
224
|
paymentMethods: z.array(zPaymentMethodSummary).readonly(),
|
|
198
|
-
estimatedCreditBalanceUSD: z.
|
|
225
|
+
estimatedCreditBalanceUSD: z.number().readonly(),
|
|
199
226
|
upcomingInvoiceTotalCents: z.optional(z.int().readonly()),
|
|
200
227
|
billingAddress: z.optional(zBillingAddress)
|
|
201
228
|
});
|
|
202
229
|
export const zUsagePoint = z.object({
|
|
203
230
|
date: z.iso.datetime(),
|
|
204
|
-
amount: z.
|
|
231
|
+
amount: z.number()
|
|
205
232
|
});
|
|
206
233
|
export const zMeterType = z.object({
|
|
207
234
|
displayName: z.string(),
|
|
208
|
-
total: z.
|
|
235
|
+
total: z.number(),
|
|
209
236
|
points: z.array(zUsagePoint)
|
|
210
237
|
});
|
|
211
238
|
export const zUsageInfoResponse = z.object({
|
|
212
239
|
meters: z.record(z.string(), zMeterType),
|
|
213
|
-
total: z.
|
|
240
|
+
total: z.number(),
|
|
214
241
|
from: z.iso.datetime(),
|
|
215
242
|
to: z.iso.datetime()
|
|
216
243
|
});
|
|
@@ -289,6 +316,10 @@ export const zPaymentMethodId = z.string();
|
|
|
289
316
|
* Kinde organisation id.
|
|
290
317
|
*/
|
|
291
318
|
export const zOrganisationId = z.string();
|
|
319
|
+
/**
|
|
320
|
+
* A coupon code.
|
|
321
|
+
*/
|
|
322
|
+
export const zCouponCode = z.string();
|
|
292
323
|
/**
|
|
293
324
|
* A valid currency.
|
|
294
325
|
*/
|
|
@@ -407,6 +438,50 @@ export const zUpdateDefaultPaymentMethodData = z.object({
|
|
|
407
438
|
* Default payment method updated
|
|
408
439
|
*/
|
|
409
440
|
export const zUpdateDefaultPaymentMethodResponse = z.void();
|
|
441
|
+
export const zGetCouponData = z.object({
|
|
442
|
+
body: z.optional(z.never()),
|
|
443
|
+
path: z.object({
|
|
444
|
+
org: z.string(),
|
|
445
|
+
code: z.string()
|
|
446
|
+
}),
|
|
447
|
+
query: z.optional(z.never())
|
|
448
|
+
});
|
|
449
|
+
/**
|
|
450
|
+
* The coupon
|
|
451
|
+
*/
|
|
452
|
+
export const zGetCouponResponse = zCoupon;
|
|
453
|
+
export const zRedeemCouponData = z.object({
|
|
454
|
+
body: z.optional(z.never()),
|
|
455
|
+
path: z.object({
|
|
456
|
+
org: z.string(),
|
|
457
|
+
code: z.string()
|
|
458
|
+
}),
|
|
459
|
+
query: z.optional(z.never())
|
|
460
|
+
});
|
|
461
|
+
/**
|
|
462
|
+
* The redeemed coupon
|
|
463
|
+
*/
|
|
464
|
+
export const zRedeemCouponResponse = zCoupon;
|
|
465
|
+
export const zCreateCouponData = z.object({
|
|
466
|
+
body: zCreateCoupon,
|
|
467
|
+
path: z.optional(z.never()),
|
|
468
|
+
query: z.optional(z.never())
|
|
469
|
+
});
|
|
470
|
+
/**
|
|
471
|
+
* The new coupon
|
|
472
|
+
*/
|
|
473
|
+
export const zCreateCouponResponse = zAdminCoupon;
|
|
474
|
+
export const zDeleteCouponData = z.object({
|
|
475
|
+
body: z.optional(z.never()),
|
|
476
|
+
path: z.object({
|
|
477
|
+
code: z.string()
|
|
478
|
+
}),
|
|
479
|
+
query: z.optional(z.never())
|
|
480
|
+
});
|
|
481
|
+
/**
|
|
482
|
+
* Coupon deleted
|
|
483
|
+
*/
|
|
484
|
+
export const zDeleteCouponResponse = z.void();
|
|
410
485
|
export const zGetInvoicesData = z.object({
|
|
411
486
|
body: z.optional(z.never()),
|
|
412
487
|
path: z.object({
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { useMutation } from "@tanstack/react-query";
|
|
2
2
|
import { GetSuccessResponse } from "../util";
|
|
3
|
-
import { GetCustomerData, GetUsageData, GetPlansData, UpdatePlanData, UpdatePlanResponses, CancelSubscriptionData, CancelSubscriptionResponses, CreateSubscriptionData, CreateSubscriptionResponses, UpdateBillingAddressData, UpdateBillingAddressResponses, CreateSetupIntentData, CreateSetupIntentResponses, DeletePaymentMethodData, DeletePaymentMethodResponses, UpdateDefaultPaymentMethodData, UpdateDefaultPaymentMethodResponses, GetInvoicesData, M2mGetCustomerData, M2mCreateCustomerData, M2mCreateCustomerResponses, M2mUpdatePlanData, M2mUpdatePlanResponses } from "../../sdk/billing/types.gen";
|
|
3
|
+
import { GetCustomerData, GetUsageData, GetPlansData, UpdatePlanData, UpdatePlanResponses, CancelSubscriptionData, CancelSubscriptionResponses, CreateSubscriptionData, CreateSubscriptionResponses, UpdateBillingAddressData, UpdateBillingAddressResponses, CreateSetupIntentData, CreateSetupIntentResponses, DeletePaymentMethodData, DeletePaymentMethodResponses, UpdateDefaultPaymentMethodData, UpdateDefaultPaymentMethodResponses, GetCouponData, RedeemCouponData, RedeemCouponResponses, CreateCouponData, CreateCouponResponses, DeleteCouponData, DeleteCouponResponses, GetInvoicesData, M2mGetCustomerData, M2mCreateCustomerData, M2mCreateCustomerResponses, M2mUpdatePlanData, M2mUpdatePlanResponses } from "../../sdk/billing/types.gen";
|
|
4
4
|
export declare const useGetCustomer: (options: Omit<GetCustomerData, "url"> & {
|
|
5
5
|
enabled?: boolean;
|
|
6
6
|
}) => {
|
|
@@ -678,6 +678,237 @@ export declare const useUpdateDefaultPaymentMethod: (config?: {
|
|
|
678
678
|
data: void | undefined;
|
|
679
679
|
headers: Record<string, string>;
|
|
680
680
|
}, unknown, Omit<UpdateDefaultPaymentMethodData, "url">, unknown>;
|
|
681
|
+
export declare const useGetCoupon: (options: Omit<GetCouponData, "url"> & {
|
|
682
|
+
enabled?: boolean;
|
|
683
|
+
}) => {
|
|
684
|
+
data: import("../../sdk/billing/types.gen").Coupon | undefined;
|
|
685
|
+
headers: Record<string, string> | undefined;
|
|
686
|
+
error: Error;
|
|
687
|
+
isError: true;
|
|
688
|
+
isPending: false;
|
|
689
|
+
isLoading: false;
|
|
690
|
+
isLoadingError: false;
|
|
691
|
+
isRefetchError: true;
|
|
692
|
+
isSuccess: false;
|
|
693
|
+
isPlaceholderData: false;
|
|
694
|
+
status: "error";
|
|
695
|
+
dataUpdatedAt: number;
|
|
696
|
+
errorUpdatedAt: number;
|
|
697
|
+
failureCount: number;
|
|
698
|
+
failureReason: Error | null;
|
|
699
|
+
errorUpdateCount: number;
|
|
700
|
+
isFetched: boolean;
|
|
701
|
+
isFetchedAfterMount: boolean;
|
|
702
|
+
isFetching: boolean;
|
|
703
|
+
isInitialLoading: boolean;
|
|
704
|
+
isPaused: boolean;
|
|
705
|
+
isRefetching: boolean;
|
|
706
|
+
isStale: boolean;
|
|
707
|
+
isEnabled: boolean;
|
|
708
|
+
refetch: (options?: import("@tanstack/react-query").RefetchOptions) => Promise<import("@tanstack/react-query").QueryObserverResult<{
|
|
709
|
+
data: import("../../sdk/billing/types.gen").Coupon | undefined;
|
|
710
|
+
headers: Record<string, string>;
|
|
711
|
+
} | undefined, Error>>;
|
|
712
|
+
fetchStatus: import("@tanstack/react-query").FetchStatus;
|
|
713
|
+
promise: Promise<{
|
|
714
|
+
data: import("../../sdk/billing/types.gen").Coupon | undefined;
|
|
715
|
+
headers: Record<string, string>;
|
|
716
|
+
} | undefined>;
|
|
717
|
+
} | {
|
|
718
|
+
data: import("../../sdk/billing/types.gen").Coupon | undefined;
|
|
719
|
+
headers: Record<string, string> | undefined;
|
|
720
|
+
error: null;
|
|
721
|
+
isError: false;
|
|
722
|
+
isPending: false;
|
|
723
|
+
isLoading: false;
|
|
724
|
+
isLoadingError: false;
|
|
725
|
+
isRefetchError: false;
|
|
726
|
+
isSuccess: true;
|
|
727
|
+
isPlaceholderData: false;
|
|
728
|
+
status: "success";
|
|
729
|
+
dataUpdatedAt: number;
|
|
730
|
+
errorUpdatedAt: number;
|
|
731
|
+
failureCount: number;
|
|
732
|
+
failureReason: Error | null;
|
|
733
|
+
errorUpdateCount: number;
|
|
734
|
+
isFetched: boolean;
|
|
735
|
+
isFetchedAfterMount: boolean;
|
|
736
|
+
isFetching: boolean;
|
|
737
|
+
isInitialLoading: boolean;
|
|
738
|
+
isPaused: boolean;
|
|
739
|
+
isRefetching: boolean;
|
|
740
|
+
isStale: boolean;
|
|
741
|
+
isEnabled: boolean;
|
|
742
|
+
refetch: (options?: import("@tanstack/react-query").RefetchOptions) => Promise<import("@tanstack/react-query").QueryObserverResult<{
|
|
743
|
+
data: import("../../sdk/billing/types.gen").Coupon | undefined;
|
|
744
|
+
headers: Record<string, string>;
|
|
745
|
+
} | undefined, Error>>;
|
|
746
|
+
fetchStatus: import("@tanstack/react-query").FetchStatus;
|
|
747
|
+
promise: Promise<{
|
|
748
|
+
data: import("../../sdk/billing/types.gen").Coupon | undefined;
|
|
749
|
+
headers: Record<string, string>;
|
|
750
|
+
} | undefined>;
|
|
751
|
+
} | {
|
|
752
|
+
data: import("../../sdk/billing/types.gen").Coupon | undefined;
|
|
753
|
+
headers: Record<string, string> | undefined;
|
|
754
|
+
error: Error;
|
|
755
|
+
isError: true;
|
|
756
|
+
isPending: false;
|
|
757
|
+
isLoading: false;
|
|
758
|
+
isLoadingError: true;
|
|
759
|
+
isRefetchError: false;
|
|
760
|
+
isSuccess: false;
|
|
761
|
+
isPlaceholderData: false;
|
|
762
|
+
status: "error";
|
|
763
|
+
dataUpdatedAt: number;
|
|
764
|
+
errorUpdatedAt: number;
|
|
765
|
+
failureCount: number;
|
|
766
|
+
failureReason: Error | null;
|
|
767
|
+
errorUpdateCount: number;
|
|
768
|
+
isFetched: boolean;
|
|
769
|
+
isFetchedAfterMount: boolean;
|
|
770
|
+
isFetching: boolean;
|
|
771
|
+
isInitialLoading: boolean;
|
|
772
|
+
isPaused: boolean;
|
|
773
|
+
isRefetching: boolean;
|
|
774
|
+
isStale: boolean;
|
|
775
|
+
isEnabled: boolean;
|
|
776
|
+
refetch: (options?: import("@tanstack/react-query").RefetchOptions) => Promise<import("@tanstack/react-query").QueryObserverResult<{
|
|
777
|
+
data: import("../../sdk/billing/types.gen").Coupon | undefined;
|
|
778
|
+
headers: Record<string, string>;
|
|
779
|
+
} | undefined, Error>>;
|
|
780
|
+
fetchStatus: import("@tanstack/react-query").FetchStatus;
|
|
781
|
+
promise: Promise<{
|
|
782
|
+
data: import("../../sdk/billing/types.gen").Coupon | undefined;
|
|
783
|
+
headers: Record<string, string>;
|
|
784
|
+
} | undefined>;
|
|
785
|
+
} | {
|
|
786
|
+
data: import("../../sdk/billing/types.gen").Coupon | undefined;
|
|
787
|
+
headers: Record<string, string> | undefined;
|
|
788
|
+
error: null;
|
|
789
|
+
isError: false;
|
|
790
|
+
isPending: true;
|
|
791
|
+
isLoading: true;
|
|
792
|
+
isLoadingError: false;
|
|
793
|
+
isRefetchError: false;
|
|
794
|
+
isSuccess: false;
|
|
795
|
+
isPlaceholderData: false;
|
|
796
|
+
status: "pending";
|
|
797
|
+
dataUpdatedAt: number;
|
|
798
|
+
errorUpdatedAt: number;
|
|
799
|
+
failureCount: number;
|
|
800
|
+
failureReason: Error | null;
|
|
801
|
+
errorUpdateCount: number;
|
|
802
|
+
isFetched: boolean;
|
|
803
|
+
isFetchedAfterMount: boolean;
|
|
804
|
+
isFetching: boolean;
|
|
805
|
+
isInitialLoading: boolean;
|
|
806
|
+
isPaused: boolean;
|
|
807
|
+
isRefetching: boolean;
|
|
808
|
+
isStale: boolean;
|
|
809
|
+
isEnabled: boolean;
|
|
810
|
+
refetch: (options?: import("@tanstack/react-query").RefetchOptions) => Promise<import("@tanstack/react-query").QueryObserverResult<{
|
|
811
|
+
data: import("../../sdk/billing/types.gen").Coupon | undefined;
|
|
812
|
+
headers: Record<string, string>;
|
|
813
|
+
} | undefined, Error>>;
|
|
814
|
+
fetchStatus: import("@tanstack/react-query").FetchStatus;
|
|
815
|
+
promise: Promise<{
|
|
816
|
+
data: import("../../sdk/billing/types.gen").Coupon | undefined;
|
|
817
|
+
headers: Record<string, string>;
|
|
818
|
+
} | undefined>;
|
|
819
|
+
} | {
|
|
820
|
+
data: import("../../sdk/billing/types.gen").Coupon | undefined;
|
|
821
|
+
headers: Record<string, string> | undefined;
|
|
822
|
+
error: null;
|
|
823
|
+
isError: false;
|
|
824
|
+
isPending: true;
|
|
825
|
+
isLoadingError: false;
|
|
826
|
+
isRefetchError: false;
|
|
827
|
+
isSuccess: false;
|
|
828
|
+
isPlaceholderData: false;
|
|
829
|
+
status: "pending";
|
|
830
|
+
dataUpdatedAt: number;
|
|
831
|
+
errorUpdatedAt: number;
|
|
832
|
+
failureCount: number;
|
|
833
|
+
failureReason: Error | null;
|
|
834
|
+
errorUpdateCount: number;
|
|
835
|
+
isFetched: boolean;
|
|
836
|
+
isFetchedAfterMount: boolean;
|
|
837
|
+
isFetching: boolean;
|
|
838
|
+
isLoading: boolean;
|
|
839
|
+
isInitialLoading: boolean;
|
|
840
|
+
isPaused: boolean;
|
|
841
|
+
isRefetching: boolean;
|
|
842
|
+
isStale: boolean;
|
|
843
|
+
isEnabled: boolean;
|
|
844
|
+
refetch: (options?: import("@tanstack/react-query").RefetchOptions) => Promise<import("@tanstack/react-query").QueryObserverResult<{
|
|
845
|
+
data: import("../../sdk/billing/types.gen").Coupon | undefined;
|
|
846
|
+
headers: Record<string, string>;
|
|
847
|
+
} | undefined, Error>>;
|
|
848
|
+
fetchStatus: import("@tanstack/react-query").FetchStatus;
|
|
849
|
+
promise: Promise<{
|
|
850
|
+
data: import("../../sdk/billing/types.gen").Coupon | undefined;
|
|
851
|
+
headers: Record<string, string>;
|
|
852
|
+
} | undefined>;
|
|
853
|
+
} | {
|
|
854
|
+
data: import("../../sdk/billing/types.gen").Coupon | undefined;
|
|
855
|
+
headers: Record<string, string> | undefined;
|
|
856
|
+
isError: false;
|
|
857
|
+
error: null;
|
|
858
|
+
isPending: false;
|
|
859
|
+
isLoading: false;
|
|
860
|
+
isLoadingError: false;
|
|
861
|
+
isRefetchError: false;
|
|
862
|
+
isSuccess: true;
|
|
863
|
+
isPlaceholderData: true;
|
|
864
|
+
status: "success";
|
|
865
|
+
dataUpdatedAt: number;
|
|
866
|
+
errorUpdatedAt: number;
|
|
867
|
+
failureCount: number;
|
|
868
|
+
failureReason: Error | null;
|
|
869
|
+
errorUpdateCount: number;
|
|
870
|
+
isFetched: boolean;
|
|
871
|
+
isFetchedAfterMount: boolean;
|
|
872
|
+
isFetching: boolean;
|
|
873
|
+
isInitialLoading: boolean;
|
|
874
|
+
isPaused: boolean;
|
|
875
|
+
isRefetching: boolean;
|
|
876
|
+
isStale: boolean;
|
|
877
|
+
isEnabled: boolean;
|
|
878
|
+
refetch: (options?: import("@tanstack/react-query").RefetchOptions) => Promise<import("@tanstack/react-query").QueryObserverResult<{
|
|
879
|
+
data: import("../../sdk/billing/types.gen").Coupon | undefined;
|
|
880
|
+
headers: Record<string, string>;
|
|
881
|
+
} | undefined, Error>>;
|
|
882
|
+
fetchStatus: import("@tanstack/react-query").FetchStatus;
|
|
883
|
+
promise: Promise<{
|
|
884
|
+
data: import("../../sdk/billing/types.gen").Coupon | undefined;
|
|
885
|
+
headers: Record<string, string>;
|
|
886
|
+
} | undefined>;
|
|
887
|
+
};
|
|
888
|
+
export declare const useRedeemCoupon: (config?: {
|
|
889
|
+
onSuccess?: (data: GetSuccessResponse<RedeemCouponResponses>, headers: Record<string, string>) => void;
|
|
890
|
+
onError?: Parameters<typeof useMutation>["0"]["onError"];
|
|
891
|
+
retry?: boolean;
|
|
892
|
+
}) => import("@tanstack/react-query").UseMutationResult<{
|
|
893
|
+
data: import("../../sdk/billing/types.gen").Coupon | undefined;
|
|
894
|
+
headers: Record<string, string>;
|
|
895
|
+
}, unknown, Omit<RedeemCouponData, "url">, unknown>;
|
|
896
|
+
export declare const useCreateCoupon: (config?: {
|
|
897
|
+
onSuccess?: (data: GetSuccessResponse<CreateCouponResponses>, headers: Record<string, string>) => void;
|
|
898
|
+
onError?: Parameters<typeof useMutation>["0"]["onError"];
|
|
899
|
+
retry?: boolean;
|
|
900
|
+
}) => import("@tanstack/react-query").UseMutationResult<{
|
|
901
|
+
data: import("../../sdk/billing/types.gen").AdminCoupon | undefined;
|
|
902
|
+
headers: Record<string, string>;
|
|
903
|
+
}, unknown, Omit<CreateCouponData, "url">, unknown>;
|
|
904
|
+
export declare const useDeleteCoupon: (config?: {
|
|
905
|
+
onSuccess?: (data: GetSuccessResponse<DeleteCouponResponses>, headers: Record<string, string>) => void;
|
|
906
|
+
onError?: Parameters<typeof useMutation>["0"]["onError"];
|
|
907
|
+
retry?: boolean;
|
|
908
|
+
}) => import("@tanstack/react-query").UseMutationResult<{
|
|
909
|
+
data: void | undefined;
|
|
910
|
+
headers: Record<string, string>;
|
|
911
|
+
}, unknown, Omit<DeleteCouponData, "url">, unknown>;
|
|
681
912
|
export declare const useGetInvoices: (options: Omit<GetInvoicesData, "url"> & {
|
|
682
913
|
enabled?: boolean;
|
|
683
914
|
}) => {
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
import { useMutation, useQuery, useQueryClient } from "@tanstack/react-query";
|
|
3
3
|
import { isPromise, headersToObject } from "../util";
|
|
4
4
|
import { useToken } from "../../provider/token-provider";
|
|
5
|
-
import { getCustomer, getUsage, getPlans, updatePlan, cancelSubscription, createSubscription, updateBillingAddress, createSetupIntent, deletePaymentMethod, updateDefaultPaymentMethod, getInvoices, m2mGetCustomer, m2mCreateCustomer, m2mUpdatePlan } from "../../sdk/billing/sdk.gen";
|
|
5
|
+
import { getCustomer, getUsage, getPlans, updatePlan, cancelSubscription, createSubscription, updateBillingAddress, createSetupIntent, deletePaymentMethod, updateDefaultPaymentMethod, getCoupon, redeemCoupon, createCoupon, deleteCoupon, getInvoices, m2mGetCustomer, m2mCreateCustomer, m2mUpdatePlan } from "../../sdk/billing/sdk.gen";
|
|
6
6
|
export const useGetCustomer = (options) => {
|
|
7
7
|
const token = useToken();
|
|
8
8
|
let { enabled, ...rest } = options || { enabled: true };
|
|
@@ -202,6 +202,85 @@ export const useUpdateDefaultPaymentMethod = (config) => {
|
|
|
202
202
|
retry: config?.retry
|
|
203
203
|
});
|
|
204
204
|
};
|
|
205
|
+
export const useGetCoupon = (options) => {
|
|
206
|
+
const token = useToken();
|
|
207
|
+
let { enabled, ...rest } = options || { enabled: true };
|
|
208
|
+
const opts = { throwOnError: true, url: "/api/v1/coupon/{org}/{code}" };
|
|
209
|
+
const funcer = async () => {
|
|
210
|
+
const auth = isPromise(token) ? (await token) || "" : token || "";
|
|
211
|
+
if (isPromise(token) && !token)
|
|
212
|
+
return;
|
|
213
|
+
const res = await getCoupon({ ...opts, ...rest, auth });
|
|
214
|
+
return { data: res.data, headers: headersToObject(res.response.headers) };
|
|
215
|
+
};
|
|
216
|
+
if (!token)
|
|
217
|
+
enabled = false;
|
|
218
|
+
const query = useQuery({
|
|
219
|
+
queryKey: ["api", "v1", "coupon", options?.path?.org, options?.path?.code, options.query ?? {}],
|
|
220
|
+
queryFn: funcer,
|
|
221
|
+
enabled,
|
|
222
|
+
retry: false,
|
|
223
|
+
staleTime: 600000
|
|
224
|
+
});
|
|
225
|
+
return { ...query, data: query.data?.data, headers: query.data?.headers };
|
|
226
|
+
};
|
|
227
|
+
export const useRedeemCoupon = (config) => {
|
|
228
|
+
const token = useToken();
|
|
229
|
+
const queryClient = useQueryClient();
|
|
230
|
+
const opts = { throwOnError: true, url: "/api/v1/coupon/{org}/{code}/redeem" };
|
|
231
|
+
const funcer = async (options) => {
|
|
232
|
+
const auth = isPromise(token) ? (await token) || "" : token || "";
|
|
233
|
+
const res = await redeemCoupon({ ...opts, ...options, auth });
|
|
234
|
+
return { data: res.data, headers: headersToObject(res.response.headers) };
|
|
235
|
+
};
|
|
236
|
+
return useMutation({
|
|
237
|
+
mutationFn: funcer,
|
|
238
|
+
onSuccess: (res, options, c, ctx) => {
|
|
239
|
+
queryClient.invalidateQueries({ queryKey: ["api", "v1", "coupon", options?.path?.org, options?.path?.code, "redeem"] });
|
|
240
|
+
config?.onSuccess && config.onSuccess(res.data, res.headers);
|
|
241
|
+
},
|
|
242
|
+
onError: config?.onError,
|
|
243
|
+
retry: config?.retry
|
|
244
|
+
});
|
|
245
|
+
};
|
|
246
|
+
export const useCreateCoupon = (config) => {
|
|
247
|
+
const token = useToken();
|
|
248
|
+
const queryClient = useQueryClient();
|
|
249
|
+
const opts = { throwOnError: true, url: "/api/v1/admin/coupon" };
|
|
250
|
+
const funcer = async (options) => {
|
|
251
|
+
const auth = isPromise(token) ? (await token) || "" : token || "";
|
|
252
|
+
const res = await createCoupon({ ...opts, ...options, auth });
|
|
253
|
+
return { data: res.data, headers: headersToObject(res.response.headers) };
|
|
254
|
+
};
|
|
255
|
+
return useMutation({
|
|
256
|
+
mutationFn: funcer,
|
|
257
|
+
onSuccess: (res, options, c, ctx) => {
|
|
258
|
+
queryClient.invalidateQueries({ queryKey: ["api", "v1", "admin", "coupon"] });
|
|
259
|
+
config?.onSuccess && config.onSuccess(res.data, res.headers);
|
|
260
|
+
},
|
|
261
|
+
onError: config?.onError,
|
|
262
|
+
retry: config?.retry
|
|
263
|
+
});
|
|
264
|
+
};
|
|
265
|
+
export const useDeleteCoupon = (config) => {
|
|
266
|
+
const token = useToken();
|
|
267
|
+
const queryClient = useQueryClient();
|
|
268
|
+
const opts = { throwOnError: true, url: "/api/v1/admin/coupon/{code}" };
|
|
269
|
+
const funcer = async (options) => {
|
|
270
|
+
const auth = isPromise(token) ? (await token) || "" : token || "";
|
|
271
|
+
const res = await deleteCoupon({ ...opts, ...options, auth });
|
|
272
|
+
return { data: res.data, headers: headersToObject(res.response.headers) };
|
|
273
|
+
};
|
|
274
|
+
return useMutation({
|
|
275
|
+
mutationFn: funcer,
|
|
276
|
+
onSuccess: (res, options, c, ctx) => {
|
|
277
|
+
queryClient.invalidateQueries({ queryKey: ["api", "v1", "admin", "coupon", options?.path?.code] });
|
|
278
|
+
config?.onSuccess && config.onSuccess(res.data, res.headers);
|
|
279
|
+
},
|
|
280
|
+
onError: config?.onError,
|
|
281
|
+
retry: config?.retry
|
|
282
|
+
});
|
|
283
|
+
};
|
|
205
284
|
export const useGetInvoices = (options) => {
|
|
206
285
|
const token = useToken();
|
|
207
286
|
let { enabled, ...rest } = options || { enabled: true };
|