-
Notifications
You must be signed in to change notification settings - Fork 516
Expand file tree
/
Copy pathproducts.ts
More file actions
40 lines (34 loc) · 1.47 KB
/
products.ts
File metadata and controls
40 lines (34 loc) · 1.47 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
import type * as yup from "yup";
import { inlineProductSchema, yupArray, yupBoolean, yupNumber, yupObject, yupString } from "../../schema-fields";
const customerProductSwitchOptionSchema = yupObject({
product_id: yupString().defined(),
product: inlineProductSchema.defined(),
}).defined();
export const customerProductReadSchema = yupObject({
id: yupString().nullable().defined(),
quantity: yupNumber().defined(),
product: inlineProductSchema.defined(),
type: yupString().oneOf(["one_time", "subscription"]).defined(),
subscription: yupObject({
subscription_id: yupString().nullable().defined(),
current_period_end: yupString().nullable().defined(),
cancel_at_period_end: yupBoolean().defined(),
is_cancelable: yupBoolean().defined(),
}).nullable().defined(),
switch_options: yupArray(customerProductSwitchOptionSchema).optional(),
}).defined();
export type CustomerProductRead = yup.InferType<typeof customerProductReadSchema>;
export const customerProductsListResponseSchema = yupObject({
items: yupArray(customerProductReadSchema).defined(),
is_paginated: yupBoolean().oneOf([true]).defined(),
pagination: yupObject({
next_cursor: yupString().nullable().defined(),
}).defined(),
}).defined();
export type CustomerProductsListResponse = yup.InferType<typeof customerProductsListResponseSchema>;
export type ListCustomerProductsOptions = {
customer_type: "user" | "team" | "custom",
customer_id: string,
cursor?: string,
limit?: number,
};