@voucherify/sdk 2.0.0 → 2.0.3

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,23 @@
1
1
  # @voucherify/sdk
2
2
 
3
+ ## 2.0.3
4
+
5
+ ### Patch Changes
6
+
7
+ - [`da9e103`](https://github.com/voucherifyio/voucherify-js-sdk/commit/da9e103a43590b55cb80d64e1743f7ede1e09946) [#117](https://github.com/voucherifyio/voucherify-js-sdk/pull/117) Thanks [@darekg11](https://github.com/darekg11)! - Added support for listing customer activities by customerId. Additionally user can pass query params allowing for better filtering. API Reference: https://docs.voucherify.io/reference/get-customer-activities
8
+
9
+ ## 2.0.2
10
+
11
+ ### Patch Changes
12
+
13
+ - [`b5f04fa`](https://github.com/voucherifyio/voucherify-js-sdk/commit/b5f04fa09db6849f514910747a5ac9a721f63891) [#112](https://github.com/voucherifyio/voucherify-js-sdk/pull/112) Thanks [@darekg11](https://github.com/darekg11)! - Query params passed to `this.client.post` method are now correctly stringified. Added possibility to pass query params to `voucherify.promotions.validate` method in order to allow developers using SDK to pass advanced filters to restrict possible range of promotion campaigns against which validation should be performed.
14
+
15
+ ## 2.0.1
16
+
17
+ ### Patch Changes
18
+
19
+ - [`532e82b`](https://github.com/voucherifyio/voucherify-js-sdk/commit/532e82b2bd3a5991a0fd83af2edc226c6c98c680) [#105](https://github.com/voucherifyio/voucherify-js-sdk/pull/105) Thanks [@jfougere](https://github.com/jfougere)! - Fix missing session attributes in client side validation request
20
+
3
21
  ## 2.0.0
4
22
 
5
23
  ### Major Changes
package/README.md CHANGED
@@ -514,6 +514,7 @@ Methods are provided within `client.customers.*` namespace.
514
514
  - [Delete Customer](#delete-customer)
515
515
  - [List Customers](#list-customers)
516
516
  - [Update Customer's Consents](#update-customers-consents)
517
+ - [List Customer's Activities](#list-customers-activities)
517
518
 
518
519
  #### [Create Customer](https://docs.voucherify.io/reference/create-customer)
519
520
 
@@ -588,6 +589,13 @@ Keep in mind this operation may drain your API call limits fairly quickly - each
588
589
  client.customers.updateConsents(customer, consents)
589
590
  ```
590
591
 
592
+ #### [List Customers Activities](https://docs.voucherify.io/reference/get-customer-activities)
593
+
594
+ ```javascript
595
+ client.customers.listActivities(customerId)
596
+ client.customers.listActivities(customerId, params)
597
+ ```
598
+
591
599
  ---
592
600
 
593
601
  ### Consents
@@ -39,5 +39,9 @@ declare class Customers {
39
39
  * @see https://docs.voucherify.io/reference/update-customers-consents
40
40
  */
41
41
  updateConsents(idOrSourceId: string, consents: T.CustomersUpdateConsentsBody): Promise<undefined>;
42
+ /**
43
+ * @see https://docs.voucherify.io/reference/get-customer-activities
44
+ */
45
+ listActivities(customerId: string, params?: T.CustomerActivitiesListQueryParams): Promise<T.CustomerActivitiesListResponse>;
42
46
  }
43
47
  export { Customers };
@@ -12,5 +12,5 @@ export declare class Promotions {
12
12
  /**
13
13
  * @see https://docs.voucherify.io/reference/validate-promotions-1
14
14
  */
15
- validate(params: T.PromotionsValidateParams): Promise<T.PromotionsValidateResponse>;
15
+ validate(body: T.PromotionsValidateParams, params?: T.PromotionsValidateQueryParams): Promise<T.PromotionsValidateResponse>;
16
16
  }
@@ -94,6 +94,20 @@ export interface CustomersCommonListResponse {
94
94
  customers: CustomerObject[];
95
95
  has_more?: boolean;
96
96
  }
97
+ export interface CustomerActivitiesListQueryParams {
98
+ limit?: number;
99
+ order?: 'created_at' | '-created_at';
100
+ starting_after?: string;
101
+ starting_after_id?: string;
102
+ campaign_type?: 'LOYALTY_PROGRAM' | 'PROMOTION' | 'DISCOUNT_COUPONS' | 'GIFT_VOUCHERS' | 'REFERRAL_PROGRAM';
103
+ campaign_id?: string;
104
+ }
105
+ export interface CustomerActivitiesListResponse {
106
+ object: 'list';
107
+ total: number;
108
+ data_ref: 'data';
109
+ data: Record<string, any>[];
110
+ }
97
111
  export declare type CustomersCreateBody = CustomerRequest;
98
112
  export declare type CustomersCreateResponse = CustomerObject | CustomerUnconfirmed;
99
113
  export declare type CustomersGetResponse = CustomerObject | CustomerUnconfirmed;
@@ -69,6 +69,10 @@ export interface PromotionsValidateParams {
69
69
  };
70
70
  metadata?: Record<string, any>;
71
71
  }
72
+ export interface PromotionsValidateQueryParams {
73
+ audienceRulesOnly?: boolean;
74
+ filters?: Record<string, any>;
75
+ }
72
76
  export interface PromotionsValidateResponse {
73
77
  valid: boolean;
74
78
  promotions?: {
@@ -75,6 +75,9 @@ class RequestController {
75
75
  async post(path, body, params, headers) {
76
76
  const response = await this.request.post(path, body, {
77
77
  params,
78
+ paramsSerializer: function (params) {
79
+ return Qs.stringify(params);
80
+ },
78
81
  headers
79
82
  });
80
83
  return response.data;
@@ -646,8 +649,8 @@ class Promotions {
646
649
  */
647
650
 
648
651
 
649
- validate(params) {
650
- return this.client.post('/promotions/validation', params);
652
+ validate(body, params) {
653
+ return this.client.post('/promotions/validation', body, params);
651
654
  }
652
655
 
653
656
  }
@@ -747,6 +750,14 @@ class Customers {
747
750
  updateConsents(idOrSourceId, consents) {
748
751
  return this.client.put(`/customers/${encode(idOrSourceId)}/consents`, consents);
749
752
  }
753
+ /**
754
+ * @see https://docs.voucherify.io/reference/get-customer-activities
755
+ */
756
+
757
+
758
+ listActivities(customerId, params) {
759
+ return this.client.get(`/customers/${encode(customerId)}/activities`, params);
760
+ }
750
761
 
751
762
  }
752
763
 
@@ -1290,7 +1301,7 @@ function VoucherifyServerSide(options) {
1290
1301
  let headers = {
1291
1302
  'X-App-Id': options.applicationId,
1292
1303
  'X-App-Token': options.secretKey,
1293
- 'X-Voucherify-Channel': options.channel || `${environment()}-SDK-v${"2.0.0"}`,
1304
+ 'X-Voucherify-Channel': options.channel || `${environment()}-SDK-v${"2.0.3"}`,
1294
1305
  'Content-Type': 'application/json'
1295
1306
  };
1296
1307
 
@@ -1390,6 +1401,10 @@ class ClientSide {
1390
1401
  };
1391
1402
  query.customer = params.customer;
1392
1403
  query.tracking_id = params.tracking_id || this.trackingId;
1404
+ query.session_type = params.session_type;
1405
+ query.session_key = params.session_key;
1406
+ query.session_ttl = params.session_ttl;
1407
+ query.session_ttl_unit = params.session_ttl_unit;
1393
1408
  }
1394
1409
 
1395
1410
  if (!!query.code) {
@@ -1515,7 +1530,7 @@ function VoucherifyClientSide(options) {
1515
1530
  let headers = {
1516
1531
  'X-Client-Application-Id': options.clientApplicationId,
1517
1532
  'X-Client-Token': options.clientSecretKey,
1518
- 'X-Voucherify-Channel': `${environment()}-ClientSide-SDK-v${"2.0.0"}`
1533
+ 'X-Voucherify-Channel': `${environment()}-ClientSide-SDK-v${"2.0.3"}`
1519
1534
  };
1520
1535
 
1521
1536
  if (environment().startsWith('Node')) {