-
Notifications
You must be signed in to change notification settings - Fork 0
/
dopp_public_api.d.ts
122 lines (109 loc) · 2.49 KB
/
dopp_public_api.d.ts
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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
/**
* A public API that our customers can use to implement their own custom
* flows built on top of our app.
*/
export type DOPPPublicApi = {
/**
* An experimental first version of the public API.
*/
v0?: DOPPPublicApiV0;
};
/**
* An experimental first version of the public API.
*/
export type DOPPPublicApiV0 = {
/**
* Allows interop with our "Product Page Discount" app block's calculation
* features.
*
* **Only available on product pages. Requires "Product Page Discount" app
* block.**
*/
productPage?: {
/**
* Calculates the discounted prices for a product.
*
* Also expands discount descriptions.
*/
calculateDiscountedPrices: (
args?: DOPPPublicApiCalculateDiscountedPricesArgs,
) => Promise<DOPPPublicApiCalculateDiscountedPricesResult>;
};
};
/**
* Arguments for the calculateDiscountedPrices function.
*/
export type DOPPPublicApiCalculateDiscountedPricesArgs = {
/**
* The product variant to calculate discounted prices for.
*
* Defaults to the default or selected variant on the page.
*/
variantId?: number;
/**
* The quantity of the product in the cart.
* @default 1
*/
quantity?: number;
};
/**
* The result of the calculateDiscountedPrices function.
*/
export type DOPPPublicApiCalculateDiscountedPricesResult = {
/**
* The sale price of the product.
*/
salePrice: DOPPPublicApiPrice;
/**
* The regular price of the product.
*/
regularPrice: DOPPPublicApiPrice;
/**
* The discount description, if any.
*/
description: DOPPPublicApiDiscountDescription;
/**
* The discount badge, if any.
*/
badge: DOPPPublicApiDiscountDescription;
/**
* The discount message, if any.
*/
discountMessage?: string;
};
/**
* A price in the public API.
*/
export type DOPPPublicApiPrice = {
/**
* The price amount, NOT in cents.
* @example `10.99`
*/
amount: number;
/**
* The price formatted as a string, using your store's currency settings.
* @example $10.99, $10.99 CAD
*/
formatted: string;
};
/**
* A discount description in the public API.
*/
export type DOPPPublicApiDiscountDescription = {
/**
* The HTML content of the description.
*
* May be an empty string if there is no description.
*/
html: string;
/**
* The CSS content of the description.
*
* May be an empty string if there is no custom CSS.
*/
css: string;
};
/**
* An error thrown by the public API.
*/
declare class DOPPPublicApiError extends Error;