@betterstore/sdk 0.3.49 → 0.3.51

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,17 @@
1
1
  # @betterstore/sdk
2
2
 
3
+ ## 0.3.51
4
+
5
+ ### Patch Changes
6
+
7
+ - bug fix
8
+
9
+ ## 0.3.50
10
+
11
+ ### Patch Changes
12
+
13
+ - discounts handeling finished
14
+
3
15
  ## 0.3.49
4
16
 
5
17
  ### 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,62 @@ 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;
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;
160
196
  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
197
  customer?: {
170
198
  id: string;
171
199
  address?: Address;
172
200
  email?: string;
173
201
  };
202
+ lineItems: LineItem[];
203
+ tax: number | null;
204
+ shipping: number | null;
205
+ discountAmount: number | null;
206
+ appliedDiscounts: {
207
+ discount: Discount;
208
+ }[];
209
+ currency: string;
210
+ exchangeRate: number | null;
211
+ shipmentData: ShipmentData | null;
212
+ status: "IN_PROGRESS" | "PAYMENT_PENDING" | "ABANDONED" | "CANCELED" | "FAILED";
174
213
  }
175
214
  type RecursiveRecord = {
176
215
  [key: string]: any;
@@ -191,6 +230,14 @@ declare class Checkout {
191
230
  * Update a checkout session
192
231
  */
193
232
  update(checkoutId: string, params: CheckoutUpdateParams): Promise<CheckoutSession>;
233
+ /**
234
+ * Update a checkout session
235
+ */
236
+ applyDiscountCode(checkoutId: string, discountCode: string): Promise<CheckoutSession>;
237
+ /**
238
+ * Update a checkout session
239
+ */
240
+ revalidateDiscounts(checkoutId: string): Promise<CheckoutSession>;
194
241
  /**
195
242
  * Get shipping rates for a checkout session
196
243
  */
@@ -215,6 +262,14 @@ declare class Client {
215
262
  * Update a checkout session
216
263
  */
217
264
  updateCheckout(clientSecret: string, checkoutId: string, params: CheckoutUpdateParams): Promise<CheckoutSession>;
265
+ /**
266
+ * Update a checkout session
267
+ */
268
+ applyDiscountCode(clientSecret: string, checkoutId: string, discountCode: string): Promise<CheckoutSession>;
269
+ /**
270
+ * Update a checkout session
271
+ */
272
+ revalidateDiscounts(clientSecret: string, checkoutId: string): Promise<CheckoutSession>;
218
273
  /**
219
274
  * Get shipping rates for a checkout session
220
275
  */
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,62 @@ 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;
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;
160
196
  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
197
  customer?: {
170
198
  id: string;
171
199
  address?: Address;
172
200
  email?: string;
173
201
  };
202
+ lineItems: LineItem[];
203
+ tax: number | null;
204
+ shipping: number | null;
205
+ discountAmount: number | null;
206
+ appliedDiscounts: {
207
+ discount: Discount;
208
+ }[];
209
+ currency: string;
210
+ exchangeRate: number | null;
211
+ shipmentData: ShipmentData | null;
212
+ status: "IN_PROGRESS" | "PAYMENT_PENDING" | "ABANDONED" | "CANCELED" | "FAILED";
174
213
  }
175
214
  type RecursiveRecord = {
176
215
  [key: string]: any;
@@ -191,6 +230,14 @@ declare class Checkout {
191
230
  * Update a checkout session
192
231
  */
193
232
  update(checkoutId: string, params: CheckoutUpdateParams): Promise<CheckoutSession>;
233
+ /**
234
+ * Update a checkout session
235
+ */
236
+ applyDiscountCode(checkoutId: string, discountCode: string): Promise<CheckoutSession>;
237
+ /**
238
+ * Update a checkout session
239
+ */
240
+ revalidateDiscounts(checkoutId: string): Promise<CheckoutSession>;
194
241
  /**
195
242
  * Get shipping rates for a checkout session
196
243
  */
@@ -215,6 +262,14 @@ declare class Client {
215
262
  * Update a checkout session
216
263
  */
217
264
  updateCheckout(clientSecret: string, checkoutId: string, params: CheckoutUpdateParams): Promise<CheckoutSession>;
265
+ /**
266
+ * Update a checkout session
267
+ */
268
+ applyDiscountCode(clientSecret: string, checkoutId: string, discountCode: string): Promise<CheckoutSession>;
269
+ /**
270
+ * Update a checkout session
271
+ */
272
+ revalidateDiscounts(clientSecret: string, checkoutId: string): Promise<CheckoutSession>;
218
273
  /**
219
274
  * Get shipping rates for a checkout session
220
275
  */
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.51",
4
4
  "description": "E-commerce for Developers",
5
5
  "private": false,
6
6
  "publishConfig": {