@voucherify/sdk 2.8.1 → 2.9.1

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,19 @@
1
1
  # @voucherify/sdk
2
2
 
3
+ ## 2.9.1
4
+
5
+ ### Patch Changes
6
+
7
+ - [`2378764`](https://github.com/voucherifyio/voucherify-js-sdk/commit/23787647c22b31d5ca00908100d941ed27b1cea6) [#288](https://github.com/voucherifyio/voucherify-js-sdk/pull/288) Thanks [@awilczek](https://github.com/awilczek)! - Upgrade axios (CVE)
8
+
9
+ * [`8c843a8`](https://github.com/voucherifyio/voucherify-js-sdk/commit/8c843a82eb8720dc68f9c49baf02ebda1d24999f) [#286](https://github.com/voucherifyio/voucherify-js-sdk/pull/286) Thanks [@p-zielinski](https://github.com/p-zielinski)! - Added missing type properties in voucher.loyalty_card - for example for requesting voucher/loyalty member
10
+
11
+ ## 2.9.0
12
+
13
+ ### Minor Changes
14
+
15
+ - [`deb0b79`](https://github.com/voucherifyio/voucherify-js-sdk/commit/deb0b79b0e3da2ec5ad9457ba505ec2818f06347) [#282](https://github.com/voucherifyio/voucherify-js-sdk/pull/282) Thanks [@p-zielinski](https://github.com/p-zielinski)! - Support for new endpoints: List Member Activity
16
+
3
17
  ## 2.8.1
4
18
 
5
19
  ### Patch Changes
package/README.md CHANGED
@@ -1745,7 +1745,7 @@ Check our [MIGRATION GUIDE](./MIGRATION.md) to learn more about switching to our
1745
1745
 
1746
1746
  Voucherify JS SDK includes TypeScript declarations for our latest API. We recommend using TypeScript Version 4.2.
1747
1747
 
1748
- You can find TS example in [examples/with-nodejs-typescript](/examples/with-nodejs).
1748
+ Explore also [Voucherify TS examples](../../examples/sdk/with-nodejs-typescript "TypeScript examples").
1749
1749
 
1750
1750
  # <a name="error-handling"></a>😨 Error handling
1751
1751
 
@@ -85,8 +85,12 @@ export declare class Loyalties {
85
85
  */
86
86
  getMember(campaignId: string | null, memberId: string): Promise<T.LoyaltiesVoucherResponse>;
87
87
  /**
88
- * @see https://docs.voucherify.io/reference/get-member-activities
89
- * @see https://docs.voucherify.io/reference/get-member-activities-1
88
+ * @see https://docs.voucherify.io/reference/list-member-activity
89
+ * @see https://docs.voucherify.io/reference/list-member-activity-1
90
+ */
91
+ listMemberActivity(campaignId: string | null, memberId: string, params?: T.LoyaltiesListMemberActivityParams): Promise<T.LoyaltiesListMemberActivityResponse>;
92
+ /**
93
+ * @deprecated This method is deprecated in favor of the `listMemberActivity` method. We’re removing this method in next major version.
90
94
  */
91
95
  getMemberActivities(campaignId: string | null, memberId: string): Promise<T.LoyaltiesGetMemberActivitiesResponse>;
92
96
  /**
@@ -236,6 +236,8 @@ export interface LoyaltiesVoucherResponse {
236
236
  loyalty_card: {
237
237
  points: number;
238
238
  balance: number;
239
+ next_expiration_date?: string;
240
+ next_expiration_points?: number;
239
241
  };
240
242
  start_date?: string;
241
243
  expiration_date?: string;
@@ -282,6 +284,24 @@ export interface LoyaltiesCreateMember {
282
284
  }
283
285
  export declare type LoyaltiesCreateMemberResponse = LoyaltiesVoucherResponse;
284
286
  export declare type LoyaltiesGetMemberResponse = LoyaltiesCreateMemberResponse;
287
+ export declare type LoyaltiesListMemberActivityParams = {
288
+ order?: 'created_at' | '-created_at';
289
+ starting_after_id?: string;
290
+ limit?: number;
291
+ };
292
+ export declare type LoyaltiesListMemberActivityResponse = {
293
+ object: 'list';
294
+ data_ref: 'data';
295
+ data: {
296
+ id: string;
297
+ type: string;
298
+ data: any;
299
+ created_at: string;
300
+ group_id: string;
301
+ }[];
302
+ has_more: boolean;
303
+ more_starting_after?: string;
304
+ };
285
305
  export interface LoyaltiesGetMemberActivitiesResponse {
286
306
  object: 'list';
287
307
  data_ref: 'activities';
@@ -650,10 +670,6 @@ export interface LoyaltiesGetPointsExpirationResponseBody {
650
670
  }[];
651
671
  total: number;
652
672
  }
653
- export interface LoyaltiesListCardTransactionsRequestQuery {
654
- limit?: number;
655
- page?: number;
656
- }
657
673
  export declare type LoyaltiesExportCardTransactionsResponseBody = VouchersExportTransactionsResponseBody;
658
674
  export interface LoyaltiesAddOrRemoveCardBalanceRequestBody {
659
675
  points: number;
@@ -799,6 +815,7 @@ export interface LoyaltyCardTransaction {
799
815
  type: 'loyalty_card';
800
816
  total: number;
801
817
  object: 'balance';
818
+ operation_type: 'MANUAL' | 'AUTOMATIC';
802
819
  points: number;
803
820
  balance: number;
804
821
  related_object: {
@@ -143,7 +143,7 @@ export declare type OrderCalculated = {
143
143
  items_applied_discount_amount?: number;
144
144
  total_applied_discount_amount?: number;
145
145
  items?: OrderItemCalculated[];
146
- metadata: Record<string, unknown>;
146
+ metadata?: Record<string, unknown>;
147
147
  customer?: CustomerId | CustomerWithSummaryLoyaltyReferrals;
148
148
  customer_id: string | null;
149
149
  referrer?: ReferrerId | ReferrerWithSummaryLoyaltyReferrals;
@@ -35,6 +35,9 @@ export interface VouchersResponse {
35
35
  };
36
36
  loyalty_card?: {
37
37
  points: number;
38
+ balance: number;
39
+ next_expiration_date?: string;
40
+ next_expiration_points?: number;
38
41
  };
39
42
  start_date?: string;
40
43
  expiration_date?: string;
@@ -81,6 +81,7 @@ class RequestController {
81
81
  this.timeoutMs = timeoutMs;
82
82
  this.request = axios.create({
83
83
  baseURL: `${this.baseURL}/${this.basePath}/`,
84
+ allowAbsoluteUrls: false,
84
85
  headers: this.headers,
85
86
  responseType: 'json'
86
87
  });
@@ -1443,8 +1444,16 @@ class Loyalties {
1443
1444
  return this.client.get(campaignId ? `/loyalties/${encode(campaignId)}/members/${memberId}` : `/loyalties/members/${memberId}`);
1444
1445
  }
1445
1446
  /**
1446
- * @see https://docs.voucherify.io/reference/get-member-activities
1447
- * @see https://docs.voucherify.io/reference/get-member-activities-1
1447
+ * @see https://docs.voucherify.io/reference/list-member-activity
1448
+ * @see https://docs.voucherify.io/reference/list-member-activity-1
1449
+ */
1450
+
1451
+
1452
+ listMemberActivity(campaignId, memberId, params) {
1453
+ return this.client.get(campaignId ? `/loyalties/${encode(campaignId)}/members/${memberId}/activity` : `/loyalties/members/${memberId}/activity`, params);
1454
+ }
1455
+ /**
1456
+ * @deprecated This method is deprecated in favor of the `listMemberActivity` method. We’re removing this method in next major version.
1448
1457
  */
1449
1458
 
1450
1459
 
@@ -1960,7 +1969,7 @@ function VoucherifyServerSide(options) {
1960
1969
  let headers = {
1961
1970
  'X-App-Id': options.applicationId,
1962
1971
  'X-App-Token': options.secretKey,
1963
- 'X-Voucherify-Channel': options.channel || `${environment()}-SDK-v${"2.8.1"}`,
1972
+ 'X-Voucherify-Channel': options.channel || `${environment()}-SDK-v${"2.9.1"}`,
1964
1973
  'Content-Type': 'application/json'
1965
1974
  };
1966
1975
 
@@ -2226,7 +2235,7 @@ function VoucherifyClientSide(options) {
2226
2235
  let headers = {
2227
2236
  'X-Client-Application-Id': options.clientApplicationId,
2228
2237
  'X-Client-Token': options.clientSecretKey,
2229
- 'X-Voucherify-Channel': `${environment()}-ClientSide-SDK-v${"2.8.1"}`
2238
+ 'X-Voucherify-Channel': `${environment()}-ClientSide-SDK-v${"2.9.1"}`
2230
2239
  };
2231
2240
 
2232
2241
  if (environment().startsWith('Node')) {