@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.
Files changed (56) hide show
  1. package/CHANGELOG.md +110 -0
  2. package/README.md +1258 -0
  3. package/dist/AsyncActions.d.ts +15 -0
  4. package/dist/Balance.d.ts +12 -0
  5. package/dist/Campaigns.d.ts +45 -0
  6. package/dist/ClientSide.d.ts +40 -0
  7. package/dist/Consents.d.ts +10 -0
  8. package/dist/Customers.d.ts +43 -0
  9. package/dist/Distributions.d.ts +22 -0
  10. package/dist/Events.d.ts +7 -0
  11. package/dist/Exports.d.ts +18 -0
  12. package/dist/Loyalties.d.ts +82 -0
  13. package/dist/Orders.d.ts +22 -0
  14. package/dist/Products.d.ts +54 -0
  15. package/dist/PromotionTiers.d.ts +30 -0
  16. package/dist/Promotions.d.ts +16 -0
  17. package/dist/Redemptions.d.ts +26 -0
  18. package/dist/RequestController.d.ts +20 -0
  19. package/dist/Rewards.d.ts +39 -0
  20. package/dist/Segments.d.ts +22 -0
  21. package/dist/ValidationRules.d.ts +39 -0
  22. package/dist/Validations.d.ts +13 -0
  23. package/dist/VoucherifyClientSide.d.ts +76 -0
  24. package/dist/VoucherifyError.d.ts +6 -0
  25. package/dist/VoucherifyServerSide.d.ts +111 -0
  26. package/dist/Vouchers.d.ts +64 -0
  27. package/dist/helpers.d.ts +19 -0
  28. package/dist/index.d.ts +24 -0
  29. package/dist/types/AsyncActions.d.ts +18 -0
  30. package/dist/types/Balance.d.ts +14 -0
  31. package/dist/types/Campaigns.d.ts +117 -0
  32. package/dist/types/ClientSide.d.ts +135 -0
  33. package/dist/types/Consents.d.ts +33 -0
  34. package/dist/types/Customers.d.ts +113 -0
  35. package/dist/types/Distributions.d.ts +141 -0
  36. package/dist/types/Events.d.ts +17 -0
  37. package/dist/types/Exports.d.ts +30 -0
  38. package/dist/types/Loyalties.d.ts +462 -0
  39. package/dist/types/Orders.d.ts +61 -0
  40. package/dist/types/Products.d.ts +97 -0
  41. package/dist/types/PromotionTiers.d.ts +107 -0
  42. package/dist/types/Promotions.d.ts +90 -0
  43. package/dist/types/Redemptions.d.ts +150 -0
  44. package/dist/types/Rewards.d.ts +114 -0
  45. package/dist/types/Segments.d.ts +32 -0
  46. package/dist/types/ValidationRules.d.ts +74 -0
  47. package/dist/types/Validations.d.ts +66 -0
  48. package/dist/types/Vouchers.d.ts +227 -0
  49. package/dist/types/index.d.ts +19 -0
  50. package/dist/voucherifysdk.esm.js +1567 -0
  51. package/dist/voucherifysdk.esm.js.map +1 -0
  52. package/dist/voucherifysdk.umd.development.js +1578 -0
  53. package/dist/voucherifysdk.umd.development.js.map +1 -0
  54. package/dist/voucherifysdk.umd.production.min.js +2 -0
  55. package/dist/voucherifysdk.umd.production.min.js.map +1 -0
  56. package/package.json +48 -0
@@ -0,0 +1,90 @@
1
+ import { DiscountAmount, DiscountPercent, DiscountUnit } from './Vouchers';
2
+ import { OrdersItem } from './Orders';
3
+ import { PromotionTier } from './PromotionTiers';
4
+ import { SimpleCustomer } from './Customers';
5
+ import { ValidationRulesCreateAssignmentResponse } from './ValidationRules';
6
+ export interface PromotionsCreateResponse {
7
+ id: string;
8
+ name: string;
9
+ campaign_type?: 'PROMOTION';
10
+ type: 'STATIC';
11
+ description?: string;
12
+ start_date?: string;
13
+ expiration_date?: string;
14
+ promotion: {
15
+ object: 'list';
16
+ data_ref: 'tiers';
17
+ tiers?: PromotionTier[];
18
+ has_more: boolean;
19
+ };
20
+ category?: string;
21
+ auto_join: boolean;
22
+ join_once: boolean;
23
+ validation_rules_assignments: {
24
+ data?: ValidationRulesCreateAssignmentResponse[];
25
+ object: 'list';
26
+ total: number;
27
+ data_ref: 'data';
28
+ };
29
+ activity_duration_after_publishing?: string;
30
+ validity_timeframe?: {
31
+ interval?: string;
32
+ duration?: string;
33
+ };
34
+ validity_day_of_week?: number[];
35
+ metadata?: Record<string, string>;
36
+ created_at: string;
37
+ vouchers_generation_status: 'DONE';
38
+ active: boolean;
39
+ use_voucher_metadata_schema: boolean;
40
+ protected: boolean;
41
+ object: 'campaign';
42
+ }
43
+ export interface PromotionsCreate {
44
+ name: string;
45
+ campaign_type: 'PROMOTION';
46
+ start_date?: string;
47
+ expiration_date?: string;
48
+ promotion?: {
49
+ tiers: {
50
+ name: string;
51
+ banner: string;
52
+ action: {
53
+ discount: DiscountUnit | DiscountAmount | DiscountPercent;
54
+ };
55
+ metadata?: Record<string, any>;
56
+ }[];
57
+ };
58
+ }
59
+ export interface PromotionsValidateParams {
60
+ customer?: Omit<SimpleCustomer, 'object'> & {
61
+ description?: string;
62
+ };
63
+ order?: {
64
+ id?: string;
65
+ source_id?: string;
66
+ items?: OrdersItem[];
67
+ amount?: number;
68
+ metadata?: Record<string, any>;
69
+ };
70
+ metadata?: Record<string, any>;
71
+ }
72
+ export interface PromotionsValidateResponse {
73
+ valid: boolean;
74
+ promotions?: {
75
+ id: string;
76
+ object: 'promotion_tier';
77
+ banner?: string;
78
+ discount?: DiscountUnit | DiscountAmount | DiscountPercent;
79
+ discount_amount?: number;
80
+ metadata?: Record<string, any>;
81
+ order?: {
82
+ id?: string;
83
+ source_id?: string;
84
+ amount: number;
85
+ items?: OrdersItem[];
86
+ metadata?: Record<string, any>;
87
+ };
88
+ }[];
89
+ tracking_id?: string;
90
+ }
@@ -0,0 +1,150 @@
1
+ import { OrdersCreateResponse } from './Orders';
2
+ import { RewardsCreateResponse } from './Rewards';
3
+ import { SimpleCustomer } from './Customers';
4
+ import { VouchersResponse } from './Vouchers';
5
+ export interface RedemptionsRedeemBody {
6
+ tracking_id?: string;
7
+ customer?: SimpleCustomer & {
8
+ description?: string;
9
+ };
10
+ order?: Pick<Partial<OrdersCreateResponse>, 'id' | 'source_id' | 'amount' | 'items' | 'status' | 'metadata'>;
11
+ metadata?: Record<string, any>;
12
+ reward?: {
13
+ id?: string;
14
+ points?: number;
15
+ };
16
+ gift?: {
17
+ credits: number;
18
+ };
19
+ session?: {
20
+ key: string;
21
+ };
22
+ }
23
+ export interface RedemptionsRedeemResponse {
24
+ id: string;
25
+ object: 'redemption';
26
+ date?: string;
27
+ customer_id?: string;
28
+ tracking_id?: string;
29
+ order?: OrdersCreateResponse;
30
+ metadata?: Record<string, any>;
31
+ result: 'SUCCESS' | 'FAILURE';
32
+ voucher: VouchersResponse;
33
+ customer?: SimpleCustomer;
34
+ reward?: RewardsCreateResponse;
35
+ related_object_type: 'voucher';
36
+ gift?: {
37
+ amount: number;
38
+ };
39
+ loyalty_card?: {
40
+ points: number;
41
+ };
42
+ failure_code?: string;
43
+ failure_message?: string;
44
+ }
45
+ export interface RedemptionsListParams {
46
+ limit?: number;
47
+ page?: number;
48
+ result?: 'SUCCESS' | 'FAILURE';
49
+ campaign?: string;
50
+ customer?: string;
51
+ created_at?: {
52
+ before?: string;
53
+ after?: string;
54
+ };
55
+ }
56
+ export interface Redemption {
57
+ id: string;
58
+ object: 'redemption';
59
+ date?: string;
60
+ customer_id?: string;
61
+ tracking_id?: string;
62
+ order?: Omit<OrdersCreateResponse, 'object'> & {
63
+ related_object_id: string;
64
+ related_object_type: 'redemption';
65
+ referrer?: string;
66
+ };
67
+ metadata?: Record<string, any>;
68
+ result: 'SUCCESS' | 'FAILURE';
69
+ failure_code?: string;
70
+ failure_message?: string;
71
+ customer?: SimpleCustomer;
72
+ related_object_type?: 'string';
73
+ voucher?: {
74
+ code: string;
75
+ campaign?: string;
76
+ id: string;
77
+ object: 'voucher';
78
+ campaign_id?: string;
79
+ };
80
+ gift?: {
81
+ amount: number;
82
+ };
83
+ loyalty_card?: {
84
+ points: number;
85
+ };
86
+ }
87
+ export interface RedemptionsListResponse {
88
+ object: 'list';
89
+ total: number;
90
+ data_ref: 'redemptions';
91
+ redemptions: (Redemption | SimpleRollback)[];
92
+ }
93
+ export interface RedemptionsGetForVoucherResponse {
94
+ object: 'list';
95
+ total: number;
96
+ data_ref: string;
97
+ quantity: number;
98
+ redeemed_quantity?: number;
99
+ redeemed_amount?: number;
100
+ redemption_entries?: (Redemption | SimpleRollback)[];
101
+ }
102
+ export interface RedemptionsRollbackParams {
103
+ reason?: string;
104
+ tracking_id?: string;
105
+ customer?: SimpleCustomer & {
106
+ description?: string;
107
+ };
108
+ }
109
+ export interface RedemptionsRollbackQueryParams {
110
+ reason?: string;
111
+ tracking_id?: string;
112
+ }
113
+ export interface RedemptionsRollbackPayload {
114
+ customer?: SimpleCustomer & {
115
+ description?: string;
116
+ };
117
+ }
118
+ export interface RedemptionsRollbackResponse {
119
+ id: string;
120
+ object: 'redemption_rollback';
121
+ date?: string;
122
+ customer_id?: string;
123
+ tracking_id?: string;
124
+ redemption?: string;
125
+ amount?: number;
126
+ reason?: string;
127
+ result: 'SUCCESS' | 'FAILURE';
128
+ voucher?: VouchersResponse;
129
+ customer?: SimpleCustomer;
130
+ reward?: {
131
+ assignment_id: string;
132
+ object: 'reward';
133
+ };
134
+ }
135
+ export declare type SimpleRollback = Pick<RedemptionsRollbackResponse, 'id' | 'object' | 'date' | 'customer_id' | 'tracking_id' | 'redemption' | 'result' | 'customer'> & {
136
+ related_object_type: 'voucher';
137
+ voucher: {
138
+ id: string;
139
+ object: 'voucher';
140
+ code: string;
141
+ campaign?: string;
142
+ campaign_id?: string;
143
+ };
144
+ gift?: {
145
+ amount: number;
146
+ };
147
+ loyalty_card?: {
148
+ points: number;
149
+ };
150
+ };
@@ -0,0 +1,114 @@
1
+ export interface RewardsListParams {
2
+ page?: number;
3
+ limit?: number;
4
+ }
5
+ export interface RewardsResponse {
6
+ id: string;
7
+ name?: string;
8
+ stock?: number;
9
+ redeemed?: number;
10
+ attributes?: {
11
+ image_url?: string;
12
+ description?: string;
13
+ };
14
+ created_at: string;
15
+ updated_at?: string;
16
+ object: 'reward';
17
+ }
18
+ export declare type RewardsCreateResponse = RewardsResponse & RewardsTypeResponse;
19
+ export interface RewardsListResponse {
20
+ object: 'list';
21
+ total: number;
22
+ data_ref: 'data';
23
+ data: RewardsCreateResponse[];
24
+ }
25
+ export interface Rewards {
26
+ name: string;
27
+ stock?: number;
28
+ attributes?: {
29
+ image_url?: string;
30
+ description?: string;
31
+ };
32
+ }
33
+ interface RewardsTypeMaterial {
34
+ type?: 'MATERIAL';
35
+ parameters: {
36
+ product?: {
37
+ id?: string;
38
+ sku?: string;
39
+ };
40
+ };
41
+ }
42
+ interface RewardsTypeCampaign {
43
+ type?: 'CAMPAIGN';
44
+ parameters: {
45
+ campaign?: {
46
+ id: string;
47
+ balance?: number;
48
+ };
49
+ };
50
+ }
51
+ interface RewardsTypeCampaignResponse {
52
+ type?: 'CAMPAIGN';
53
+ parameters: {
54
+ campaign?: {
55
+ id: string;
56
+ balance?: number;
57
+ type?: 'DISCOUNT_COUPONS' | 'PROMOTION' | 'GIFT_VOUCHERS' | 'REFERRAL_PROGRAM';
58
+ };
59
+ };
60
+ }
61
+ interface RewardsTypeCoin {
62
+ type?: 'COIN';
63
+ parameters: {
64
+ coin?: {
65
+ exchange_ratio?: number;
66
+ };
67
+ };
68
+ }
69
+ export declare type RewardsType = RewardsTypeCampaign | RewardsTypeCoin | RewardsTypeMaterial;
70
+ export declare type RewardsTypeResponse = Required<RewardsTypeCampaignResponse> | Required<RewardsTypeCoin> | Required<RewardsTypeMaterial>;
71
+ export declare type RewardsCreate = Rewards & RewardsType;
72
+ export declare type RewardsGetResponse = RewardsCreateResponse;
73
+ export declare type RewardsUpdate = Omit<RewardsCreate, 'type'> & {
74
+ id: string;
75
+ };
76
+ export declare type RewardsUpdateResponse = RewardsCreateResponse;
77
+ export interface RewardsAssignmentObject {
78
+ id: string;
79
+ reward_id: string;
80
+ related_object_id?: string;
81
+ related_object_type?: string;
82
+ parameters?: {
83
+ loyalty?: {
84
+ points: number;
85
+ };
86
+ };
87
+ created_at: string;
88
+ updated_at?: string;
89
+ object: 'reward_assignment';
90
+ }
91
+ export interface RewardsListAssignmentsParams {
92
+ limit?: number;
93
+ page?: number;
94
+ }
95
+ export interface RewardsListAssignmentsResponse {
96
+ total: number;
97
+ data: RewardsAssignmentObject[];
98
+ object: 'list';
99
+ data_ref: 'data';
100
+ }
101
+ export interface RewardsCreateAssignment {
102
+ campaign?: string;
103
+ parameters?: {
104
+ loyalty?: {
105
+ points: number;
106
+ };
107
+ };
108
+ }
109
+ export declare type RewardsCreateAssignmentResponse = RewardsAssignmentObject;
110
+ export declare type RewardsUpdateAssignment = RewardsCreateAssignment & {
111
+ id: string;
112
+ };
113
+ export declare type RewardsUpdateAssignmentResponse = RewardsAssignmentObject;
114
+ export {};
@@ -0,0 +1,32 @@
1
+ export interface SegmentsCreate {
2
+ name: string;
3
+ type: 'static' | 'auto-update';
4
+ filter?: {
5
+ junction?: 'AND' | 'OR';
6
+ [filter_conditions: string]: any;
7
+ };
8
+ customers?: string[];
9
+ }
10
+ export interface SegmentsCreateResponse {
11
+ id: string;
12
+ name: string;
13
+ created_at: string;
14
+ metadata?: Record<string, any>;
15
+ filter?: {
16
+ junction?: 'AND' | 'OR';
17
+ [filter_conditions: string]: any;
18
+ };
19
+ type?: string;
20
+ object: 'segment';
21
+ }
22
+ export declare type SegmentsGetResponse = SegmentsCreateResponse;
23
+ export interface SegmentsListResponse {
24
+ object: 'list';
25
+ total: number;
26
+ data_ref: 'data';
27
+ data: {
28
+ id: string;
29
+ name: string;
30
+ object: 'segment';
31
+ }[];
32
+ }
@@ -0,0 +1,74 @@
1
+ export interface ValidationRulesCreate {
2
+ name: string;
3
+ error?: {
4
+ message?: string;
5
+ };
6
+ rules?: {
7
+ logic?: string;
8
+ [rule: string]: any;
9
+ };
10
+ }
11
+ export interface ValidationRulesCreateResponse {
12
+ id: string;
13
+ name: string;
14
+ error?: {
15
+ message?: string;
16
+ };
17
+ rules?: {
18
+ logic?: string;
19
+ [rule: string]: any;
20
+ };
21
+ created_at: string;
22
+ updated_at?: string;
23
+ object: 'validation_rules';
24
+ }
25
+ export interface ValidationRulesValidateResponse {
26
+ valid: boolean;
27
+ rule_id: string;
28
+ applicable_to: {
29
+ data: any[];
30
+ object: 'list';
31
+ total: number;
32
+ };
33
+ }
34
+ export declare type ValidationRulesGetResponse = ValidationRulesCreateResponse & {
35
+ assignments_count?: string;
36
+ };
37
+ export declare type ValidationRulesUpdate = Partial<ValidationRulesCreate> & {
38
+ id: string;
39
+ };
40
+ export declare type ValidationRulesUpdateResponse = ValidationRulesCreateResponse;
41
+ export interface ValidationRulesCreateAssignment {
42
+ voucher?: string;
43
+ campaign?: string;
44
+ promotion_tier?: string;
45
+ }
46
+ export interface ValidationRulesCreateAssignmentResponse {
47
+ id: string;
48
+ rule_id: string;
49
+ related_object_id?: string;
50
+ related_object_type?: string;
51
+ created_at?: string;
52
+ updated_at: string;
53
+ object: 'validation_rules_assignment';
54
+ }
55
+ export interface ValidationRulesListParams {
56
+ limit?: number;
57
+ page?: number;
58
+ }
59
+ export interface ValidationRulesListResponse {
60
+ object: 'list';
61
+ total: number;
62
+ data_ref: 'data';
63
+ data: ValidationRulesGetResponse[];
64
+ }
65
+ export interface ValidationRulesListAssignmentsParams {
66
+ limit?: number;
67
+ page?: number;
68
+ }
69
+ export interface ValidationRulesListAssignmentsResponse {
70
+ object: 'list';
71
+ total: number;
72
+ data_ref: 'data';
73
+ data: ValidationRulesCreateAssignmentResponse[];
74
+ }
@@ -0,0 +1,66 @@
1
+ import { DiscountAmount, DiscountPercent, DiscountUnit } from './Vouchers';
2
+ import { OrdersItem } from './Orders';
3
+ import { PromotionsValidateParams } from './Promotions';
4
+ export interface ValidationsValidateVoucherParams {
5
+ customer?: {
6
+ id?: string;
7
+ source_id?: string;
8
+ name?: string;
9
+ email?: string;
10
+ description?: string;
11
+ metadata?: Record<string, any>;
12
+ };
13
+ order?: {
14
+ id?: string;
15
+ source_id?: string;
16
+ amount?: number;
17
+ items?: OrdersItem[];
18
+ metadata?: Record<string, any>;
19
+ };
20
+ gift?: {
21
+ credits: number;
22
+ };
23
+ reward?: {
24
+ id: string;
25
+ };
26
+ session?: {
27
+ type: 'LOCK';
28
+ key?: string;
29
+ ttl?: number;
30
+ ttl_unit?: 'MILLISECONDS' | 'SECONDS' | 'MINUTES' | 'HOURS' | 'DAYS';
31
+ };
32
+ }
33
+ export interface ValidationsValidateVoucherResponse {
34
+ applicable_to?: {
35
+ object: 'list';
36
+ total: number;
37
+ data?: {
38
+ id: string;
39
+ object: 'product';
40
+ source_id?: string;
41
+ }[];
42
+ };
43
+ campaign?: string;
44
+ campaign_id?: string;
45
+ metadata?: Record<string, any>;
46
+ code?: string;
47
+ valid?: boolean;
48
+ discount?: DiscountAmount | DiscountUnit | DiscountPercent;
49
+ gift?: {
50
+ amount: number;
51
+ balance: number;
52
+ };
53
+ loyalty?: {
54
+ points_cost: number;
55
+ };
56
+ order?: {
57
+ amount: number;
58
+ discount_amount: number;
59
+ total_discount_amount: number;
60
+ total_amount: number;
61
+ items?: OrdersItem[];
62
+ };
63
+ tracking_id: string;
64
+ }
65
+ export declare type ValidationsValidateCode = PromotionsValidateParams;
66
+ export declare type ValidationsValidateContext = ValidationsValidateVoucherParams;