@voucherify/sdk 2.6.0 → 2.7.0
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 +13 -0
- package/README.md +21 -0
- package/dist/ClientSide.d.ts +5 -0
- package/dist/Qualifications.d.ts +10 -0
- package/dist/VoucherifyServerSide.d.ts +2 -0
- package/dist/index.d.ts +1 -0
- package/dist/types/ApplicableTo.d.ts +15 -0
- package/dist/types/Customers.d.ts +88 -3
- package/dist/types/DiscountVoucher.d.ts +44 -2
- package/dist/types/Orders.d.ts +110 -1
- package/dist/types/Qualifications.d.ts +86 -0
- package/dist/types/ValidationRules.d.ts +1 -0
- package/dist/types/index.d.ts +1 -0
- package/dist/voucherifysdk.esm.js +55 -8
- package/dist/voucherifysdk.esm.js.map +1 -1
- package/dist/voucherifysdk.umd.development.js +55 -8
- package/dist/voucherifysdk.umd.development.js.map +1 -1
- package/dist/voucherifysdk.umd.production.min.js +1 -1
- package/dist/voucherifysdk.umd.production.min.js.map +1 -1
- package/package.json +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,18 @@
|
|
|
1
1
|
# @voucherify/sdk
|
|
2
2
|
|
|
3
|
+
## 2.7.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- [`32fa44a`](https://github.com/voucherifyio/voucherify-js-sdk/commit/32fa44ab17b21bda9daf953eaf4969d528c2d707) [#255](https://github.com/voucherifyio/voucherify-js-sdk/pull/255) Thanks [@awilczek](https://github.com/awilczek)! - Update axios to 1.6.5 in SDK package
|
|
8
|
+
|
|
9
|
+
* [`8df2fed`](https://github.com/voucherifyio/voucherify-js-sdk/commit/8df2fed2b4319f681d0ff17b9bb15e6bbf80dd7c) [#254](https://github.com/voucherifyio/voucherify-js-sdk/pull/254) Thanks [@p-zielinski](https://github.com/p-zielinski)! - Add support for few endpoints of Loyalties API.
|
|
10
|
+
- Added support for new endpoints: `POST /v1/qualifications`, `POST /client/v1/qualifications` [(examples of usage available in readme.md)](..%2F..%2Fpackages%2Fsdk%2FREADME.md)
|
|
11
|
+
- New exported types/interfaces: `InapplicableTo`, `Referrer`, `ReferrerWithSummaryLoyaltyReferrals`, `Customer`, `CustomerWithSummaryLoyaltyReferrals`, `CustomerSummary`, `CustomerSummaryRedemptions`, `CustomerSummaryOrders`, `CustomerLoyalty`, `CustomerReferrals`, `Discount`, `DiscountAmount_`, `DiscountUnit_`, `DiscountUnitBase_`, `DiscountUnitMultiple_`, `DiscountPercent_`, `DiscountFixed_`, `Order`, `OrderItem`, `OrderCalculated`, `OrderRedemptions`, `OrderItemCalculated`, `QualificationsCheckEligibilityRequestBody`, `QualificationsCheckEligibilityResponseBody`, `QualificationsFiltersFields`, `QualificationsFiltersCondition`, `QualificationsFieldConditions`, `QualificationsRedeemablesResponse`, `QualificationsStackingRulesResponse`, `QualificationsRedeemable`, `QualificationsRedeemableBase`, `RedeemableSingleResultResponse`, `ValidationRulesAssignmentsList`,
|
|
12
|
+
- Added optional properties to `ApplicableTo`: `product_id`, `product_source_id`, `quantity_limit`, `aggregated_quantity_limit`, `amount_limit`, `aggregated_amount_limit`, `order_item_indices`
|
|
13
|
+
- Added required property: `data_ref: 'data'` to `ApplicableToResultList` // NOTE: as this type is only used in responses, this is not a breaking change.
|
|
14
|
+
- Added optional properties to `CustomerRequest`: `birthday` and `birthdate`
|
|
15
|
+
|
|
3
16
|
## 2.6.0
|
|
4
17
|
|
|
5
18
|
### Minor Changes
|
package/README.md
CHANGED
|
@@ -450,6 +450,20 @@ client.categories.list()
|
|
|
450
450
|
|
|
451
451
|
---
|
|
452
452
|
|
|
453
|
+
### Qualifications
|
|
454
|
+
|
|
455
|
+
Methods are provided within `client.qualifications.*` or `client.promotions.*` namespace.
|
|
456
|
+
|
|
457
|
+
- [Check Eligibility](#Check-Eligibility)
|
|
458
|
+
|
|
459
|
+
#### [Check Eligibility](https://docs.voucherify.io/reference/check-eligibility)
|
|
460
|
+
|
|
461
|
+
```javascript
|
|
462
|
+
client.qualifications.checkEligibility(body)
|
|
463
|
+
```
|
|
464
|
+
|
|
465
|
+
---
|
|
466
|
+
|
|
453
467
|
### Validations
|
|
454
468
|
|
|
455
469
|
Methods are provided within `client.validations.*` or `client.promotions.*` namespace.
|
|
@@ -1606,6 +1620,7 @@ Methods are provided within `client.*` namespace.
|
|
|
1606
1620
|
- [List consents](#list-consents)
|
|
1607
1621
|
- [Update consents](#update-consents)
|
|
1608
1622
|
- [Track custom events](#track-custom-events)
|
|
1623
|
+
- [Qualifications](#Qualifications)
|
|
1609
1624
|
|
|
1610
1625
|
#### Set Identity
|
|
1611
1626
|
|
|
@@ -1678,6 +1693,12 @@ client.updateConsents(idOrSourceId, consents)
|
|
|
1678
1693
|
client.track(eventName, metadata, customer)
|
|
1679
1694
|
```
|
|
1680
1695
|
|
|
1696
|
+
#### [Qualifications](https://docs.voucherify.io/reference/check-eligibility-client-side)
|
|
1697
|
+
|
|
1698
|
+
```javascript
|
|
1699
|
+
client.qualifications(body)
|
|
1700
|
+
```
|
|
1701
|
+
|
|
1681
1702
|
# <a name="snippet"></a>🏎 Marketer-ready Voucherify snippet
|
|
1682
1703
|
|
|
1683
1704
|
Go [here](./examples/sdk/with-html) for more HTML-based examples
|
package/dist/ClientSide.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import * as T from './types/ClientSide';
|
|
2
|
+
import * as TQ from './types/Qualifications';
|
|
2
3
|
import type { RequestController } from './RequestController';
|
|
3
4
|
export declare class ClientSide {
|
|
4
5
|
private client;
|
|
@@ -45,4 +46,8 @@ export declare class ClientSide {
|
|
|
45
46
|
* @see https://docs.voucherify.io/reference/redeem-stackable-discounts-client-side
|
|
46
47
|
*/
|
|
47
48
|
redeemStackable(params: T.ClientSideRedemptionsRedeemStackableParams): Promise<import("./types").RedemptionsRedeemStackableResponse>;
|
|
49
|
+
/**
|
|
50
|
+
* @see https://docs.voucherify.io/reference/check-eligibility
|
|
51
|
+
*/
|
|
52
|
+
qualifications(body: TQ.QualificationsCheckEligibilityRequestBody): Promise<TQ.QualificationsCheckEligibilityResponseBody>;
|
|
48
53
|
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import * as T from './types/Qualifications';
|
|
2
|
+
import type { RequestController } from './RequestController';
|
|
3
|
+
export declare class Qualifications {
|
|
4
|
+
private client;
|
|
5
|
+
constructor(client: RequestController);
|
|
6
|
+
/**
|
|
7
|
+
* @see https://docs.voucherify.io/reference/check-eligibility
|
|
8
|
+
*/
|
|
9
|
+
checkEligibility(body: T.QualificationsCheckEligibilityRequestBody): Promise<T.QualificationsCheckEligibilityResponseBody>;
|
|
10
|
+
}
|
|
@@ -18,6 +18,7 @@ import { ApiLimitsHandler } from './ApiLimitsHandler';
|
|
|
18
18
|
import { MetadataSchemas } from './MetadataSchemas';
|
|
19
19
|
import { Categories } from './Categories';
|
|
20
20
|
import { ProductCollections } from './ProductCollections';
|
|
21
|
+
import { Qualifications } from './Qualifications';
|
|
21
22
|
export interface VoucherifyServerSideOptions {
|
|
22
23
|
/**
|
|
23
24
|
* Optionally, you can add `apiUrl` to the client options if you want to use Voucherify running in a specific region.
|
|
@@ -118,6 +119,7 @@ export declare function VoucherifyServerSide(options: VoucherifyServerSideOption
|
|
|
118
119
|
orders: Orders;
|
|
119
120
|
products: Products;
|
|
120
121
|
productCollections: ProductCollections;
|
|
122
|
+
qualifications: Qualifications;
|
|
121
123
|
rewards: Rewards;
|
|
122
124
|
loyalties: Loyalties;
|
|
123
125
|
segments: Segments;
|
package/dist/index.d.ts
CHANGED
|
@@ -22,3 +22,4 @@ export type { ValidationRules } from './ValidationRules';
|
|
|
22
22
|
export type { Validations } from './Validations';
|
|
23
23
|
export type { VoucherifyError } from './VoucherifyError';
|
|
24
24
|
export type { Vouchers } from './Vouchers';
|
|
25
|
+
export type { Qualifications } from './Qualifications';
|
|
@@ -3,13 +3,28 @@ export interface ApplicableTo {
|
|
|
3
3
|
object: 'product' | 'sku' | 'products_collection';
|
|
4
4
|
id: string;
|
|
5
5
|
source_id?: string;
|
|
6
|
+
product_id?: string;
|
|
7
|
+
product_source_id?: string;
|
|
6
8
|
strict: boolean;
|
|
7
9
|
price?: number;
|
|
8
10
|
price_formula?: number;
|
|
9
11
|
effect: ApplicableToEffect;
|
|
12
|
+
quantity_limit?: number;
|
|
13
|
+
aggregated_quantity_limit?: number;
|
|
14
|
+
amount_limit?: number;
|
|
15
|
+
aggregated_amount_limit?: number;
|
|
16
|
+
order_item_indices?: number[];
|
|
10
17
|
}
|
|
11
18
|
export interface ApplicableToResultList {
|
|
12
19
|
object: 'list';
|
|
13
20
|
total: number;
|
|
14
21
|
data: ApplicableTo[];
|
|
22
|
+
data_ref: 'data';
|
|
15
23
|
}
|
|
24
|
+
export declare type InapplicableToResultList = {
|
|
25
|
+
data: InapplicableTo[];
|
|
26
|
+
total: number;
|
|
27
|
+
object: 'list';
|
|
28
|
+
data_ref: string;
|
|
29
|
+
};
|
|
30
|
+
export declare type InapplicableTo = ApplicableTo;
|
|
@@ -65,9 +65,11 @@ export interface CustomerRequest {
|
|
|
65
65
|
id?: string;
|
|
66
66
|
source_id?: string;
|
|
67
67
|
name?: string;
|
|
68
|
-
email?: string;
|
|
69
|
-
metadata?: Record<string, any>;
|
|
70
68
|
description?: string;
|
|
69
|
+
email?: string;
|
|
70
|
+
phone?: string;
|
|
71
|
+
birthday?: string;
|
|
72
|
+
birthdate?: string;
|
|
71
73
|
address?: {
|
|
72
74
|
city?: string;
|
|
73
75
|
state?: string;
|
|
@@ -76,7 +78,7 @@ export interface CustomerRequest {
|
|
|
76
78
|
country?: string;
|
|
77
79
|
postal_code?: string;
|
|
78
80
|
};
|
|
79
|
-
|
|
81
|
+
metadata?: Record<string, any>;
|
|
80
82
|
}
|
|
81
83
|
export interface CustomersCommonListRequest {
|
|
82
84
|
limit?: number;
|
|
@@ -142,6 +144,89 @@ declare type CustomerAddress = {
|
|
|
142
144
|
postal_code?: string | null;
|
|
143
145
|
} | null;
|
|
144
146
|
};
|
|
147
|
+
export declare type Referrer = CustomerRequest;
|
|
148
|
+
export declare type Customer = CustomerRequest;
|
|
149
|
+
export declare type ReferrerWithSummaryLoyaltyReferrals = CustomerWithSummaryLoyaltyReferrals;
|
|
150
|
+
export declare type CustomerId = {
|
|
151
|
+
id: string;
|
|
152
|
+
object: 'customer';
|
|
153
|
+
};
|
|
154
|
+
export declare type ReferrerId = CustomerId;
|
|
155
|
+
export declare type CustomerWithSummaryLoyaltyReferrals = {
|
|
156
|
+
id?: string;
|
|
157
|
+
source_id?: string;
|
|
158
|
+
name?: string;
|
|
159
|
+
description?: string;
|
|
160
|
+
email?: string;
|
|
161
|
+
phone?: string;
|
|
162
|
+
birthday?: string;
|
|
163
|
+
birthdate?: string;
|
|
164
|
+
address: {
|
|
165
|
+
city?: string;
|
|
166
|
+
state?: string;
|
|
167
|
+
line_1?: string;
|
|
168
|
+
line_2?: string;
|
|
169
|
+
country?: string;
|
|
170
|
+
postal_code?: string;
|
|
171
|
+
} | null;
|
|
172
|
+
metadata?: Record<string, any>;
|
|
173
|
+
summary: CustomerSummary;
|
|
174
|
+
loyalty: CustomerLoyalty;
|
|
175
|
+
referrals: CustomerReferrals;
|
|
176
|
+
system_metadata: Record<string, unknown>;
|
|
177
|
+
created_at: string;
|
|
178
|
+
updated_at?: string;
|
|
179
|
+
assets?: {
|
|
180
|
+
cockpit_url?: string;
|
|
181
|
+
};
|
|
182
|
+
object: 'customer';
|
|
183
|
+
};
|
|
184
|
+
export declare type CustomerSummary = {
|
|
185
|
+
redemptions: CustomerSummaryRedemptions;
|
|
186
|
+
orders: CustomerSummaryOrders;
|
|
187
|
+
};
|
|
188
|
+
export declare type CustomerSummaryRedemptions = {
|
|
189
|
+
total_redeemed: number;
|
|
190
|
+
total_failed: number;
|
|
191
|
+
total_succeeded: number;
|
|
192
|
+
total_rolled_back: number;
|
|
193
|
+
total_rollback_failed: number;
|
|
194
|
+
total_rollback_succeeded: number;
|
|
195
|
+
gift: {
|
|
196
|
+
redeemed_amount: number;
|
|
197
|
+
amount_to_go: number;
|
|
198
|
+
};
|
|
199
|
+
loyalty_card: {
|
|
200
|
+
redeemed_points: number;
|
|
201
|
+
points_to_go: number;
|
|
202
|
+
};
|
|
203
|
+
};
|
|
204
|
+
export declare type CustomerSummaryOrders = {
|
|
205
|
+
total_amount: number;
|
|
206
|
+
total_count: number;
|
|
207
|
+
average_amount: number;
|
|
208
|
+
last_order_amount: number;
|
|
209
|
+
last_order_date: string;
|
|
210
|
+
};
|
|
211
|
+
export declare type CustomerLoyalty = {
|
|
212
|
+
points: number;
|
|
213
|
+
referred_customers: number;
|
|
214
|
+
campaigns: Record<string, {
|
|
215
|
+
points: number;
|
|
216
|
+
loyalty_tier: string;
|
|
217
|
+
referred_customers: number;
|
|
218
|
+
}>;
|
|
219
|
+
};
|
|
220
|
+
export declare type CustomerReferrals = {
|
|
221
|
+
total: number;
|
|
222
|
+
campaigns: {
|
|
223
|
+
campaign_id: string;
|
|
224
|
+
referrer_id: string;
|
|
225
|
+
related_object_id: string;
|
|
226
|
+
related_object_type: string;
|
|
227
|
+
date: string;
|
|
228
|
+
}[];
|
|
229
|
+
};
|
|
145
230
|
export declare type CustomersUpdateInBulkRequestBody = (CustomerBase & CustomerAddress & {
|
|
146
231
|
source_id: string | null;
|
|
147
232
|
})[];
|
|
@@ -5,9 +5,9 @@ export declare enum DiscountVouchersTypesEnum {
|
|
|
5
5
|
UNIT = "UNIT",
|
|
6
6
|
FIXED = "FIXED"
|
|
7
7
|
}
|
|
8
|
-
export declare type DiscountVouchersEffectTypes = 'ADD_MISSING_ITEMS' | 'ADD_NEW_ITEMS' | 'ADD_MANY_ITEMS' | 'APPLY_TO_ORDER' | 'APPLY_TO_ITEMS' | 'APPLY_TO_ITEMS_PROPORTIONALLY' | 'APPLY_TO_ITEMS_PROPORTIONALLY_BY_QUANTITY';
|
|
8
|
+
export declare type DiscountVouchersEffectTypes = 'ADD_MISSING_ITEMS' | 'ADD_NEW_ITEMS' | 'ADD_MANY_ITEMS' | 'APPLY_TO_ORDER' | 'APPLY_TO_ITEMS' | 'APPLY_TO_ITEMS_PROPORTIONALLY' | 'APPLY_TO_ITEMS_PROPORTIONALLY_BY_QUANTITY' | 'APPLY_TO_ITEMS_BY_QUANTITY';
|
|
9
9
|
export declare type DiscountUnitVouchersEffectTypes = 'ADD_MISSING_ITEMS' | 'ADD_NEW_ITEMS' | 'ADD_MANY_ITEMS';
|
|
10
|
-
export declare type DiscountAmountVouchersEffectTypes = 'APPLY_TO_ORDER' | 'APPLY_TO_ITEMS' | 'APPLY_TO_ITEMS_PROPORTIONALLY' | 'APPLY_TO_ITEMS_PROPORTIONALLY_BY_QUANTITY';
|
|
10
|
+
export declare type DiscountAmountVouchersEffectTypes = 'APPLY_TO_ORDER' | 'APPLY_TO_ITEMS' | 'APPLY_TO_ITEMS_PROPORTIONALLY' | 'APPLY_TO_ITEMS_PROPORTIONALLY_BY_QUANTITY' | 'APPLY_TO_ITEMS_BY_QUANTITY';
|
|
11
11
|
export declare type DiscountPercentVouchersEffectTypes = 'APPLY_TO_ORDER' | 'APPLY_TO_ITEMS';
|
|
12
12
|
export declare type DiscountFixedVouchersEffectTypes = 'APPLY_TO_ORDER' | 'APPLY_TO_ITEMS';
|
|
13
13
|
interface SimpleSkuDiscountUnit {
|
|
@@ -48,4 +48,46 @@ export interface DiscountFixed {
|
|
|
48
48
|
fixed_amount_formula?: string;
|
|
49
49
|
effect?: DiscountFixedVouchersEffectTypes;
|
|
50
50
|
}
|
|
51
|
+
export declare type Discount = DiscountAmount_ | DiscountUnit_ | DiscountUnitMultiple_ | DiscountPercent_ | DiscountFixed_;
|
|
52
|
+
export declare type DiscountAmount_ = {
|
|
53
|
+
type: 'AMOUNT';
|
|
54
|
+
amount_off?: number;
|
|
55
|
+
amount_off_formula?: string;
|
|
56
|
+
aggregated_amount_limit?: number;
|
|
57
|
+
effect?: DiscountAmountVouchersEffectTypes;
|
|
58
|
+
is_dynamic?: boolean;
|
|
59
|
+
};
|
|
60
|
+
export declare type DiscountUnit_ = {
|
|
61
|
+
type: 'UNIT';
|
|
62
|
+
} & DiscountUnitBase_;
|
|
63
|
+
export declare type DiscountUnitBase_ = {
|
|
64
|
+
unit_off?: number;
|
|
65
|
+
unit_off_formula?: string;
|
|
66
|
+
unit_type: string;
|
|
67
|
+
product?: SimpleProductDiscountUnit;
|
|
68
|
+
sku?: SimpleSkuDiscountUnit;
|
|
69
|
+
effect?: 'ADD_MISSING_ITEMS' | 'ADD_NEW_ITEMS';
|
|
70
|
+
is_dynamic?: boolean;
|
|
71
|
+
};
|
|
72
|
+
export declare type DiscountUnitMultiple_ = {
|
|
73
|
+
type: 'UNIT';
|
|
74
|
+
effect: 'ADD_MANY_ITEMS';
|
|
75
|
+
units: DiscountUnitBase_[];
|
|
76
|
+
};
|
|
77
|
+
export declare type DiscountPercent_ = {
|
|
78
|
+
type: 'PERCENT';
|
|
79
|
+
percent_off?: number;
|
|
80
|
+
percent_off_formula?: string;
|
|
81
|
+
amount_limit?: number;
|
|
82
|
+
aggregated_amount_limit?: number;
|
|
83
|
+
effect?: DiscountPercentVouchersEffectTypes;
|
|
84
|
+
is_dynamic?: boolean;
|
|
85
|
+
};
|
|
86
|
+
export declare type DiscountFixed_ = {
|
|
87
|
+
type: 'FIXED';
|
|
88
|
+
fixed_amount?: number;
|
|
89
|
+
fixed_amount_formula?: string;
|
|
90
|
+
effect?: DiscountFixedVouchersEffectTypes;
|
|
91
|
+
is_dynamic?: boolean;
|
|
92
|
+
};
|
|
51
93
|
export {};
|
package/dist/types/Orders.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { CustomerRequest } from './Customers';
|
|
1
|
+
import { Customer, CustomerId, CustomerRequest, CustomerWithSummaryLoyaltyReferrals, Referrer, ReferrerId, ReferrerWithSummaryLoyaltyReferrals } from './Customers';
|
|
2
2
|
export interface OrdersItem {
|
|
3
3
|
sku_id?: string;
|
|
4
4
|
product_id?: string;
|
|
@@ -84,3 +84,112 @@ export interface OrdersListResponse {
|
|
|
84
84
|
data_ref: 'orders';
|
|
85
85
|
orders: OrdersGetResponse[];
|
|
86
86
|
}
|
|
87
|
+
export declare type Order = {
|
|
88
|
+
id?: string;
|
|
89
|
+
source_id?: string;
|
|
90
|
+
status?: 'CREATED' | 'PAID' | 'CANCELED' | 'FULFILLED';
|
|
91
|
+
amount?: number;
|
|
92
|
+
discount_amount?: number;
|
|
93
|
+
initial_amount?: number;
|
|
94
|
+
items?: OrderItem[];
|
|
95
|
+
customer?: Customer;
|
|
96
|
+
customer_id?: string;
|
|
97
|
+
referrer?: Referrer;
|
|
98
|
+
referrer_id?: string;
|
|
99
|
+
metadata?: Record<string, any>;
|
|
100
|
+
};
|
|
101
|
+
export declare type OrderItem = {
|
|
102
|
+
sku_id?: string;
|
|
103
|
+
product_id?: string;
|
|
104
|
+
related_object?: 'product' | 'sku';
|
|
105
|
+
source_id?: string;
|
|
106
|
+
quantity?: number;
|
|
107
|
+
discount_quantity?: number;
|
|
108
|
+
initial_quantity?: number;
|
|
109
|
+
amount?: number;
|
|
110
|
+
discount_amount?: number;
|
|
111
|
+
initial_amount?: number;
|
|
112
|
+
price?: number;
|
|
113
|
+
product?: {
|
|
114
|
+
id?: string;
|
|
115
|
+
source_id?: string;
|
|
116
|
+
override?: boolean;
|
|
117
|
+
name?: string;
|
|
118
|
+
metadata?: Record<string, any>;
|
|
119
|
+
price?: number;
|
|
120
|
+
};
|
|
121
|
+
sku?: {
|
|
122
|
+
id?: string;
|
|
123
|
+
source_id?: string;
|
|
124
|
+
override?: boolean;
|
|
125
|
+
sku?: string;
|
|
126
|
+
price?: number;
|
|
127
|
+
};
|
|
128
|
+
metadata?: Record<string, any>;
|
|
129
|
+
};
|
|
130
|
+
export declare type OrderCalculated = {
|
|
131
|
+
id?: string;
|
|
132
|
+
source_id?: string | null;
|
|
133
|
+
created_at?: string;
|
|
134
|
+
updated_at?: string | null;
|
|
135
|
+
status?: 'CREATED' | 'PAID' | 'CANCELED' | 'FULFILLED';
|
|
136
|
+
amount?: number;
|
|
137
|
+
initial_amount?: number;
|
|
138
|
+
discount_amount?: number;
|
|
139
|
+
items_discount_amount?: number;
|
|
140
|
+
total_discount_amount?: number;
|
|
141
|
+
total_amount?: number;
|
|
142
|
+
applied_discount_amount?: number;
|
|
143
|
+
items_applied_discount_amount?: number;
|
|
144
|
+
total_applied_discount_amount?: number;
|
|
145
|
+
items?: OrderItemCalculated[];
|
|
146
|
+
metadata: Record<string, unknown>;
|
|
147
|
+
customer?: CustomerId | CustomerWithSummaryLoyaltyReferrals;
|
|
148
|
+
customer_id: string | null;
|
|
149
|
+
referrer?: ReferrerId | ReferrerWithSummaryLoyaltyReferrals;
|
|
150
|
+
referrer_id: string | null;
|
|
151
|
+
object: 'order';
|
|
152
|
+
redemptions?: Record<string, OrderRedemptions>;
|
|
153
|
+
};
|
|
154
|
+
export declare type OrderRedemptions = {
|
|
155
|
+
date?: string;
|
|
156
|
+
rollback_id?: string;
|
|
157
|
+
rollback_date?: string;
|
|
158
|
+
related_object_type?: string;
|
|
159
|
+
related_object_id?: string;
|
|
160
|
+
related_object_parent_id?: string;
|
|
161
|
+
stacked?: string[];
|
|
162
|
+
rollback_stacked?: string[];
|
|
163
|
+
};
|
|
164
|
+
export declare type OrderItemCalculated = {
|
|
165
|
+
sku_id?: string;
|
|
166
|
+
product_id?: string;
|
|
167
|
+
related_object?: 'product' | 'sku';
|
|
168
|
+
source_id?: string;
|
|
169
|
+
quantity?: number;
|
|
170
|
+
discount_quantity?: number;
|
|
171
|
+
initial_quantity?: number;
|
|
172
|
+
amount?: number;
|
|
173
|
+
discount_amount?: number;
|
|
174
|
+
initial_amount?: number;
|
|
175
|
+
total_applied_discount_amount?: number;
|
|
176
|
+
price?: number;
|
|
177
|
+
subtotal_amount?: number;
|
|
178
|
+
product?: {
|
|
179
|
+
id?: string;
|
|
180
|
+
source_id?: string;
|
|
181
|
+
override?: boolean;
|
|
182
|
+
name?: string;
|
|
183
|
+
metadata?: Record<string, any>;
|
|
184
|
+
price?: number;
|
|
185
|
+
};
|
|
186
|
+
sku?: {
|
|
187
|
+
id?: string;
|
|
188
|
+
source_id?: string;
|
|
189
|
+
override?: boolean;
|
|
190
|
+
sku?: string;
|
|
191
|
+
price?: number;
|
|
192
|
+
};
|
|
193
|
+
object: 'order_item';
|
|
194
|
+
metadata?: Record<string, any>;
|
|
195
|
+
};
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
import { CustomerRequest } from './Customers';
|
|
2
|
+
import { Junction } from './Exports';
|
|
3
|
+
import { Order, OrderCalculated } from './Orders';
|
|
4
|
+
import { ApplicableToResultList, InapplicableToResultList } from './ApplicableTo';
|
|
5
|
+
import { Category } from './Categories';
|
|
6
|
+
import { Discount } from './DiscountVoucher';
|
|
7
|
+
import { LoyaltiesTransferPoints } from './Loyalties';
|
|
8
|
+
import { ValidationRulesAssignmentsList } from './ValidationRules';
|
|
9
|
+
export declare type QualificationsCheckEligibilityRequestBody = {
|
|
10
|
+
customer?: CustomerRequest;
|
|
11
|
+
order?: Order;
|
|
12
|
+
mode?: 'BASIC' | 'ADVANCED';
|
|
13
|
+
tracking_id?: string;
|
|
14
|
+
scenario?: 'ALL' | 'CUSTOMER_WALLET' | 'AUDIENCE_ONLY' | 'PRODUCTS' | 'PRODUCTS_DISCOUNT' | 'PROMOTION_STACKS' | 'PRODUCTS_BY_CUSTOMER' | 'PRODUCTS_DISCOUNT_BY_CUSTOMER';
|
|
15
|
+
options?: {
|
|
16
|
+
limit?: number;
|
|
17
|
+
starting_after?: string;
|
|
18
|
+
filters?: {
|
|
19
|
+
junction?: Junction;
|
|
20
|
+
} & Partial<Record<QualificationsFiltersFields, QualificationsFieldConditions>>;
|
|
21
|
+
expand?: ('redeemable' | 'category' | 'validation_rules')[];
|
|
22
|
+
sorting_rule?: 'BEST_DEAL' | 'LEAST_DEAL' | 'DEFAULT';
|
|
23
|
+
};
|
|
24
|
+
metadata?: Record<string, any>;
|
|
25
|
+
};
|
|
26
|
+
export declare type QualificationsCheckEligibilityResponseBody = {
|
|
27
|
+
redeemables: QualificationsRedeemableList;
|
|
28
|
+
tracking_id?: string;
|
|
29
|
+
order?: OrderCalculated;
|
|
30
|
+
stacking_rules: QualificationsStackingRules;
|
|
31
|
+
};
|
|
32
|
+
export declare type QualificationsFiltersFields = 'category_id' | 'campaign_id' | 'resource_id' | 'resource_type' | 'voucher_type' | 'code';
|
|
33
|
+
export declare type QualificationsFiltersCondition = '$in' | '$not_in' | '$is' | '$is_not' | '$has_value' | '$is_unknown';
|
|
34
|
+
export declare type QualificationsFieldConditions = {
|
|
35
|
+
conditions?: Partial<Record<QualificationsFiltersCondition, any>>;
|
|
36
|
+
};
|
|
37
|
+
export declare type QualificationsRedeemableList = {
|
|
38
|
+
object: 'list';
|
|
39
|
+
data_ref: 'data';
|
|
40
|
+
data: QualificationsRedeemable[];
|
|
41
|
+
total: number;
|
|
42
|
+
has_more: boolean;
|
|
43
|
+
more_starting_after?: string;
|
|
44
|
+
};
|
|
45
|
+
export declare type QualificationsStackingRules = {
|
|
46
|
+
redeemables_limit: number;
|
|
47
|
+
applicable_redeemables_limit: number;
|
|
48
|
+
applicable_exclusive_redeemables_limit: number;
|
|
49
|
+
exclusive_categories: string[];
|
|
50
|
+
joint_categories: string[];
|
|
51
|
+
};
|
|
52
|
+
export declare type QualificationsRedeemable = QualificationsRedeemableBase & {
|
|
53
|
+
redeemables?: QualificationsRedeemableBase[];
|
|
54
|
+
};
|
|
55
|
+
export declare type QualificationsRedeemableBase = {
|
|
56
|
+
id: string;
|
|
57
|
+
object: 'campaign' | 'promotion_tier' | 'promotion_stack' | 'voucher';
|
|
58
|
+
created_at: string;
|
|
59
|
+
result: RedeemableResult;
|
|
60
|
+
order?: OrderCalculated;
|
|
61
|
+
validation_rule_id?: string;
|
|
62
|
+
applicable_to: ApplicableToResultList;
|
|
63
|
+
inapplicable_to: InapplicableToResultList;
|
|
64
|
+
metadata: Record<string, unknown> | null;
|
|
65
|
+
categories: Category[];
|
|
66
|
+
banner?: string;
|
|
67
|
+
name?: string;
|
|
68
|
+
campaign_name?: string;
|
|
69
|
+
campaign_id?: string;
|
|
70
|
+
validation_rules_assignments?: ValidationRulesAssignmentsList;
|
|
71
|
+
};
|
|
72
|
+
export declare type RedeemableResult = {
|
|
73
|
+
discount?: Discount;
|
|
74
|
+
gift?: {
|
|
75
|
+
balance: number;
|
|
76
|
+
credits: number;
|
|
77
|
+
};
|
|
78
|
+
loyalty_card?: {
|
|
79
|
+
points?: number;
|
|
80
|
+
balance?: number;
|
|
81
|
+
exchange_ratio?: number;
|
|
82
|
+
points_ratio?: number;
|
|
83
|
+
transfers?: LoyaltiesTransferPoints[];
|
|
84
|
+
};
|
|
85
|
+
error?: Error;
|
|
86
|
+
};
|
|
@@ -69,6 +69,7 @@ export interface ValidationRulesListAssignmentsResponse {
|
|
|
69
69
|
data_ref: 'data';
|
|
70
70
|
data: ValidationRulesCreateAssignmentResponse[];
|
|
71
71
|
}
|
|
72
|
+
export declare type ValidationRulesAssignmentsList = ValidationRulesListResponse;
|
|
72
73
|
export interface ValidationRulesAssignment {
|
|
73
74
|
id: string;
|
|
74
75
|
rule_id: string;
|
package/dist/types/index.d.ts
CHANGED
|
@@ -105,7 +105,13 @@ class RequestController {
|
|
|
105
105
|
}
|
|
106
106
|
|
|
107
107
|
setLastResponseHeaders(headers) {
|
|
108
|
-
|
|
108
|
+
const result = {};
|
|
109
|
+
|
|
110
|
+
for (const key in headers) {
|
|
111
|
+
result[key] = String(headers[key]);
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
this.lastResponseHeaders = result;
|
|
109
115
|
this.isLastResponseHeadersSet = true;
|
|
110
116
|
}
|
|
111
117
|
|
|
@@ -323,7 +329,10 @@ class Campaigns {
|
|
|
323
329
|
const fileStream = fs.createReadStream(filePath);
|
|
324
330
|
const form = new FormData();
|
|
325
331
|
form.append('file', fileStream);
|
|
326
|
-
|
|
332
|
+
const headers = {
|
|
333
|
+
'Content-Type': 'multipart/form-data'
|
|
334
|
+
};
|
|
335
|
+
return this.client.post(`/campaigns/${campaignId}/importCSV`, form, undefined, headers);
|
|
327
336
|
}
|
|
328
337
|
/**
|
|
329
338
|
* @see https://docs.voucherify.io/reference/enable-campaign
|
|
@@ -584,7 +593,10 @@ class Vouchers {
|
|
|
584
593
|
const fileStream = fs.createReadStream(filePath);
|
|
585
594
|
const form = new FormData();
|
|
586
595
|
form.append('file', fileStream);
|
|
587
|
-
|
|
596
|
+
const headers = {
|
|
597
|
+
'Content-Type': 'multipart/form-data'
|
|
598
|
+
};
|
|
599
|
+
return this.client.post('/vouchers/importCSV', form, undefined, headers);
|
|
588
600
|
}
|
|
589
601
|
/**
|
|
590
602
|
* @see https://docs.voucherify.io/reference/list-voucher-transactions
|
|
@@ -954,7 +966,10 @@ class Customers {
|
|
|
954
966
|
const fileStream = fs.createReadStream(filePath);
|
|
955
967
|
const form = new FormData();
|
|
956
968
|
form.append('file', fileStream);
|
|
957
|
-
|
|
969
|
+
const headers = {
|
|
970
|
+
'Content-Type': 'multipart/form-data'
|
|
971
|
+
};
|
|
972
|
+
return this.client.post(`/customers/importCSV`, form, undefined, headers);
|
|
958
973
|
}
|
|
959
974
|
|
|
960
975
|
}
|
|
@@ -1135,7 +1150,10 @@ class Products {
|
|
|
1135
1150
|
const fileStream = fs.createReadStream(filePath);
|
|
1136
1151
|
const form = new FormData();
|
|
1137
1152
|
form.append('file', fileStream);
|
|
1138
|
-
|
|
1153
|
+
const headers = {
|
|
1154
|
+
'Content-Type': 'multipart/form-data'
|
|
1155
|
+
};
|
|
1156
|
+
return this.client.post(`/skus/importCSV`, form, undefined, headers);
|
|
1139
1157
|
}
|
|
1140
1158
|
/**
|
|
1141
1159
|
* @see https://docs.voucherify.io/reference/import-products-using-csv
|
|
@@ -1148,7 +1166,10 @@ class Products {
|
|
|
1148
1166
|
const fileStream = fs.createReadStream(filePath);
|
|
1149
1167
|
const form = new FormData();
|
|
1150
1168
|
form.append('file', fileStream);
|
|
1151
|
-
|
|
1169
|
+
const headers = {
|
|
1170
|
+
'Content-Type': 'multipart/form-data'
|
|
1171
|
+
};
|
|
1172
|
+
return this.client.post(`/products/importCSV`, form, undefined, headers);
|
|
1152
1173
|
}
|
|
1153
1174
|
|
|
1154
1175
|
}
|
|
@@ -1875,6 +1896,22 @@ class ProductCollections {
|
|
|
1875
1896
|
|
|
1876
1897
|
}
|
|
1877
1898
|
|
|
1899
|
+
class Qualifications {
|
|
1900
|
+
constructor(client) {
|
|
1901
|
+
this.client = void 0;
|
|
1902
|
+
this.client = client;
|
|
1903
|
+
}
|
|
1904
|
+
/**
|
|
1905
|
+
* @see https://docs.voucherify.io/reference/check-eligibility
|
|
1906
|
+
*/
|
|
1907
|
+
|
|
1908
|
+
|
|
1909
|
+
checkEligibility(body) {
|
|
1910
|
+
return this.client.post('/qualifications', body);
|
|
1911
|
+
}
|
|
1912
|
+
|
|
1913
|
+
}
|
|
1914
|
+
|
|
1878
1915
|
// apiLimitsHandler: ApiLimitsHandler
|
|
1879
1916
|
// campaigns: Campaigns
|
|
1880
1917
|
// consents: Consents
|
|
@@ -1905,7 +1942,7 @@ function VoucherifyServerSide(options) {
|
|
|
1905
1942
|
let headers = {
|
|
1906
1943
|
'X-App-Id': options.applicationId,
|
|
1907
1944
|
'X-App-Token': options.secretKey,
|
|
1908
|
-
'X-Voucherify-Channel': options.channel || `${environment()}-SDK-v${"2.
|
|
1945
|
+
'X-Voucherify-Channel': options.channel || `${environment()}-SDK-v${"2.7.0"}`,
|
|
1909
1946
|
'Content-Type': 'application/json'
|
|
1910
1947
|
};
|
|
1911
1948
|
|
|
@@ -1947,6 +1984,7 @@ function VoucherifyServerSide(options) {
|
|
|
1947
1984
|
const promotions = new Promotions(client, promotionTiers, promotionStack);
|
|
1948
1985
|
const validations = new Validations(client, promotions);
|
|
1949
1986
|
const redemptions = new Redemptions(client);
|
|
1987
|
+
const qualifications = new Qualifications(client);
|
|
1950
1988
|
const customers = new Customers(client);
|
|
1951
1989
|
const consents = new Consents(client);
|
|
1952
1990
|
const orders = new Orders(client);
|
|
@@ -1971,6 +2009,7 @@ function VoucherifyServerSide(options) {
|
|
|
1971
2009
|
orders,
|
|
1972
2010
|
products,
|
|
1973
2011
|
productCollections,
|
|
2012
|
+
qualifications,
|
|
1974
2013
|
rewards,
|
|
1975
2014
|
loyalties,
|
|
1976
2015
|
segments,
|
|
@@ -2147,6 +2186,14 @@ class ClientSide {
|
|
|
2147
2186
|
redeemStackable(params) {
|
|
2148
2187
|
return this.client.post(`/redemptions`, params);
|
|
2149
2188
|
}
|
|
2189
|
+
/**
|
|
2190
|
+
* @see https://docs.voucherify.io/reference/check-eligibility
|
|
2191
|
+
*/
|
|
2192
|
+
|
|
2193
|
+
|
|
2194
|
+
qualifications(body) {
|
|
2195
|
+
return this.client.post('/qualifications', body);
|
|
2196
|
+
}
|
|
2150
2197
|
|
|
2151
2198
|
}
|
|
2152
2199
|
|
|
@@ -2161,7 +2208,7 @@ function VoucherifyClientSide(options) {
|
|
|
2161
2208
|
let headers = {
|
|
2162
2209
|
'X-Client-Application-Id': options.clientApplicationId,
|
|
2163
2210
|
'X-Client-Token': options.clientSecretKey,
|
|
2164
|
-
'X-Voucherify-Channel': `${environment()}-ClientSide-SDK-v${"2.
|
|
2211
|
+
'X-Voucherify-Channel': `${environment()}-ClientSide-SDK-v${"2.7.0"}`
|
|
2165
2212
|
};
|
|
2166
2213
|
|
|
2167
2214
|
if (environment().startsWith('Node')) {
|