@bzbs/react-api-client 0.2.2 → 0.2.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/dist/index.d.mts CHANGED
@@ -14,6 +14,8 @@ type ServiceResponse<T> = SuccessResponse<T> | ErrorResponse;
14
14
  interface ApiResponse<T> {
15
15
  Success: boolean;
16
16
  Data: T;
17
+ success: boolean;
18
+ data: T;
17
19
  }
18
20
  type SuccessResponse<T> = {
19
21
  type: 'success';
@@ -47,6 +49,7 @@ declare class BaseService {
47
49
  private baseUrl;
48
50
  constructor(client: AxiosInstance, baseUrl: string);
49
51
  private normalizeError;
52
+ private normalizeResponse;
50
53
  private request;
51
54
  get<T>(path: string, params?: any, requestOptions?: RequestOptions): Promise<ServiceResponse<T>>;
52
55
  post<T>(path: string, data: any, requestOptions?: RequestOptions): Promise<ServiceResponse<T>>;
@@ -2669,7 +2672,7 @@ declare class BzbsService {
2669
2672
  couponApi: CouponApi;
2670
2673
  dashboardApi: DashboardApi;
2671
2674
  historyApi: HistoryApi;
2672
- lineApi: LineApi;
2675
+ lineApi: LineApi | undefined;
2673
2676
  notificationApi: NotificationApi;
2674
2677
  placeApi: PlaceApi;
2675
2678
  pointLogApi: PointLogApi;
@@ -2679,7 +2682,7 @@ declare class BzbsService {
2679
2682
  stampApi: StampApi;
2680
2683
  forumApi: RequestHelpApi;
2681
2684
  blob: Blob;
2682
- constructor(client: AxiosInstance, baseUrl: string, baseLineUrl: string, baseBlobUrl: string);
2685
+ constructor(client: AxiosInstance, baseUrl: string, baseLineUrl: string | "", baseBlobUrl: string);
2683
2686
  }
2684
2687
 
2685
2688
  export { type Address, AddressApi, type ApiResponse, AuthenticateApi, type Badge, BadgeApi, BaseService, Blob, type Buzzebees, type BzbsErrorResponse, BzbsService, type Campaign, CampaignApi, type CampaignDetail, type CartAccessResponse, CartApi, type CartCountResponse, type Category, CategoryApi, type ChatMessage, type ClientError, type ConfirmOtpResponse, type Consent, ConsentApi, type ConsentVersion, type ConsentVersionValue, CouponApi, type CouponResponse, type CouponResponseData, type CreateStampResponse, type Dashboard, DashboardApi, type Detail, type District, type ErrorResponse, type ExpiringPoints, type FavoriteResponse, type ForgetPasswordResponse, HistoryApi, type LikeForumResponse, LineApi, type LineAuthResponse, type LoginResponse, type Maintenance, type Mission, type Notification, NotificationApi, type OtpResponse, type Picture, type Place, PlaceApi, type PlaceService, type PointLog, PointLogApi, ProfileApi, type ProfileResponse, type Province, type Purchase, type RedeemResponse, RegistrationApi, type RegistrationResponse, RequestHelpApi, type RequestHelpCode, type RequestOptions, type ResumeResponse, type ServerError, type ServiceResponse, type Stamp, StampApi, type StampCampaign, type StampHistory, type StampProfileResponse, type StatusResponse, type Style, type SubCampaign, type SubCampaignStyle, type SubDistrict, type SuccessResponse, type Trace, type UpdatedPoints, type UseCampaignResponse, type ValidateOtpResponse, type Version, type ZipCode };
package/dist/index.d.ts CHANGED
@@ -14,6 +14,8 @@ type ServiceResponse<T> = SuccessResponse<T> | ErrorResponse;
14
14
  interface ApiResponse<T> {
15
15
  Success: boolean;
16
16
  Data: T;
17
+ success: boolean;
18
+ data: T;
17
19
  }
18
20
  type SuccessResponse<T> = {
19
21
  type: 'success';
@@ -47,6 +49,7 @@ declare class BaseService {
47
49
  private baseUrl;
48
50
  constructor(client: AxiosInstance, baseUrl: string);
49
51
  private normalizeError;
52
+ private normalizeResponse;
50
53
  private request;
51
54
  get<T>(path: string, params?: any, requestOptions?: RequestOptions): Promise<ServiceResponse<T>>;
52
55
  post<T>(path: string, data: any, requestOptions?: RequestOptions): Promise<ServiceResponse<T>>;
@@ -2669,7 +2672,7 @@ declare class BzbsService {
2669
2672
  couponApi: CouponApi;
2670
2673
  dashboardApi: DashboardApi;
2671
2674
  historyApi: HistoryApi;
2672
- lineApi: LineApi;
2675
+ lineApi: LineApi | undefined;
2673
2676
  notificationApi: NotificationApi;
2674
2677
  placeApi: PlaceApi;
2675
2678
  pointLogApi: PointLogApi;
@@ -2679,7 +2682,7 @@ declare class BzbsService {
2679
2682
  stampApi: StampApi;
2680
2683
  forumApi: RequestHelpApi;
2681
2684
  blob: Blob;
2682
- constructor(client: AxiosInstance, baseUrl: string, baseLineUrl: string, baseBlobUrl: string);
2685
+ constructor(client: AxiosInstance, baseUrl: string, baseLineUrl: string | "", baseBlobUrl: string);
2683
2686
  }
2684
2687
 
2685
2688
  export { type Address, AddressApi, type ApiResponse, AuthenticateApi, type Badge, BadgeApi, BaseService, Blob, type Buzzebees, type BzbsErrorResponse, BzbsService, type Campaign, CampaignApi, type CampaignDetail, type CartAccessResponse, CartApi, type CartCountResponse, type Category, CategoryApi, type ChatMessage, type ClientError, type ConfirmOtpResponse, type Consent, ConsentApi, type ConsentVersion, type ConsentVersionValue, CouponApi, type CouponResponse, type CouponResponseData, type CreateStampResponse, type Dashboard, DashboardApi, type Detail, type District, type ErrorResponse, type ExpiringPoints, type FavoriteResponse, type ForgetPasswordResponse, HistoryApi, type LikeForumResponse, LineApi, type LineAuthResponse, type LoginResponse, type Maintenance, type Mission, type Notification, NotificationApi, type OtpResponse, type Picture, type Place, PlaceApi, type PlaceService, type PointLog, PointLogApi, ProfileApi, type ProfileResponse, type Province, type Purchase, type RedeemResponse, RegistrationApi, type RegistrationResponse, RequestHelpApi, type RequestHelpCode, type RequestOptions, type ResumeResponse, type ServerError, type ServiceResponse, type Stamp, StampApi, type StampCampaign, type StampHistory, type StampProfileResponse, type StatusResponse, type Style, type SubCampaign, type SubCampaignStyle, type SubDistrict, type SuccessResponse, type Trace, type UpdatedPoints, type UseCampaignResponse, type ValidateOtpResponse, type Version, type ZipCode };
package/dist/index.js CHANGED
@@ -114,6 +114,48 @@ var BaseService = class {
114
114
  details: error
115
115
  };
116
116
  }
117
+ normalizeResponse(response) {
118
+ if (response.status === 204) {
119
+ return { model: {}, response, type: "success" };
120
+ }
121
+ if ("Success" in response.data || "success" in response.data) {
122
+ const data = response.data;
123
+ if (data.Success) {
124
+ if ("Data" in response.data) {
125
+ return { model: data.Data, response, type: "success" };
126
+ } else if ("data" in response.data) {
127
+ return { model: data.data, response, type: "success" };
128
+ } else {
129
+ return { model: {}, response, type: "success" };
130
+ }
131
+ } else if (data.success) {
132
+ if ("Data" in response.data) {
133
+ return { model: data.Data, response, type: "success" };
134
+ } else if ("data" in response.data) {
135
+ return { model: data.data, response, type: "success" };
136
+ } else {
137
+ return { model: {}, response, type: "success" };
138
+ }
139
+ } else {
140
+ const error = {
141
+ type: "server-error",
142
+ error: {
143
+ requestId: response.data.RequestId || "",
144
+ error: {
145
+ id: response.data.Code || response.status,
146
+ message: response.data.Message || response.statusText,
147
+ code: response.data.Code || response.status,
148
+ type: "buzzebees"
149
+ }
150
+ },
151
+ statusCode: response.data.Code || response.status,
152
+ response
153
+ };
154
+ return this.normalizeError(error);
155
+ }
156
+ }
157
+ return { model: response.data, response, type: "success" };
158
+ }
117
159
  request(method, path, data, requestOptions) {
118
160
  return __async(this, null, function* () {
119
161
  var _a;
@@ -125,41 +167,13 @@ var BaseService = class {
125
167
  data
126
168
  };
127
169
  const response = yield this.client.request(__spreadValues({ method, url }, config));
128
- if (response.status === 204) {
129
- return { model: "", response, type: "success" };
130
- }
131
- if ("Success" in response.data) {
132
- const data2 = response.data;
133
- if (data2.Success) {
134
- if ("Data" in response.data) {
135
- return { model: data2.Data, response, type: "success" };
136
- } else {
137
- return { model: "", response, type: "success" };
138
- }
139
- } else {
140
- const error = {
141
- type: "server-error",
142
- error: {
143
- requestId: response.data.RequestId || "",
144
- error: {
145
- id: response.data.Code || 500,
146
- message: response.data.Message || "An unexpected error occurred.",
147
- code: response.data.Code || 500,
148
- type: "buzzebees"
149
- }
150
- },
151
- statusCode: response.data.Code || 500,
152
- response
153
- };
154
- return this.normalizeError(error);
155
- }
156
- }
157
- return { model: response.data, response, type: "success" };
170
+ return this.normalizeResponse(response);
158
171
  } catch (error) {
159
172
  return this.normalizeError(error);
160
173
  }
161
174
  });
162
175
  }
176
+ /* if blob type we not include header in requestOptions */
163
177
  get(path, params, requestOptions) {
164
178
  return __async(this, null, function* () {
165
179
  return this.request("get", path, void 0, __spreadProps(__spreadValues({}, requestOptions), { params }));
@@ -2307,7 +2321,9 @@ var BzbsService = class {
2307
2321
  this.couponApi = new CouponApi(this.client, this.baseUrl);
2308
2322
  this.dashboardApi = new DashboardApi(this.client, this.baseUrl);
2309
2323
  this.historyApi = new HistoryApi(this.client, this.baseUrl);
2310
- this.lineApi = new LineApi(this.client, this.baseLineUrl);
2324
+ if (this.baseLineUrl) {
2325
+ this.lineApi = new LineApi(this.client, this.baseLineUrl);
2326
+ }
2311
2327
  this.notificationApi = new NotificationApi(this.client, this.baseUrl);
2312
2328
  this.placeApi = new PlaceApi(this.client, this.baseUrl);
2313
2329
  this.pointLogApi = new PointLogApi(this.client, this.baseUrl);