@voucherify/sdk 1.2.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 +110 -0
- package/README.md +1258 -0
- package/dist/AsyncActions.d.ts +15 -0
- package/dist/Balance.d.ts +12 -0
- package/dist/Campaigns.d.ts +45 -0
- package/dist/ClientSide.d.ts +40 -0
- package/dist/Consents.d.ts +10 -0
- package/dist/Customers.d.ts +43 -0
- package/dist/Distributions.d.ts +22 -0
- package/dist/Events.d.ts +7 -0
- package/dist/Exports.d.ts +18 -0
- package/dist/Loyalties.d.ts +82 -0
- package/dist/Orders.d.ts +22 -0
- package/dist/Products.d.ts +54 -0
- package/dist/PromotionTiers.d.ts +30 -0
- package/dist/Promotions.d.ts +16 -0
- package/dist/Redemptions.d.ts +26 -0
- package/dist/RequestController.d.ts +20 -0
- package/dist/Rewards.d.ts +39 -0
- package/dist/Segments.d.ts +22 -0
- package/dist/ValidationRules.d.ts +39 -0
- package/dist/Validations.d.ts +13 -0
- package/dist/VoucherifyClientSide.d.ts +76 -0
- package/dist/VoucherifyError.d.ts +6 -0
- package/dist/VoucherifyServerSide.d.ts +111 -0
- package/dist/Vouchers.d.ts +64 -0
- package/dist/helpers.d.ts +19 -0
- package/dist/index.d.ts +24 -0
- package/dist/types/AsyncActions.d.ts +18 -0
- package/dist/types/Balance.d.ts +14 -0
- package/dist/types/Campaigns.d.ts +117 -0
- package/dist/types/ClientSide.d.ts +135 -0
- package/dist/types/Consents.d.ts +33 -0
- package/dist/types/Customers.d.ts +113 -0
- package/dist/types/Distributions.d.ts +141 -0
- package/dist/types/Events.d.ts +17 -0
- package/dist/types/Exports.d.ts +30 -0
- package/dist/types/Loyalties.d.ts +462 -0
- package/dist/types/Orders.d.ts +61 -0
- package/dist/types/Products.d.ts +97 -0
- package/dist/types/PromotionTiers.d.ts +107 -0
- package/dist/types/Promotions.d.ts +90 -0
- package/dist/types/Redemptions.d.ts +150 -0
- package/dist/types/Rewards.d.ts +114 -0
- package/dist/types/Segments.d.ts +32 -0
- package/dist/types/ValidationRules.d.ts +74 -0
- package/dist/types/Validations.d.ts +66 -0
- package/dist/types/Vouchers.d.ts +227 -0
- package/dist/types/index.d.ts +19 -0
- package/dist/voucherifysdk.esm.js +1567 -0
- package/dist/voucherifysdk.esm.js.map +1 -0
- package/dist/voucherifysdk.umd.development.js +1578 -0
- package/dist/voucherifysdk.umd.development.js.map +1 -0
- package/dist/voucherifysdk.umd.production.min.js +2 -0
- package/dist/voucherifysdk.umd.production.min.js.map +1 -0
- package/package.json +48 -0
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import { ClientSide } from './ClientSide';
|
|
2
|
+
export type { ClientSide };
|
|
3
|
+
export interface VoucherifyClientSideOptions {
|
|
4
|
+
/**
|
|
5
|
+
* Optionally, you can add `apiUrl` to the client options if you want to use Voucherify running in a specific region.
|
|
6
|
+
*
|
|
7
|
+
* ```javascript
|
|
8
|
+
* const client = VoucherifyClientSide({
|
|
9
|
+
* clientApplicationId: 'YOUR-CLIENT-APPLICATION-ID',
|
|
10
|
+
* clientSecretKey: 'YOUR-CLIENT-SECRET-KEY',
|
|
11
|
+
* apiUrl: 'https://<region>.api.voucherify.io'
|
|
12
|
+
* })
|
|
13
|
+
* ```
|
|
14
|
+
*/
|
|
15
|
+
apiUrl?: string;
|
|
16
|
+
/**
|
|
17
|
+
* [Log-in](http://app.voucherify.io/?utm_source=github&utm_medium=sdk&utm_campaign=acq#/login) to Voucherify web interface and obtain your `Client-side Keys` from [Configuration](https://app.voucherify.io/?utm_source=github&utm_medium=sdk&utm_campaign=acq#/app/configuration):
|
|
18
|
+
*
|
|
19
|
+
* ```javascript
|
|
20
|
+
* const client = VoucherifyClientSide({
|
|
21
|
+
* clientApplicationId: 'YOUR-CLIENT-APPLICATION-ID',
|
|
22
|
+
* clientSecretKey: 'YOUR-CLIENT-SECRET-KEY'
|
|
23
|
+
* })
|
|
24
|
+
* ```
|
|
25
|
+
*/
|
|
26
|
+
clientApplicationId: string;
|
|
27
|
+
/**
|
|
28
|
+
* [Log-in](http://app.voucherify.io/?utm_source=github&utm_medium=sdk&utm_campaign=acq#/login) to Voucherify web interface and obtain your `Client-side Keys` from [Configuration](https://app.voucherify.io/?utm_source=github&utm_medium=sdk&utm_campaign=acq#/app/configuration):
|
|
29
|
+
*
|
|
30
|
+
* ```javascript
|
|
31
|
+
* const client = VoucherifyClientSide({
|
|
32
|
+
* clientApplicationId: 'YOUR-CLIENT-APPLICATION-ID',
|
|
33
|
+
* clientSecretKey: 'YOUR-CLIENT-SECRET-KEY'
|
|
34
|
+
* })
|
|
35
|
+
* ```
|
|
36
|
+
*/
|
|
37
|
+
clientSecretKey: string;
|
|
38
|
+
/**
|
|
39
|
+
* Set customer identity when using React Widget. In other situations, use `setIdentity` method:
|
|
40
|
+
*
|
|
41
|
+
* ```javascript
|
|
42
|
+
* client.setIdentity('gustav@purpleson.com')
|
|
43
|
+
* ```
|
|
44
|
+
*/
|
|
45
|
+
trackingId?: string;
|
|
46
|
+
/**
|
|
47
|
+
* **(Required in Node.js)** Set the origin from where the requests are made.
|
|
48
|
+
*
|
|
49
|
+
* ```javascript
|
|
50
|
+
* const client = VoucherifyClientSide({
|
|
51
|
+
* clientApplicationId: 'YOUR-CLIENT-APPLICATION-ID',
|
|
52
|
+
* clientSecretKey: 'YOUR-CLIENT-SECRET-KEY',
|
|
53
|
+
* origin: 'your-domain.com'
|
|
54
|
+
* })
|
|
55
|
+
* ```
|
|
56
|
+
*
|
|
57
|
+
* @note in the browser, this option will be ignored. The `origin` header is a [forbidden header name](https://developer.mozilla.org/en-US/docs/Glossary/Forbidden_header_name) and it'll be automatically set by the browser for every request.
|
|
58
|
+
*/
|
|
59
|
+
origin?: string;
|
|
60
|
+
/**
|
|
61
|
+
* You can pass additional headers to requests made by the API Client.
|
|
62
|
+
* It can prove to be useful when debugging various scenarios.
|
|
63
|
+
* ```javascript
|
|
64
|
+
* const voucherify = VoucherifyServerSide({
|
|
65
|
+
* clientApplicationId: 'YOUR-CLIENT-APPLICATION-ID',
|
|
66
|
+
* clientSecretKey: 'YOUR-CLIENT-SECRET-KEY',
|
|
67
|
+
* customHeaders: {
|
|
68
|
+
* "DEBUG-HEADER": "my_value",
|
|
69
|
+
* "TEST-HEADER": "another_value"
|
|
70
|
+
* }
|
|
71
|
+
* })
|
|
72
|
+
* ```
|
|
73
|
+
*/
|
|
74
|
+
customHeaders?: Record<string, string>;
|
|
75
|
+
}
|
|
76
|
+
export declare function VoucherifyClientSide(options: VoucherifyClientSideOptions): ClientSide;
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
import { AsyncActions } from './AsyncActions';
|
|
2
|
+
import { Campaigns } from './Campaigns';
|
|
3
|
+
import { Distributions } from './Distributions';
|
|
4
|
+
import { Events } from './Events';
|
|
5
|
+
import { Vouchers } from './Vouchers';
|
|
6
|
+
import { Validations } from './Validations';
|
|
7
|
+
import { Redemptions } from './Redemptions';
|
|
8
|
+
import { Promotions } from './Promotions';
|
|
9
|
+
import { Customers } from './Customers';
|
|
10
|
+
import { Consents } from './Consents';
|
|
11
|
+
import { Orders } from './Orders';
|
|
12
|
+
import { Products } from './Products';
|
|
13
|
+
import { Rewards } from './Rewards';
|
|
14
|
+
import { Loyalties } from './Loyalties';
|
|
15
|
+
import { ValidationRules } from './ValidationRules';
|
|
16
|
+
import { Segments } from './Segments';
|
|
17
|
+
export interface VoucherifyServerSideOptions {
|
|
18
|
+
/**
|
|
19
|
+
* Optionally, you can add `apiUrl` to the client options if you want to use Voucherify running in a specific region.
|
|
20
|
+
*
|
|
21
|
+
* ```javascript
|
|
22
|
+
* const voucherify = VoucherifyServerSide({
|
|
23
|
+
* applicationId: 'YOUR-APPLICATION-ID',
|
|
24
|
+
* secretKey: 'YOUR-SECRET-KEY',
|
|
25
|
+
* apiUrl: 'https://<region>.api.voucherify.io'
|
|
26
|
+
* })
|
|
27
|
+
* ```
|
|
28
|
+
*/
|
|
29
|
+
apiUrl?: string;
|
|
30
|
+
/**
|
|
31
|
+
* [Log-in](http://app.voucherify.io/?utm_source=github&utm_medium=sdk&utm_campaign=acq#/login) to Voucherify web interface and obtain your `Application Keys` from [Configuration](https://app.voucherify.io/?utm_source=github&utm_medium=sdk&utm_campaign=acq#/app/configuration):
|
|
32
|
+
*
|
|
33
|
+
* ```javascript
|
|
34
|
+
* const voucherify = VoucherifyServerSide({
|
|
35
|
+
* applicationId: 'YOUR-APPLICATION-ID',
|
|
36
|
+
* secretKey: 'YOUR-SECRET-KEY'
|
|
37
|
+
* })
|
|
38
|
+
* ```
|
|
39
|
+
*/
|
|
40
|
+
applicationId: string;
|
|
41
|
+
/**
|
|
42
|
+
* [Log-in](http://app.voucherify.io/?utm_source=github&utm_medium=sdk&utm_campaign=acq#/login) to Voucherify web interface and obtain your `Application Keys` from [Configuration](https://app.voucherify.io/?utm_source=github&utm_medium=sdk&utm_campaign=acq#/app/configuration):
|
|
43
|
+
*
|
|
44
|
+
* ```javascript
|
|
45
|
+
* const voucherify = VoucherifyServerSide({
|
|
46
|
+
* applicationId: 'YOUR-APPLICATION-ID',
|
|
47
|
+
* secretKey: 'YOUR-SECRET-KEY'
|
|
48
|
+
* })
|
|
49
|
+
* ```
|
|
50
|
+
*/
|
|
51
|
+
secretKey: string;
|
|
52
|
+
/**
|
|
53
|
+
* Optionally, you can add `apiVersion` to the client options if you want to use a [specific API version](http://docs.voucherify.io/docs/api-version-upgrades?utm_source=github&utm_medium=sdk&utm_campaign=acq).
|
|
54
|
+
*
|
|
55
|
+
* ```javascript
|
|
56
|
+
* const voucherify = VoucherifyServerSide({
|
|
57
|
+
* applicationId: 'YOUR-APPLICATION-ID',
|
|
58
|
+
* secretKey: 'YOUR-SECRET-KEY',
|
|
59
|
+
* apiVersion: 'v2017-04-20'
|
|
60
|
+
* })
|
|
61
|
+
* ```
|
|
62
|
+
*/
|
|
63
|
+
apiVersion?: string;
|
|
64
|
+
channel?: string;
|
|
65
|
+
/**
|
|
66
|
+
* Set this option to disable displaying the warning about exposing your `secretKey` if you're using VoucherifyServerSide in a browser environment.
|
|
67
|
+
* By setting this option to `true`, you acknowledge that you understand the risks of exposing your `secretKey` to a browser environment.
|
|
68
|
+
*
|
|
69
|
+
* ```javascript
|
|
70
|
+
* const voucherify = VoucherifyServerSide({
|
|
71
|
+
* applicationId: 'YOUR-APPLICATION-ID',
|
|
72
|
+
* secretKey: 'YOUR-SECRET-KEY',
|
|
73
|
+
* dangerouslySetSecretKeyInBrowser: true
|
|
74
|
+
* })
|
|
75
|
+
* ```
|
|
76
|
+
*/
|
|
77
|
+
dangerouslySetSecretKeyInBrowser?: boolean;
|
|
78
|
+
/**
|
|
79
|
+
* You can pass additional headers to requests made by the API Client.
|
|
80
|
+
* It can prove to be useful when debugging various scenarios.
|
|
81
|
+
* ```javascript
|
|
82
|
+
* const voucherify = VoucherifyServerSide({
|
|
83
|
+
* applicationId: 'YOUR-APPLICATION-ID',
|
|
84
|
+
* secretKey: 'YOUR-SECRET-KEY',
|
|
85
|
+
* customHeaders: {
|
|
86
|
+
* "DEBUG-HEADER": "my_value",
|
|
87
|
+
* "TEST-HEADER": "another_value"
|
|
88
|
+
* }
|
|
89
|
+
* })
|
|
90
|
+
* ```
|
|
91
|
+
*/
|
|
92
|
+
customHeaders?: Record<string, string>;
|
|
93
|
+
}
|
|
94
|
+
export declare function VoucherifyServerSide(options: VoucherifyServerSideOptions): {
|
|
95
|
+
vouchers: Vouchers;
|
|
96
|
+
campaigns: Campaigns;
|
|
97
|
+
distributions: Distributions;
|
|
98
|
+
validations: Validations;
|
|
99
|
+
redemptions: Redemptions;
|
|
100
|
+
promotions: Promotions;
|
|
101
|
+
customers: Customers;
|
|
102
|
+
consents: Consents;
|
|
103
|
+
orders: Orders;
|
|
104
|
+
products: Products;
|
|
105
|
+
rewards: Rewards;
|
|
106
|
+
loyalties: Loyalties;
|
|
107
|
+
segments: Segments;
|
|
108
|
+
validationRules: ValidationRules;
|
|
109
|
+
events: Events;
|
|
110
|
+
asyncActions: AsyncActions;
|
|
111
|
+
};
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import * as T from './types/Vouchers';
|
|
2
|
+
import type { RequestController } from './RequestController';
|
|
3
|
+
import type { Balance } from './Balance';
|
|
4
|
+
declare class VouchersQualification {
|
|
5
|
+
private client;
|
|
6
|
+
constructor(client: RequestController);
|
|
7
|
+
/**
|
|
8
|
+
* The method can be used for sending a request to display all vouchers qualified to the given customer and context (e.g., order, loyalty reward). A checking logic won't run among coupons from bulk unique codes campaigns. For campaigns with multiple unique codes, you should run a dedicated function for searching for qualified campaigns.
|
|
9
|
+
* As a sample use case, you can imagine a requirement of displaying below cart the coupons eligible to a customer. The customer can take and apply the proposed voucher.
|
|
10
|
+
* @see https://docs.voucherify.io/reference?utm_source=github&utm_medium=sdk&utm_campaign=acq#push-qualification-request
|
|
11
|
+
*/
|
|
12
|
+
examine(body: T.VouchersQualificationExamineBody, params?: T.VouchersQualificationExamineParams): Promise<T.VouchersQualificationExamineResponse>;
|
|
13
|
+
}
|
|
14
|
+
export declare class Vouchers {
|
|
15
|
+
private client;
|
|
16
|
+
balance: Balance;
|
|
17
|
+
qualifications: VouchersQualification;
|
|
18
|
+
constructor(client: RequestController, balance: Balance);
|
|
19
|
+
/**
|
|
20
|
+
* @see https://docs.voucherify.io/reference?utm_source=github&utm_medium=sdk&utm_campaign=acq#create-voucher
|
|
21
|
+
*/
|
|
22
|
+
create(voucher: T.VouchersCreate): Promise<Pick<T.VouchersResponse, "object" | "type" | "discount" | "gift" | "category" | "additional_info" | "start_date" | "expiration_date" | "metadata" | "id" | "code" | "campaign" | "loyalty_card" | "validity_timeframe" | "validity_day_of_week" | "publish" | "redemption" | "active" | "assets" | "is_referral_code" | "referrer_id" | "holder_id" | "updated_at">>;
|
|
23
|
+
/**
|
|
24
|
+
* @see https://docs.voucherify.io/reference?utm_source=github&utm_medium=sdk&utm_campaign=acq#vouchers-get
|
|
25
|
+
*/
|
|
26
|
+
get(code: string): Promise<T.VouchersResponse>;
|
|
27
|
+
/**
|
|
28
|
+
* @see https://docs.voucherify.io/reference?utm_source=github&utm_medium=sdk&utm_campaign=acq#update-voucher
|
|
29
|
+
*/
|
|
30
|
+
update(voucher: T.VouchersUpdate): Promise<T.VouchersResponse>;
|
|
31
|
+
/**
|
|
32
|
+
* @see https://docs.voucherify.io/reference?utm_source=github&utm_medium=sdk&utm_campaign=acq#delete-voucher
|
|
33
|
+
*/
|
|
34
|
+
delete(code: string, params?: T.VouchersDeleteParams): Promise<unknown>;
|
|
35
|
+
/**
|
|
36
|
+
* @see https://docs.voucherify.io/reference?utm_source=github&utm_medium=sdk&utm_campaign=acq#list-vouchers
|
|
37
|
+
*/
|
|
38
|
+
list(params?: T.VouchersListParams): Promise<T.VouchersListResponse>;
|
|
39
|
+
/**
|
|
40
|
+
* @see https://docs.voucherify.io/reference?utm_source=github&utm_medium=sdk&utm_campaign=acq#enable-voucher
|
|
41
|
+
*/
|
|
42
|
+
enable(code: string): Promise<T.VouchersResponse>;
|
|
43
|
+
/**
|
|
44
|
+
* @see https://docs.voucherify.io/reference?utm_source=github&utm_medium=sdk&utm_campaign=acq#disable-voucher
|
|
45
|
+
*/
|
|
46
|
+
disable(code: string): Promise<T.VouchersResponse>;
|
|
47
|
+
/**
|
|
48
|
+
* @see https://docs.voucherify.io/reference?utm_source=github&utm_medium=sdk&utm_campaign=acq#import-vouchers-1
|
|
49
|
+
*/
|
|
50
|
+
import(vouchers: T.VouchersImport[]): Promise<unknown>;
|
|
51
|
+
/**
|
|
52
|
+
* @see https://docs.voucherify.io/reference?utm_source=github&utm_medium=sdk&utm_campaign=acq#update-vouchers-metadata-in-bulk
|
|
53
|
+
*/
|
|
54
|
+
bulkUpdateMetadata(params: T.VouchersBulkUpdateMetadata): Promise<T.VouchersBulkUpdateMetadataResponse>;
|
|
55
|
+
/**
|
|
56
|
+
* @see https://docs.voucherify.io/reference?utm_source=github&utm_medium=sdk&utm_campaign=acq#update-vouchers-in-bulk
|
|
57
|
+
*/
|
|
58
|
+
bulkUpdate(vouchers: T.VouchersBulkUpdate): Promise<T.VouchersBulkUpdateResponse>;
|
|
59
|
+
/**
|
|
60
|
+
* @see https://docs.voucherify.io/reference?utm_source=github&utm_medium=sdk&utm_campaign=acq#release-validation-session
|
|
61
|
+
*/
|
|
62
|
+
releaseValidationSession(code: string, sessionKey: string): Promise<unknown>;
|
|
63
|
+
}
|
|
64
|
+
export {};
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
export declare function encode(value?: string): string;
|
|
2
|
+
export declare function isNumber(value: any): value is number;
|
|
3
|
+
export declare function isString(value: any): value is string;
|
|
4
|
+
export declare function isOptionalString(value: any): value is string | undefined;
|
|
5
|
+
export declare function isObject<T extends Record<string, any> = Record<string, any>>(value: any): value is T;
|
|
6
|
+
export declare function isOptionalObject<T extends Record<string, any> = Record<string, any>>(value: any): value is T | null | undefined;
|
|
7
|
+
export declare function isFunction(value: any): value is Function;
|
|
8
|
+
export declare function exists<T extends any>(value: T): value is NonNullable<T>;
|
|
9
|
+
export declare function environment(): string;
|
|
10
|
+
export declare function assert(condition: any, message?: string): asserts condition;
|
|
11
|
+
export declare function toQueryParams(obj: Record<string, unknown>): Record<string, string>;
|
|
12
|
+
/**
|
|
13
|
+
* Return an object containing all properties of `obj` excluding the ones in `keys` array
|
|
14
|
+
* e.g:
|
|
15
|
+
* ```javascript
|
|
16
|
+
* omit({ a: 1, b: 2, c: 3, d: 4 }, ['b', 'd']) // output: { a: 1, c: 3 }
|
|
17
|
+
* ```
|
|
18
|
+
*/
|
|
19
|
+
export declare function omit<T extends {}, K extends keyof T>(obj: T, keys: K[]): Omit<T, K>;
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
export * from './types';
|
|
2
|
+
export * from './VoucherifyServerSide';
|
|
3
|
+
export * from './VoucherifyClientSide';
|
|
4
|
+
export type { Balance } from './Balance';
|
|
5
|
+
export type { Campaigns } from './Campaigns';
|
|
6
|
+
export type { ClientSide } from './ClientSide';
|
|
7
|
+
export type { Consents } from './Consents';
|
|
8
|
+
export type { Customers } from './Customers';
|
|
9
|
+
export type { Distributions } from './Distributions';
|
|
10
|
+
export type { Events } from './Events';
|
|
11
|
+
export type { Exports } from './Exports';
|
|
12
|
+
export type { Loyalties } from './Loyalties';
|
|
13
|
+
export type { Orders } from './Orders';
|
|
14
|
+
export type { Products } from './Products';
|
|
15
|
+
export type { Promotions } from './Promotions';
|
|
16
|
+
export type { PromotionTiers } from './PromotionTiers';
|
|
17
|
+
export type { Redemptions } from './Redemptions';
|
|
18
|
+
export type { RequestController } from './RequestController';
|
|
19
|
+
export type { Rewards } from './Rewards';
|
|
20
|
+
export type { Segments } from './Segments';
|
|
21
|
+
export type { ValidationRules } from './ValidationRules';
|
|
22
|
+
export type { Validations } from './Validations';
|
|
23
|
+
export type { VoucherifyError } from './VoucherifyError';
|
|
24
|
+
export type { Vouchers } from './Vouchers';
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
export interface AsyncActionsResponse {
|
|
2
|
+
id: string;
|
|
3
|
+
type: string;
|
|
4
|
+
status: string;
|
|
5
|
+
result: object;
|
|
6
|
+
created_at: string;
|
|
7
|
+
object: 'async_action';
|
|
8
|
+
}
|
|
9
|
+
export interface AsyncActionsListParams {
|
|
10
|
+
limit?: number;
|
|
11
|
+
end_date?: string;
|
|
12
|
+
}
|
|
13
|
+
export interface AsyncActionsListResponse {
|
|
14
|
+
object: 'list';
|
|
15
|
+
data_ref: 'async_actions';
|
|
16
|
+
async_actions: Omit<AsyncActionsResponse, 'result'>[];
|
|
17
|
+
}
|
|
18
|
+
export declare type AsyncActionsGetResponse = AsyncActionsResponse;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export interface BalanceCreateParams {
|
|
2
|
+
amount: number;
|
|
3
|
+
}
|
|
4
|
+
export interface BalanceCreateResponse {
|
|
5
|
+
amount: number;
|
|
6
|
+
total: number;
|
|
7
|
+
balance: number;
|
|
8
|
+
type: string;
|
|
9
|
+
object: 'balance';
|
|
10
|
+
related_object: {
|
|
11
|
+
type: string;
|
|
12
|
+
id: string;
|
|
13
|
+
};
|
|
14
|
+
}
|
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
import { SimpleVoucher, VouchersImport, VouchersResponse } from './Vouchers';
|
|
2
|
+
import { CustomerRequest } from './Customers';
|
|
3
|
+
import { OrdersGetResponse } from './Orders';
|
|
4
|
+
import { ValidationRulesCreateAssignmentResponse } from './ValidationRules';
|
|
5
|
+
interface ReferralProgramCustomEventRedemption {
|
|
6
|
+
conversion_event_type: 'custom_event';
|
|
7
|
+
custom_event: {
|
|
8
|
+
id: string;
|
|
9
|
+
name: string;
|
|
10
|
+
};
|
|
11
|
+
referee_reward?: {
|
|
12
|
+
related_object_parent: {
|
|
13
|
+
id: string;
|
|
14
|
+
name: string;
|
|
15
|
+
object: 'CAMPAIGN';
|
|
16
|
+
};
|
|
17
|
+
amount: number;
|
|
18
|
+
type: 'GIFT_VOUCHER' | 'LOYALTY_CARD';
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
interface ReferralProgramRedemption {
|
|
22
|
+
conversion_event_type: 'redemption';
|
|
23
|
+
referee_reward?: {
|
|
24
|
+
related_object_parent: {
|
|
25
|
+
id: string;
|
|
26
|
+
name: string;
|
|
27
|
+
object: 'CAMPAIGN';
|
|
28
|
+
};
|
|
29
|
+
amount: number;
|
|
30
|
+
type: 'GIFT_VOUCHER' | 'LOYALTY_CARD';
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
export interface CampaignResponse {
|
|
34
|
+
id: string;
|
|
35
|
+
name: string;
|
|
36
|
+
campaign_type: 'LOYALTY_PROGRAM' | 'PROMOTION' | 'DISCOUNT_COUPONS' | 'GIFT_VOUCHERS' | 'REFERRAL_PROGRAM';
|
|
37
|
+
type: 'AUTO_UPDATE' | 'STATIC';
|
|
38
|
+
category?: string;
|
|
39
|
+
auto_join?: boolean;
|
|
40
|
+
join_once?: boolean;
|
|
41
|
+
description?: string;
|
|
42
|
+
start_date?: string;
|
|
43
|
+
validation_rules_assignments: {
|
|
44
|
+
data?: ValidationRulesCreateAssignmentResponse[];
|
|
45
|
+
object: 'list';
|
|
46
|
+
total: number;
|
|
47
|
+
data_ref: 'data';
|
|
48
|
+
};
|
|
49
|
+
expiration_date?: string;
|
|
50
|
+
activity_duration_after_publishing?: string;
|
|
51
|
+
validity_timeframe?: {
|
|
52
|
+
interval?: string;
|
|
53
|
+
duration?: string;
|
|
54
|
+
};
|
|
55
|
+
validity_day_of_week?: number[];
|
|
56
|
+
metadata?: Record<string, any>;
|
|
57
|
+
created_at: string;
|
|
58
|
+
vouchers_generation_status: 'IN_PROGRESS' | 'DONE' | 'FAILED' | 'DRAFT';
|
|
59
|
+
active: boolean;
|
|
60
|
+
voucher?: SimpleVoucher;
|
|
61
|
+
referral_program?: ReferralProgramCustomEventRedemption | ReferralProgramRedemption;
|
|
62
|
+
use_voucher_metadata_schema?: boolean;
|
|
63
|
+
protected?: boolean;
|
|
64
|
+
vouchers_count?: number;
|
|
65
|
+
object: 'campaign';
|
|
66
|
+
}
|
|
67
|
+
export interface CampaignsQualificationsBody {
|
|
68
|
+
customer?: CustomerRequest;
|
|
69
|
+
order?: Pick<OrdersGetResponse, 'id' | 'source_id' | 'items'>;
|
|
70
|
+
}
|
|
71
|
+
export interface CampaignsQualificationsParams {
|
|
72
|
+
audienceRulesOnly?: boolean;
|
|
73
|
+
order?: 'created_at' | '-created_at' | 'updated_at' | '-updated_at';
|
|
74
|
+
limit?: number;
|
|
75
|
+
}
|
|
76
|
+
export interface CampaignsQualificationsResponse {
|
|
77
|
+
object: 'list';
|
|
78
|
+
total: number;
|
|
79
|
+
data_ref: 'data';
|
|
80
|
+
data: CampaignResponse[];
|
|
81
|
+
id?: string;
|
|
82
|
+
created_at?: string;
|
|
83
|
+
}
|
|
84
|
+
export declare type CampaignsCreateCampaign = Omit<CampaignResponse, 'id' | 'protected' | 'vouchers_generation_status' | 'validation_rules_assignments' | 'object' | 'created_at' | 'active'> & {
|
|
85
|
+
active?: boolean;
|
|
86
|
+
};
|
|
87
|
+
export declare type CampaignsUpdateCampaign = Pick<CampaignResponse, 'start_date' | 'expiration_date' | 'type' | 'description' | 'metadata'>;
|
|
88
|
+
export interface CampaignsDeleteParams {
|
|
89
|
+
force?: boolean;
|
|
90
|
+
}
|
|
91
|
+
export declare type CampaignsAddVoucherBody = Pick<Partial<VouchersImport>, 'code_config' | 'category' | 'redemption' | 'metadata' | 'additional_info'>;
|
|
92
|
+
export interface CampaignsAddVoucherParams {
|
|
93
|
+
vouchers_count?: number;
|
|
94
|
+
}
|
|
95
|
+
export declare type CampaignsAddCertainVoucherParams = Pick<Partial<VouchersImport>, 'category' | 'redemption' | 'metadata' | 'additional_info'>;
|
|
96
|
+
export declare type CampaignsAddVoucherResponse = Pick<VouchersResponse, 'code' | 'object' | 'campaign' | 'category' | 'type' | 'discount' | 'gift' | 'start_date' | 'expiration_date' | 'publish' | 'redemption' | 'active' | 'additional_info' | 'metadata'>;
|
|
97
|
+
export declare type CampaignsAddCertainVoucherResponse = CampaignsAddVoucherResponse;
|
|
98
|
+
export declare type CampaignsImportVouchers = Pick<VouchersImport, 'code' | 'redemption' | 'metadata' | 'additional_info' | 'active'>;
|
|
99
|
+
export interface CampaignsListParams {
|
|
100
|
+
limit?: number;
|
|
101
|
+
page?: number;
|
|
102
|
+
campaign_type?: 'DISCOUNT_COUPONS' | 'PROMOTION' | 'GIFT_VOUCHERS' | 'REFERRAL_PROGRAM';
|
|
103
|
+
filters?: {
|
|
104
|
+
junction?: string;
|
|
105
|
+
[filter_condition: string]: any;
|
|
106
|
+
};
|
|
107
|
+
}
|
|
108
|
+
export interface CampaignsListResponse {
|
|
109
|
+
object: 'list';
|
|
110
|
+
total: number;
|
|
111
|
+
data_ref: 'campaigns';
|
|
112
|
+
campaigns: CampaignResponse[];
|
|
113
|
+
}
|
|
114
|
+
export declare type CampaignsCreateCampaignResponse = CampaignResponse;
|
|
115
|
+
export declare type CampaignsUpdateCampaignResponse = CampaignResponse;
|
|
116
|
+
export declare type CampaignsGetCampaignResponse = CampaignResponse;
|
|
117
|
+
export {};
|
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
import { CustomerRequest, CustomersCreateBody, CustomersCreateResponse, CustomersUpdateConsentsBody } from './Customers';
|
|
2
|
+
import { DiscountAmount, DiscountPercent, DiscountUnit, VouchersListParams, VouchersResponse } from './Vouchers';
|
|
3
|
+
import { OrdersCreateResponse, OrdersItem } from './Orders';
|
|
4
|
+
import { ConsentsListResponse } from './Consents';
|
|
5
|
+
import { DistributionsPublicationsCreateResponse } from './Distributions';
|
|
6
|
+
import { SimplePromotionTier } from './PromotionTiers';
|
|
7
|
+
declare type ClientSideItem = Pick<OrdersItem, 'source_id' | 'sku_id' | 'product_id' | 'sku' | 'quantity' | 'related_object' | 'amount'>;
|
|
8
|
+
export declare type ClientSideCustomersUpdateConsentsBody = CustomersUpdateConsentsBody;
|
|
9
|
+
export declare type ClientSideCustomersCreateParams = CustomersCreateBody;
|
|
10
|
+
export declare type ClientSideCustomersCreateResponse = CustomersCreateResponse;
|
|
11
|
+
export interface ClientSideValidateParams {
|
|
12
|
+
code?: string;
|
|
13
|
+
tracking_id?: string;
|
|
14
|
+
amount?: number;
|
|
15
|
+
items?: ClientSideItem[];
|
|
16
|
+
orderMetadata?: Record<string, any>;
|
|
17
|
+
customer?: Pick<CustomerRequest, 'source_id' | 'metadata'>;
|
|
18
|
+
reward?: {
|
|
19
|
+
id: string;
|
|
20
|
+
};
|
|
21
|
+
metadata?: Record<string, any>;
|
|
22
|
+
session_type?: 'LOCK';
|
|
23
|
+
session_key?: string;
|
|
24
|
+
session_ttl?: number;
|
|
25
|
+
session_ttl_unit?: 'MILLISECONDS' | 'SECONDS' | 'MINUTES' | 'HOURS' | 'DAYS';
|
|
26
|
+
}
|
|
27
|
+
export declare type ClientSideListVouchersParams = VouchersListParams;
|
|
28
|
+
export declare type ClientSideVoucherListing = Pick<VouchersResponse, 'active' | 'code' | 'metadata' | 'assets' | 'object' | 'expiration_date' | 'start_date'>;
|
|
29
|
+
export interface ClientSideListVouchersResponse {
|
|
30
|
+
object: 'list';
|
|
31
|
+
total: number;
|
|
32
|
+
data_ref: 'vouchers';
|
|
33
|
+
vouchers: ClientSideVoucherListing[];
|
|
34
|
+
}
|
|
35
|
+
export interface ClientSideValidateResponse {
|
|
36
|
+
code?: string;
|
|
37
|
+
valid: boolean;
|
|
38
|
+
discount?: DiscountUnit | DiscountAmount | DiscountPercent;
|
|
39
|
+
applicable_to?: {
|
|
40
|
+
object: 'list';
|
|
41
|
+
total: number;
|
|
42
|
+
data?: {
|
|
43
|
+
id: string;
|
|
44
|
+
object: 'product';
|
|
45
|
+
source_id?: string;
|
|
46
|
+
}[];
|
|
47
|
+
};
|
|
48
|
+
order?: {
|
|
49
|
+
amount: number;
|
|
50
|
+
discount_amount: number;
|
|
51
|
+
total_discount_amount: number;
|
|
52
|
+
total_amount: number;
|
|
53
|
+
items?: ClientSideItem[];
|
|
54
|
+
};
|
|
55
|
+
tracking_id?: string;
|
|
56
|
+
campaign_id?: string;
|
|
57
|
+
loyalty?: {
|
|
58
|
+
points_cost: number;
|
|
59
|
+
};
|
|
60
|
+
gift?: {
|
|
61
|
+
amount: number;
|
|
62
|
+
balance: number;
|
|
63
|
+
};
|
|
64
|
+
promotions?: SimplePromotionTier[];
|
|
65
|
+
}
|
|
66
|
+
export interface ClientSideRedeemPayload {
|
|
67
|
+
tracking_id?: string;
|
|
68
|
+
customer?: CustomerRequest;
|
|
69
|
+
order?: ClientSideRedeemOrder;
|
|
70
|
+
metadata?: Record<string, any>;
|
|
71
|
+
reward?: {
|
|
72
|
+
id: string;
|
|
73
|
+
};
|
|
74
|
+
session?: {
|
|
75
|
+
key: string;
|
|
76
|
+
};
|
|
77
|
+
}
|
|
78
|
+
export interface ClientSideRedeemResponse {
|
|
79
|
+
id: string;
|
|
80
|
+
object: 'redemption';
|
|
81
|
+
date?: string;
|
|
82
|
+
customer_id?: string;
|
|
83
|
+
tracking_id?: string;
|
|
84
|
+
order?: OrdersCreateResponse;
|
|
85
|
+
metadata?: Record<string, any>;
|
|
86
|
+
result: 'SUCCESS' | 'FAILURE';
|
|
87
|
+
voucher?: VouchersResponse;
|
|
88
|
+
}
|
|
89
|
+
export interface ClientSidePublishPayload {
|
|
90
|
+
source_id?: string;
|
|
91
|
+
channel?: 'Voucherify.js' | string;
|
|
92
|
+
customer?: CustomerRequest;
|
|
93
|
+
voucher?: string;
|
|
94
|
+
metadata?: Record<string, any>;
|
|
95
|
+
}
|
|
96
|
+
export declare type ClientSidePublishPreparedPayload = ClientSidePublishPayload;
|
|
97
|
+
export interface ClientSidePublishQueryParams {
|
|
98
|
+
join_once?: boolean;
|
|
99
|
+
campaign?: string;
|
|
100
|
+
}
|
|
101
|
+
export interface ClientSidePublishCampaign {
|
|
102
|
+
name: string;
|
|
103
|
+
count?: number;
|
|
104
|
+
}
|
|
105
|
+
export declare type ClientSidePublishResponse = DistributionsPublicationsCreateResponse & {
|
|
106
|
+
vouchers_id?: string[];
|
|
107
|
+
};
|
|
108
|
+
export interface ClientSideTrackLoyalty {
|
|
109
|
+
code?: string;
|
|
110
|
+
}
|
|
111
|
+
export interface ClientSideTrackReferral {
|
|
112
|
+
code?: string;
|
|
113
|
+
}
|
|
114
|
+
export interface ClientSideTrackPayload {
|
|
115
|
+
event: string;
|
|
116
|
+
metadata?: Record<string, any>;
|
|
117
|
+
customer: CustomerRequest;
|
|
118
|
+
loyalty?: ClientSideTrackLoyalty;
|
|
119
|
+
referral?: ClientSideTrackReferral;
|
|
120
|
+
}
|
|
121
|
+
export interface ClientSideTrackResponse {
|
|
122
|
+
object: 'event';
|
|
123
|
+
type: string;
|
|
124
|
+
}
|
|
125
|
+
export declare type ClientSideRedeemOrder = Partial<Pick<OrdersCreateResponse, 'id' | 'source_id' | 'metadata' | 'amount'>> & {
|
|
126
|
+
items?: ClientSideItem[];
|
|
127
|
+
};
|
|
128
|
+
export interface ClientSideRedeemWidgetPayload {
|
|
129
|
+
order?: {
|
|
130
|
+
amount?: number;
|
|
131
|
+
};
|
|
132
|
+
}
|
|
133
|
+
export declare type ClientSideTrackCustomer = CustomerRequest;
|
|
134
|
+
export declare type ClientSideConsentsListResponse = ConsentsListResponse;
|
|
135
|
+
export {};
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
interface ConsentGroup {
|
|
2
|
+
id: string;
|
|
3
|
+
name: string;
|
|
4
|
+
description: string;
|
|
5
|
+
consents: string[];
|
|
6
|
+
created_at: string;
|
|
7
|
+
updated_at?: string;
|
|
8
|
+
object: 'consent_group';
|
|
9
|
+
}
|
|
10
|
+
export interface Consent {
|
|
11
|
+
id: string;
|
|
12
|
+
name: string;
|
|
13
|
+
description: string;
|
|
14
|
+
category: string;
|
|
15
|
+
created_at: string;
|
|
16
|
+
updated_at?: string;
|
|
17
|
+
object: 'consent';
|
|
18
|
+
}
|
|
19
|
+
export interface ConsentsListResponse {
|
|
20
|
+
groups: {
|
|
21
|
+
object: 'list';
|
|
22
|
+
total: number;
|
|
23
|
+
data_ref: 'data';
|
|
24
|
+
data: ConsentGroup[];
|
|
25
|
+
};
|
|
26
|
+
consents: {
|
|
27
|
+
object: 'list';
|
|
28
|
+
total: number;
|
|
29
|
+
data_ref: 'data';
|
|
30
|
+
data: Consent[];
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
export {};
|