@bzbs/react-api-client 2.0.2 → 2.1.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/dist/index.mjs CHANGED
@@ -56,9 +56,26 @@ var BaseService = class {
56
56
  };
57
57
  }
58
58
  if (error.response && error.response.data) {
59
+ const data = error.response.data;
60
+ if (data["Success"]) {
61
+ return {
62
+ type: "server-error",
63
+ error: {
64
+ requestId: data.RequestId || "",
65
+ error: {
66
+ id: data.Code || data.code || error.response.status,
67
+ message: data.Message || data.message || error.response.statusText,
68
+ code: data.Code || data.code || error.response.status,
69
+ type: "buzzebees"
70
+ }
71
+ },
72
+ statusCode: error.response.status,
73
+ response: error.response
74
+ };
75
+ }
59
76
  return {
60
77
  type: "server-error",
61
- error: error.response.data,
78
+ error: data,
62
79
  statusCode: error.response.status,
63
80
  response: error.response
64
81
  };
@@ -1002,6 +1019,7 @@ var CampaignApi = class extends BaseService {
1002
1019
  * @param params.contactNumber - The contact number of the user.
1003
1020
  * @param params.options - Additional options for the redemption.
1004
1021
  * @param params.spPoints - Point Per Unit x Quantity (Donate only).
1022
+ * @param params.pointUnit - The point unit of the campaign (Point Service Only).
1005
1023
  * @param requestOptions - The options for the HTTP request.
1006
1024
  * @returns A promise that resolves to a service response containing the redeem response.
1007
1025
  */
@@ -1631,6 +1649,107 @@ var PointLogApi = class extends BaseService {
1631
1649
  }
1632
1650
  };
1633
1651
 
1652
+ // src/api/points/point-api.ts
1653
+ var PointApi = class extends BaseService {
1654
+ constructor(client, baseUrl) {
1655
+ super(client, baseUrl);
1656
+ }
1657
+ /**
1658
+ * Retrieves the current point balance for the authenticated user across the requested point units.
1659
+ *
1660
+ * @param params - The parameters for retrieving the point balance.
1661
+ * @param params.units - (Optional) Point unit codes (e.g. Point, Coin). Omit to use all units configured for the app.
1662
+ * @param params.boxIds - (Optional) Box (sub-bucket) identifiers to filter by.
1663
+ * @param params.onlyVisible - (Optional) When true (default), only units marked visible for the app are considered.
1664
+ * @param params.options - (Optional) Additional options for the request.
1665
+ * @param requestOptions - (Optional) The request options.
1666
+ * @returns A promise that resolves to a service response containing an array of point balances.
1667
+ */
1668
+ balance(params, requestOptions) {
1669
+ return __async(this, null, function* () {
1670
+ return yield this.get(
1671
+ "point/balance",
1672
+ __spreadValues({
1673
+ units: params == null ? void 0 : params.units,
1674
+ boxIds: params == null ? void 0 : params.boxIds,
1675
+ onlyVisible: params == null ? void 0 : params.onlyVisible
1676
+ }, params == null ? void 0 : params.options),
1677
+ requestOptions
1678
+ );
1679
+ });
1680
+ }
1681
+ /**
1682
+ * Retrieves the point balance with Currents and Expires breakdowns keyed by date.
1683
+ *
1684
+ * @param params - The parameters for retrieving the point detail.
1685
+ * @param params.units - (Optional) Point unit codes (e.g. Point, Coin). Omit to use all units configured for the app.
1686
+ * @param params.boxIds - (Optional) Box (sub-bucket) identifiers to filter by.
1687
+ * @param params.onlyVisible - (Optional) When true (default), only units marked visible for the app are considered.
1688
+ * @param params.options - (Optional) Additional options for the request.
1689
+ * @param requestOptions - (Optional) The request options.
1690
+ * @returns A promise that resolves to a service response containing an array of point balances with breakdowns.
1691
+ */
1692
+ detail(params, requestOptions) {
1693
+ return __async(this, null, function* () {
1694
+ return yield this.get(
1695
+ "point/detail",
1696
+ __spreadValues({
1697
+ units: params == null ? void 0 : params.units,
1698
+ boxIds: params == null ? void 0 : params.boxIds,
1699
+ onlyVisible: params == null ? void 0 : params.onlyVisible
1700
+ }, params == null ? void 0 : params.options),
1701
+ requestOptions
1702
+ );
1703
+ });
1704
+ }
1705
+ /**
1706
+ * Retrieves a paginated list of earn/burn/transfer transactions between start and end dates.
1707
+ *
1708
+ * @param params - The parameters for retrieving the point history.
1709
+ * @param params.start - Start of the range (inclusive), ISO-8601 with offset.
1710
+ * @param params.end - End of the range (inclusive), ISO-8601 with offset.
1711
+ * @param params.onlyVisible - (Optional) When true (default), only units marked visible for the app are considered.
1712
+ * @param params.skip - (Optional) Number of records to skip (offset pagination).
1713
+ * @param params.top - (Optional) Maximum number of records to return.
1714
+ * @param params.sortType - (Optional) Sort direction for Timestamp: Asc|Desc.
1715
+ * @param params.units - (Optional) Point unit codes to filter by.
1716
+ * @param params.boxIds - (Optional) Box (sub-bucket) identifiers to filter by.
1717
+ * @param params.references - (Optional) Filter by transaction reference.
1718
+ * @param params.transactionIds - (Optional) Filter by exact transaction IDs.
1719
+ * @param params.includeActions - (Optional) Only include transactions whose Action matches (e.g. Earn, Burn, Transfer).
1720
+ * @param params.excludeActions - (Optional) Exclude transactions whose Action matches.
1721
+ * @param params.includeTypes - (Optional) Only include transactions whose Type matches.
1722
+ * @param params.excludeTypes - (Optional) Exclude transactions whose Type matches.
1723
+ * @param params.options - (Optional) Additional options for the request.
1724
+ * @param requestOptions - (Optional) The request options.
1725
+ * @returns A promise that resolves to a service response containing an array of point history transactions.
1726
+ */
1727
+ history(params, requestOptions) {
1728
+ return __async(this, null, function* () {
1729
+ return yield this.get(
1730
+ "point/history",
1731
+ __spreadValues({
1732
+ start: params.start,
1733
+ end: params.end,
1734
+ onlyVisible: params.onlyVisible,
1735
+ skip: params.skip,
1736
+ top: params.top,
1737
+ sortType: params.sortType,
1738
+ units: params.units,
1739
+ boxIds: params.boxIds,
1740
+ references: params.references,
1741
+ transactionIds: params.transactionIds,
1742
+ includeActions: params.includeActions,
1743
+ excludeActions: params.excludeActions,
1744
+ includeTypes: params.includeTypes,
1745
+ excludeTypes: params.excludeTypes
1746
+ }, params.options),
1747
+ requestOptions
1748
+ );
1749
+ });
1750
+ }
1751
+ };
1752
+
1634
1753
  // src/api/profile/profile-api.ts
1635
1754
  var ProfileApi = class extends BaseService {
1636
1755
  constructor(client, baseUrl) {
@@ -2590,6 +2709,7 @@ var BzbsService = class {
2590
2709
  this.notificationApi = new NotificationApi(this.client, this.baseUrl);
2591
2710
  this.placeApi = new PlaceApi(this.client, this.baseUrl);
2592
2711
  this.pointLogApi = new PointLogApi(this.client, this.baseUrl);
2712
+ this.pointApi = new PointApi(this.client, this.baseUrl);
2593
2713
  this.profileApi = new ProfileApi(this.client, this.baseUrl);
2594
2714
  this.registerApi = new RegistrationApi(this.client, this.baseUrl);
2595
2715
  this.addressApi = new AddressApi(this.client, this.baseUrl);
@@ -2612,6 +2732,7 @@ var BzbsService = class {
2612
2732
  this.notificationApi.setBaseUrl(baseUrl);
2613
2733
  this.placeApi.setBaseUrl(baseUrl);
2614
2734
  this.pointLogApi.setBaseUrl(baseUrl);
2735
+ this.pointApi.setBaseUrl(baseUrl);
2615
2736
  this.profileApi.setBaseUrl(baseUrl);
2616
2737
  this.registerApi.setBaseUrl(baseUrl);
2617
2738
  this.addressApi.setBaseUrl(baseUrl);
@@ -2647,6 +2768,7 @@ export {
2647
2768
  LineApi,
2648
2769
  NotificationApi,
2649
2770
  PlaceApi,
2771
+ PointApi,
2650
2772
  PointLogApi,
2651
2773
  ProfileApi,
2652
2774
  RegistrationApi,