@@ -21,7 +21,8 @@ export type CartDiscountType = 'Percentage' | 'FixedAmount' | 'Code';
21
21
export type LineItemDiscountType = 'Percentage' | 'FixedAmount' ;
22
22
23
23
export interface CartApiContent {
24
- /** Provides a subscription to POS cart changes.
24
+ /**
25
+ * Provides a subscription to POS cart changes.
25
26
* Provides an initial value and a callback to subscribe to value changes. Currently supports only one subscription.
26
27
* You can utilize `makeStatefulSubscribable` on a `RemoteSubscribable` to implement multiple subscriptions.
27
28
* Using `makeStatefulSubscribable` or the corresponding hooks counts as a subscription.
@@ -31,99 +32,151 @@ export interface CartApiContent {
31
32
/** Bulk update the cart
32
33
* @param cartState the cart state to set
33
34
* @returns the updated cart
35
+ *
36
+ * @throws CartNotEditableError if the cart is not currently editable.
34
37
*/
35
38
bulkCartUpdate ( cartState : CartUpdateInput ) : Promise < Cart > ;
36
39
37
40
/** Apply a cart level discount
38
41
* @param type the type of discount applied (example: 'Percentage')
39
42
* @param title the title attributed with the discount
40
43
* @param amount the percentage or fixed monetary amount deducted with the discount. Pass in `undefined` if using discount codes.
44
+ *
45
+ * @throws CartNotEditableError if the cart is not currently editable.
41
46
*/
42
47
applyCartDiscount (
43
48
type : CartDiscountType ,
44
49
title : string ,
45
50
amount ?: string ,
46
51
) : Promise < void > ;
47
52
48
- /** Add a code discount to the cart
53
+ /**
54
+ * Add a code discount to the cart
49
55
* @param code the code for the discount to add to the cart
56
+ *
57
+ * @throws CartNotEditableError if the cart is not currently editable.
50
58
*/
51
59
addCartCodeDiscount ( code : string ) : Promise < void > ;
52
60
53
- /** Remove the cart discount */
61
+ /**
62
+ * Remove the cart discount
63
+ *
64
+ * @throws CartNotEditableError if the cart is not currently editable.
65
+ */
54
66
removeCartDiscount ( ) : Promise < void > ;
55
67
56
- /** Remove all cart and line item discounts
68
+ /**
69
+ * Remove all cart and line item discounts
57
70
* @param disableAutomaticDiscounts Whether or not automatic discounts should be enabled after removing the discounts.
71
+ *
72
+ * @throws CartNotEditableError if the cart is not currently editable.
58
73
*/
59
74
removeAllDiscounts ( disableAutomaticDiscounts : boolean ) : Promise < void > ;
60
75
61
- /** Clear the cart */
76
+ /**
77
+ * Clear the cart
78
+ *
79
+ * @throws CartNotEditableError if the cart is not currently editable.
80
+ */
62
81
clearCart ( ) : Promise < void > ;
63
82
64
- /** Set the customer in the cart
83
+ /**
84
+ * Set the customer in the cart
65
85
* @param customer the customer object to add to the cart
86
+ *
87
+ * @throws CartNotEditableError if the cart is not currently editable.
66
88
*/
67
89
setCustomer ( customer : Customer ) : Promise < void > ;
68
90
69
- /** Remove the current customer from the cart */
91
+ /**
92
+ * Remove the current customer from the cart
93
+ *
94
+ * @throws CartNotEditableError if the cart is not currently editable.
95
+ */
70
96
removeCustomer ( ) : Promise < void > ;
71
97
72
- /** Add a custom sale to the cart
98
+ /**
99
+ * Add a custom sale to the cart
73
100
* @param customSale the custom sale object to add to the cart
74
101
* @returns {string } the uuid of the line item added
102
+ *
103
+ * @throws CartNotEditableError if the cart is not currently editable.
75
104
*/
76
105
addCustomSale ( customSale : CustomSale ) : Promise < string > ;
77
106
78
- /** Add a line item by variant ID to the cart
107
+ /**
108
+ * Add a line item by variant ID to the cart
79
109
* @param variantId the product variant's numeric ID to add to the cart
80
110
* @param quantity the number of this variant to add to the cart
81
111
* @returns {string } the uuid of the line item added
112
+ *
113
+ * @throws CartNotEditableError if the cart is not currently editable.
82
114
*/
83
115
addLineItem ( variantId : number , quantity : number ) : Promise < string > ;
84
116
85
- /** Remove the line item at this uuid from the cart
117
+ /**
118
+ * Remove the line item at this uuid from the cart
86
119
* @param uuid the uuid of the line item that should be removed
120
+ *
121
+ * @throws CartNotEditableError if the cart is not currently editable.
87
122
*/
88
123
removeLineItem ( uuid : string ) : Promise < void > ;
89
124
90
- /** Adds custom properties to the cart
125
+ /**
126
+ * Adds custom properties to the cart
91
127
* @param properties the custom key to value object to attribute to the cart
128
+ *
129
+ * @throws CartNotEditableError if the cart is not currently editable.
92
130
*/
93
131
addCartProperties ( properties : Record < string , string > ) : Promise < void > ;
94
132
95
- /** Removes the specified cart properties
133
+ /**
134
+ * Removes the specified cart properties
96
135
* @param keys the collection of keys to be removed from the cart properties
136
+ *
137
+ * @throws CartNotEditableError if the cart is not currently editable.
97
138
*/
98
139
removeCartProperties ( keys : string [ ] ) : Promise < void > ;
99
140
100
- /** Adds custom properties to the specified line item
141
+ /**
142
+ * Adds custom properties to the specified line item
101
143
* @param uuid the uuid of the line item to which the properties should be stringd
102
144
* @param properties the custom key to value object to attribute to the line item
145
+ *
146
+ * @throws CartNotEditableError if the cart is not currently editable.
103
147
*/
104
148
addLineItemProperties (
105
149
uuid : string ,
106
150
properties : Record < string , string > ,
107
151
) : Promise < void > ;
108
152
109
- /** Adds custom properties to multiple line items at the same time.
153
+ /**
154
+ * Adds custom properties to multiple line items at the same time.
110
155
* @param lineItemProperties the collection of custom line item properties to apply to their respective line items.
156
+ *
157
+ * @throws CartNotEditableError if the cart is not currently editable.
111
158
*/
112
159
bulkAddLineItemProperties (
113
160
lineItemProperties : SetLineItemPropertiesInput [ ] ,
114
161
) : Promise < void > ;
115
162
116
- /** Removes the specified line item properties
163
+ /**
164
+ * Removes the specified line item properties
117
165
* @param uuid the uuid of the line item to which the properties should be removed
118
166
* @param keys the collection of keys to be removed from the line item properties
167
+ *
168
+ * @throws CartNotEditableError if the cart is not currently editable.
119
169
*/
120
170
removeLineItemProperties ( uuid : string , keys : string [ ] ) : Promise < void > ;
121
171
122
- /** Add a discount on a line item to the cart
172
+ /**
173
+ * Add a discount on a line item to the cart
123
174
* @param uuid the uuid of the line item that should receive a discount
124
175
* @param type the type of discount applied (example: 'Percentage')
125
176
* @param title the title attributed with the discount
126
177
* @param amount the percentage or fixed monetary amount deducted with the discout
178
+ *
179
+ * @throws CartNotEditableError if the cart is not currently editable.
127
180
*/
128
181
setLineItemDiscount (
129
182
uuid : string ,
@@ -132,45 +185,65 @@ export interface CartApiContent {
132
185
amount : string ,
133
186
) : Promise < void > ;
134
187
135
- /** Set line item discounts to multiple line items at the same time.
188
+ /**
189
+ * Set line item discounts to multiple line items at the same time.
136
190
* @param lineItemDiscounts a map of discounts to add. They key is the uuid of the line item you want to add the discount to. The value is the discount input.
191
+ *
192
+ * @throws CartNotEditableError if the cart is not currently editable.
137
193
*/
138
194
bulkSetLineItemDiscounts (
139
195
lineItemDiscounts : SetLineItemDiscountInput [ ] ,
140
196
) : Promise < void > ;
141
197
142
- /** Sets an attributed staff to all line items in the cart.
198
+ /**
199
+ * Sets an attributed staff to all line items in the cart.
143
200
* @param staffId the ID of the staff. Providing undefined will clear the attributed staff from all line items.
201
+ *
202
+ * @throws CartNotEditableError if the cart is not currently editable.
144
203
*/
145
204
setAttributedStaff ( staffId : number | undefined ) : Promise < void > ;
146
205
147
- /** Sets an attributed staff to a specific line items in the cart.
206
+ /**
207
+ * Sets an attributed staff to a specific line items in the cart.
148
208
* @param staffId the ID of the staff. Providing undefined will clear the attributed staff on the line item.
149
209
* @param lineItemUuid the UUID of the line item.
210
+ *
211
+ * @throws CartNotEditableError if the cart is not currently editable.
150
212
*/
151
213
setAttributedStaffToLineItem (
152
214
staffId : number | undefined ,
153
215
lineItemUuid : string ,
154
216
) : Promise < void > ;
155
217
156
- /** Remove all discounts from a line item
218
+ /**
219
+ * Remove all discounts from a line item
157
220
* @param uuid the uuid of the line item whose discounts should be removed
221
+ *
222
+ * @throws CartNotEditableError if the cart is not currently editable.
158
223
*/
159
224
removeLineItemDiscount ( uuid : string ) : Promise < void > ;
160
225
161
- /** Add an address to the customer (Customer must be present)
226
+ /**
227
+ * Add an address to the customer (Customer must be present)
162
228
* @param address the address object to add to the customer in cart
229
+ *
230
+ * @throws CartNotEditableError if the cart is not currently editable.
163
231
*/
164
232
addAddress ( address : Address ) : Promise < void > ;
165
233
166
234
/**
167
235
* Delete an address from the customer (Customer must be present)
168
236
* @param addressId the address ID to delete
237
+ *
238
+ * @throws CartNotEditableError if the cart is not currently editable.
169
239
*/
170
240
deleteAddress ( addressId : number ) : Promise < void > ;
171
241
172
- /** Update the default address for the customer (Customer must be present)
242
+ /**
243
+ * Update the default address for the customer (Customer must be present)
173
244
* @param addressId the address ID to set as the default address
245
+ *
246
+ * @throws CartNotEditableError if the cart is not currently editable.
174
247
*/
175
248
updateDefaultAddress ( addressId : number ) : Promise < void > ;
176
249
}
0 commit comments