@betterstore/sdk 0.3.49 → 0.3.50

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/CHANGELOG.md CHANGED
@@ -1,5 +1,11 @@
1
1
  # @betterstore/sdk
2
2
 
3
+ ## 0.3.50
4
+
5
+ ### Patch Changes
6
+
7
+ - discounts handeling finished
8
+
3
9
  ## 0.3.49
4
10
 
5
11
  ### Patch Changes
package/dist/index.d.mts CHANGED
@@ -141,6 +141,7 @@ interface CheckoutCreateParams {
141
141
  customerId?: string;
142
142
  lineItems: LineItemCreate[];
143
143
  currency?: Currency;
144
+ discountCode?: string;
144
145
  }
145
146
  interface CheckoutUpdateParams {
146
147
  customerId?: string;
@@ -153,24 +154,61 @@ interface CheckoutUpdateParams {
153
154
  };
154
155
  }
155
156
 
156
- interface CheckoutSession {
157
+ type ShipmentData = {
158
+ provider: string;
159
+ name?: string;
160
+ service?: string;
161
+ pickupPointId?: string;
162
+ trackingId?: string;
163
+ trackingUrl?: string;
164
+ };
165
+ type Discount = {
157
166
  id: string;
158
167
  createdAt: Date;
159
168
  updatedAt: Date;
160
- clientSecret: string;
161
- lineItems: LineItem[];
162
- total?: number;
163
- subtotal?: number;
164
- tax?: number;
165
- shipping?: number;
166
- currency: string;
167
- exchangeRate: number;
168
- status: "IN_PROGRESS" | "PAYMENT_PENDING" | "ABANDONED" | "CANCELED" | "FAILED";
169
+ type: "AMOUNT_OFF_PRODUCTS" | "BUY_X_GET_Y" | "AMOUNT_OFF_ORDER" | "FREE_SHIPPING";
170
+ method: "CODE" | "AUTOMATIC";
171
+ code?: string | null;
172
+ title?: string | null;
173
+ value: number;
174
+ valueType: "PERCENTAGE" | "FIXED_AMOUNT" | "FREE";
175
+ discountScope: "PRODUCTS" | "COLLECTIONS";
176
+ allowedProductIDs: string[];
177
+ allowedCollectionIDs: string[];
178
+ allowedCombinations: ("ORDER" | "PRODUCT" | "SHIPPING")[];
179
+ minimumRequirementsType: "NONE" | "MINIMUM_ORDER_AMOUNT" | "MINIMUM_PRODUCT_QUANTITY";
180
+ minimumRequirementsValue?: number | null;
181
+ requiredProductIDs: string[];
182
+ requiredCollectionIDs: string[];
183
+ minimumRequirementsScope: "PRODUCTS" | "COLLECTIONS";
184
+ maxUses?: number | null;
185
+ maxUsesPerCustomer?: number | null;
186
+ maxAllowedProductQuantity?: number | null;
187
+ uses: number;
188
+ startsAt: Date;
189
+ expiresAt?: Date | null;
190
+ status: "ACTIVE" | "EXPIRED" | "SCHEDULED";
191
+ organizationId: string;
192
+ };
193
+ interface CheckoutSession {
194
+ id: string;
195
+ testmode: boolean;
169
196
  customer?: {
170
197
  id: string;
171
198
  address?: Address;
172
199
  email?: string;
173
200
  };
201
+ lineItems: LineItem[];
202
+ tax: number | null;
203
+ shipping: number | null;
204
+ discountAmount: number | null;
205
+ appliedDiscounts: {
206
+ discount: Discount;
207
+ }[];
208
+ currency: string;
209
+ exchangeRate: number | null;
210
+ shipmentData: ShipmentData | null;
211
+ status: "IN_PROGRESS" | "PAYMENT_PENDING" | "ABANDONED" | "CANCELED" | "FAILED";
174
212
  }
175
213
  type RecursiveRecord = {
176
214
  [key: string]: any;
@@ -191,6 +229,14 @@ declare class Checkout {
191
229
  * Update a checkout session
192
230
  */
193
231
  update(checkoutId: string, params: CheckoutUpdateParams): Promise<CheckoutSession>;
232
+ /**
233
+ * Update a checkout session
234
+ */
235
+ applyDiscountCode(checkoutId: string, discountCode: string): Promise<CheckoutSession>;
236
+ /**
237
+ * Update a checkout session
238
+ */
239
+ revalidateDiscounts(checkoutId: string): Promise<CheckoutSession>;
194
240
  /**
195
241
  * Get shipping rates for a checkout session
196
242
  */
@@ -215,6 +261,14 @@ declare class Client {
215
261
  * Update a checkout session
216
262
  */
217
263
  updateCheckout(clientSecret: string, checkoutId: string, params: CheckoutUpdateParams): Promise<CheckoutSession>;
264
+ /**
265
+ * Update a checkout session
266
+ */
267
+ applyDiscountCode(clientSecret: string, checkoutId: string, discountCode: string): Promise<CheckoutSession>;
268
+ /**
269
+ * Update a checkout session
270
+ */
271
+ revalidateDiscounts(clientSecret: string, checkoutId: string): Promise<CheckoutSession>;
218
272
  /**
219
273
  * Get shipping rates for a checkout session
220
274
  */
package/dist/index.d.ts CHANGED
@@ -141,6 +141,7 @@ interface CheckoutCreateParams {
141
141
  customerId?: string;
142
142
  lineItems: LineItemCreate[];
143
143
  currency?: Currency;
144
+ discountCode?: string;
144
145
  }
145
146
  interface CheckoutUpdateParams {
146
147
  customerId?: string;
@@ -153,24 +154,61 @@ interface CheckoutUpdateParams {
153
154
  };
154
155
  }
155
156
 
156
- interface CheckoutSession {
157
+ type ShipmentData = {
158
+ provider: string;
159
+ name?: string;
160
+ service?: string;
161
+ pickupPointId?: string;
162
+ trackingId?: string;
163
+ trackingUrl?: string;
164
+ };
165
+ type Discount = {
157
166
  id: string;
158
167
  createdAt: Date;
159
168
  updatedAt: Date;
160
- clientSecret: string;
161
- lineItems: LineItem[];
162
- total?: number;
163
- subtotal?: number;
164
- tax?: number;
165
- shipping?: number;
166
- currency: string;
167
- exchangeRate: number;
168
- status: "IN_PROGRESS" | "PAYMENT_PENDING" | "ABANDONED" | "CANCELED" | "FAILED";
169
+ type: "AMOUNT_OFF_PRODUCTS" | "BUY_X_GET_Y" | "AMOUNT_OFF_ORDER" | "FREE_SHIPPING";
170
+ method: "CODE" | "AUTOMATIC";
171
+ code?: string | null;
172
+ title?: string | null;
173
+ value: number;
174
+ valueType: "PERCENTAGE" | "FIXED_AMOUNT" | "FREE";
175
+ discountScope: "PRODUCTS" | "COLLECTIONS";
176
+ allowedProductIDs: string[];
177
+ allowedCollectionIDs: string[];
178
+ allowedCombinations: ("ORDER" | "PRODUCT" | "SHIPPING")[];
179
+ minimumRequirementsType: "NONE" | "MINIMUM_ORDER_AMOUNT" | "MINIMUM_PRODUCT_QUANTITY";
180
+ minimumRequirementsValue?: number | null;
181
+ requiredProductIDs: string[];
182
+ requiredCollectionIDs: string[];
183
+ minimumRequirementsScope: "PRODUCTS" | "COLLECTIONS";
184
+ maxUses?: number | null;
185
+ maxUsesPerCustomer?: number | null;
186
+ maxAllowedProductQuantity?: number | null;
187
+ uses: number;
188
+ startsAt: Date;
189
+ expiresAt?: Date | null;
190
+ status: "ACTIVE" | "EXPIRED" | "SCHEDULED";
191
+ organizationId: string;
192
+ };
193
+ interface CheckoutSession {
194
+ id: string;
195
+ testmode: boolean;
169
196
  customer?: {
170
197
  id: string;
171
198
  address?: Address;
172
199
  email?: string;
173
200
  };
201
+ lineItems: LineItem[];
202
+ tax: number | null;
203
+ shipping: number | null;
204
+ discountAmount: number | null;
205
+ appliedDiscounts: {
206
+ discount: Discount;
207
+ }[];
208
+ currency: string;
209
+ exchangeRate: number | null;
210
+ shipmentData: ShipmentData | null;
211
+ status: "IN_PROGRESS" | "PAYMENT_PENDING" | "ABANDONED" | "CANCELED" | "FAILED";
174
212
  }
175
213
  type RecursiveRecord = {
176
214
  [key: string]: any;
@@ -191,6 +229,14 @@ declare class Checkout {
191
229
  * Update a checkout session
192
230
  */
193
231
  update(checkoutId: string, params: CheckoutUpdateParams): Promise<CheckoutSession>;
232
+ /**
233
+ * Update a checkout session
234
+ */
235
+ applyDiscountCode(checkoutId: string, discountCode: string): Promise<CheckoutSession>;
236
+ /**
237
+ * Update a checkout session
238
+ */
239
+ revalidateDiscounts(checkoutId: string): Promise<CheckoutSession>;
194
240
  /**
195
241
  * Get shipping rates for a checkout session
196
242
  */
@@ -215,6 +261,14 @@ declare class Client {
215
261
  * Update a checkout session
216
262
  */
217
263
  updateCheckout(clientSecret: string, checkoutId: string, params: CheckoutUpdateParams): Promise<CheckoutSession>;
264
+ /**
265
+ * Update a checkout session
266
+ */
267
+ applyDiscountCode(clientSecret: string, checkoutId: string, discountCode: string): Promise<CheckoutSession>;
268
+ /**
269
+ * Update a checkout session
270
+ */
271
+ revalidateDiscounts(clientSecret: string, checkoutId: string): Promise<CheckoutSession>;
218
272
  /**
219
273
  * Get shipping rates for a checkout session
220
274
  */
package/dist/index.js CHANGED
@@ -163,6 +163,29 @@ var Checkout = class {
163
163
  return data;
164
164
  });
165
165
  }
166
+ /**
167
+ * Update a checkout session
168
+ */
169
+ applyDiscountCode(checkoutId, discountCode) {
170
+ return __async(this, null, function* () {
171
+ const data = yield this.apiClient.post(
172
+ `/checkout/${checkoutId}/discount`,
173
+ { code: discountCode }
174
+ );
175
+ return data;
176
+ });
177
+ }
178
+ /**
179
+ * Update a checkout session
180
+ */
181
+ revalidateDiscounts(checkoutId) {
182
+ return __async(this, null, function* () {
183
+ const data = yield this.apiClient.get(
184
+ `/checkout/${checkoutId}/revalidate-discounts`
185
+ );
186
+ return data;
187
+ });
188
+ }
166
189
  /**
167
190
  * Get shipping rates for a checkout session
168
191
  */
@@ -220,6 +243,31 @@ var Client = class {
220
243
  return data;
221
244
  });
222
245
  }
246
+ /**
247
+ * Update a checkout session
248
+ */
249
+ applyDiscountCode(clientSecret, checkoutId, discountCode) {
250
+ return __async(this, null, function* () {
251
+ const apiClient = createApiClient(clientSecret, this.proxy);
252
+ const data = yield apiClient.post(
253
+ `/checkout/${checkoutId}/discount`,
254
+ { code: discountCode }
255
+ );
256
+ return data;
257
+ });
258
+ }
259
+ /**
260
+ * Update a checkout session
261
+ */
262
+ revalidateDiscounts(clientSecret, checkoutId) {
263
+ return __async(this, null, function* () {
264
+ const apiClient = createApiClient(clientSecret, this.proxy);
265
+ const data = yield apiClient.get(
266
+ `/checkout/${checkoutId}/revalidate-discounts`
267
+ );
268
+ return data;
269
+ });
270
+ }
223
271
  /**
224
272
  * Get shipping rates for a checkout session
225
273
  */
package/dist/index.mjs CHANGED
@@ -127,6 +127,29 @@ var Checkout = class {
127
127
  return data;
128
128
  });
129
129
  }
130
+ /**
131
+ * Update a checkout session
132
+ */
133
+ applyDiscountCode(checkoutId, discountCode) {
134
+ return __async(this, null, function* () {
135
+ const data = yield this.apiClient.post(
136
+ `/checkout/${checkoutId}/discount`,
137
+ { code: discountCode }
138
+ );
139
+ return data;
140
+ });
141
+ }
142
+ /**
143
+ * Update a checkout session
144
+ */
145
+ revalidateDiscounts(checkoutId) {
146
+ return __async(this, null, function* () {
147
+ const data = yield this.apiClient.get(
148
+ `/checkout/${checkoutId}/revalidate-discounts`
149
+ );
150
+ return data;
151
+ });
152
+ }
130
153
  /**
131
154
  * Get shipping rates for a checkout session
132
155
  */
@@ -184,6 +207,31 @@ var Client = class {
184
207
  return data;
185
208
  });
186
209
  }
210
+ /**
211
+ * Update a checkout session
212
+ */
213
+ applyDiscountCode(clientSecret, checkoutId, discountCode) {
214
+ return __async(this, null, function* () {
215
+ const apiClient = createApiClient(clientSecret, this.proxy);
216
+ const data = yield apiClient.post(
217
+ `/checkout/${checkoutId}/discount`,
218
+ { code: discountCode }
219
+ );
220
+ return data;
221
+ });
222
+ }
223
+ /**
224
+ * Update a checkout session
225
+ */
226
+ revalidateDiscounts(clientSecret, checkoutId) {
227
+ return __async(this, null, function* () {
228
+ const apiClient = createApiClient(clientSecret, this.proxy);
229
+ const data = yield apiClient.get(
230
+ `/checkout/${checkoutId}/revalidate-discounts`
231
+ );
232
+ return data;
233
+ });
234
+ }
187
235
  /**
188
236
  * Get shipping rates for a checkout session
189
237
  */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@betterstore/sdk",
3
- "version": "0.3.49",
3
+ "version": "0.3.50",
4
4
  "description": "E-commerce for Developers",
5
5
  "private": false,
6
6
  "publishConfig": {