@bzbs/react-api-client 0.1.13 → 0.2.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/README.md CHANGED
@@ -1,82 +1,82 @@
1
- # Installing
2
-
3
- Using npm :
4
-
5
- ```bash
6
- npm i @bzbs/react-api-client
7
- ```
8
-
9
- Once the package is installed, you can import the library using import or require approach:
10
-
11
- ```js
12
- import { BzbsService } from '@bzbs/react-api-client';
13
- ```
14
-
15
- You must to have AxiosInstance, Base URL and Line URL for library require:
16
-
17
- ```js
18
- const axiosClient = axios.create({});
19
- const baseUrl = 'https://www.xxx-api.com/api/';
20
- const lineUrl = 'https://api.line.me/v2/bot/';
21
- ```
22
-
23
- And defind const and export libraty to using:
24
-
25
- ```js
26
- export const bzbsService = new BzbsService(axiosClient, baseUrl, lineUrl);
27
- ```
28
-
29
- If you have default header you can add to AxiosInstance brfore:
30
-
31
- ```js
32
- const defaultOptions = {
33
- headers: {
34
- 'Content-Type': 'application/json, multipart/form-data',
35
- 'App-Id': 2952697274802274,
36
- 'Ocp-Apim-Subscription-Key': '89c1d9bafb65486aa02606f63cb86b5c',
37
- },
38
- };
39
-
40
- axiosClient.defaults.headers.common = defaultOptions.headers;
41
- ```
42
-
43
- ## Example
44
-
45
- Create service-config.tsx file:
46
-
47
- ```tsx
48
- import { BzbsService } from '@bzbs/react-api-client';
49
- import axios from 'axios';
50
-
51
- const defaultOptions = {
52
- headers: {
53
- 'Content-Type': 'application/json, multipart/form-data',
54
- 'App-Id': 2952697274802274,
55
- 'Ocp-Apim-Subscription-Key': '89c1d9bafb65486aa02606f63cb86b5c',
56
- },
57
- };
58
-
59
- var axiosClient = axios.create({});
60
- axiosClient.defaults.headers.common = defaultOptions.headers;
61
-
62
- const baseUrl = 'https://apigateway.buzzebees-uat.com/api/';
63
- const lineUrl = 'https://api.line.me/v2/bot/';
64
-
65
- export const bzbsService = new BzbsService(axiosClient, baseUrl, lineUrl);
66
- ```
67
-
68
- Using service API in another files:
69
-
70
- ```tsx
71
- import { bzbsService } from './src/service-config';
72
-
73
- const campaigList = async () => {
74
- await bzbsService.campaignApi?.campaign({
75
- config: 'campaign_buzzebeesdemo',
76
- byConfig: true,
77
- skip: 0,
78
- top: 10,
79
- deviceLocale: 1054,
80
- });
81
- };
82
- ```
1
+ # Installing
2
+
3
+ Using npm :
4
+
5
+ ```bash
6
+ npm i @bzbs/react-api-client
7
+ ```
8
+
9
+ Once the package is installed, you can import the library using import or require approach:
10
+
11
+ ```js
12
+ import { BzbsService } from '@bzbs/react-api-client';
13
+ ```
14
+
15
+ You must to have AxiosInstance, Base URL and Line URL for library require:
16
+
17
+ ```js
18
+ const axiosClient = axios.create({});
19
+ const baseUrl = 'https://www.xxx-api.com/api/';
20
+ const lineUrl = 'https://api.line.me/v2/bot/';
21
+ ```
22
+
23
+ And defind const and export libraty to using:
24
+
25
+ ```js
26
+ export const bzbsService = new BzbsService(axiosClient, baseUrl, lineUrl);
27
+ ```
28
+
29
+ If you have default header you can add to AxiosInstance brfore:
30
+
31
+ ```js
32
+ const defaultOptions = {
33
+ headers: {
34
+ 'Content-Type': 'application/json, multipart/form-data',
35
+ 'App-Id': 2952697274802274,
36
+ 'Ocp-Apim-Subscription-Key': '89c1d9bafb65486aa02606f63cb86b5c',
37
+ },
38
+ };
39
+
40
+ axiosClient.defaults.headers.common = defaultOptions.headers;
41
+ ```
42
+
43
+ ## Example
44
+
45
+ Create service-config.tsx file:
46
+
47
+ ```tsx
48
+ import { BzbsService } from '@bzbs/react-api-client';
49
+ import axios from 'axios';
50
+
51
+ const defaultOptions = {
52
+ headers: {
53
+ 'Content-Type': 'application/json, multipart/form-data',
54
+ 'App-Id': 2952697274802274,
55
+ 'Ocp-Apim-Subscription-Key': '89c1d9bafb65486aa02606f63cb86b5c',
56
+ },
57
+ };
58
+
59
+ var axiosClient = axios.create({});
60
+ axiosClient.defaults.headers.common = defaultOptions.headers;
61
+
62
+ const baseUrl = 'https://apigateway.buzzebees-uat.com/api/';
63
+ const lineUrl = 'https://api.line.me/v2/bot/';
64
+
65
+ export const bzbsService = new BzbsService(axiosClient, baseUrl, lineUrl);
66
+ ```
67
+
68
+ Using service API in another files:
69
+
70
+ ```tsx
71
+ import { bzbsService } from './src/service-config';
72
+
73
+ const campaigList = async () => {
74
+ await bzbsService.campaignApi?.campaign({
75
+ config: 'campaign_buzzebeesdemo',
76
+ byConfig: true,
77
+ skip: 0,
78
+ top: 10,
79
+ deviceLocale: 1054,
80
+ });
81
+ };
82
+ ```
package/dist/index.d.mts CHANGED
@@ -11,6 +11,10 @@ interface BzbsErrorResponse {
11
11
  }
12
12
 
13
13
  type ServiceResponse<T> = SuccessResponse<T> | ErrorResponse;
14
+ interface ApiResponse<T> {
15
+ Success: boolean;
16
+ Data: T;
17
+ }
14
18
  type SuccessResponse<T> = {
15
19
  type: 'success';
16
20
  model: T;
@@ -1103,6 +1107,38 @@ interface SubDistrict {
1103
1107
  zip_code?: string;
1104
1108
  }
1105
1109
 
1110
+ interface Maintenance {
1111
+ header_primary: string;
1112
+ button_text_primary: string;
1113
+ button_text_secondary: string;
1114
+ header_secondary: string;
1115
+ message_primary: string;
1116
+ message_secondary: string;
1117
+ enabled: boolean;
1118
+ landing_url: string;
1119
+ [key: string]: unknown;
1120
+ }
1121
+
1122
+ interface ConsentVersion {
1123
+ AnalyticsOtherCookies: ConsentVersionValue;
1124
+ AnalyticsGoogleCookies: ConsentVersionValue;
1125
+ FunctionalCookies: ConsentVersionValue;
1126
+ NecessaryCookies: ConsentVersionValue;
1127
+ AnalyticsFirebaseCookies: ConsentVersionValue;
1128
+ marketing: ConsentVersionValue;
1129
+ privacy: ConsentVersionValue;
1130
+ terms: ConsentVersionValue;
1131
+ MarketingCookies: ConsentVersionValue;
1132
+ AnalyticsMetaCookies: ConsentVersionValue;
1133
+ AnalyticsBuzzebeesCookies: ConsentVersionValue;
1134
+ cookie: ConsentVersionValue;
1135
+ [key: string]: unknown;
1136
+ }
1137
+ interface ConsentVersionValue {
1138
+ latest_version: string;
1139
+ current_version: string;
1140
+ }
1141
+
1106
1142
  declare class AuthenticateApi extends BaseService {
1107
1143
  constructor(client: AxiosInstance, baseUrl: string);
1108
1144
  /**
@@ -2612,10 +2648,18 @@ declare class RequestHelpApi extends BaseService {
2612
2648
  }, requestOptions?: RequestOptions): Promise<ServiceResponse<LikeForumResponse>>;
2613
2649
  }
2614
2650
 
2651
+ declare class Blob extends BaseService {
2652
+ constructor(client: AxiosInstance, baseUrl: string);
2653
+ consentVersion(appId: string): Promise<ServiceResponse<ConsentVersion>>;
2654
+ maintenance(appId: string): Promise<ServiceResponse<Maintenance>>;
2655
+ blob(path: string, requestOptions?: RequestOptions): Promise<ServiceResponse<unknown>>;
2656
+ }
2657
+
2615
2658
  declare class BzbsService {
2616
2659
  client: AxiosInstance;
2617
2660
  baseUrl: string;
2618
2661
  baseLineUrl: string;
2662
+ baseBlobUrl: string;
2619
2663
  authApi: AuthenticateApi;
2620
2664
  badgeApi: BadgeApi;
2621
2665
  campaignApi: CampaignApi;
@@ -2634,7 +2678,8 @@ declare class BzbsService {
2634
2678
  addressApi: AddressApi;
2635
2679
  stampApi: StampApi;
2636
2680
  forumApi: RequestHelpApi;
2637
- constructor(client: AxiosInstance, baseUrl: string, baseLineUrl: string);
2681
+ blob: Blob;
2682
+ constructor(client: AxiosInstance, baseUrl: string, baseLineUrl: string, baseBlobUrl: string);
2638
2683
  }
2639
2684
 
2640
- export { type Address, AddressApi, AuthenticateApi, type Badge, BadgeApi, BaseService, 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, 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 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 };
2685
+ 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
@@ -11,6 +11,10 @@ interface BzbsErrorResponse {
11
11
  }
12
12
 
13
13
  type ServiceResponse<T> = SuccessResponse<T> | ErrorResponse;
14
+ interface ApiResponse<T> {
15
+ Success: boolean;
16
+ Data: T;
17
+ }
14
18
  type SuccessResponse<T> = {
15
19
  type: 'success';
16
20
  model: T;
@@ -1103,6 +1107,38 @@ interface SubDistrict {
1103
1107
  zip_code?: string;
1104
1108
  }
1105
1109
 
1110
+ interface Maintenance {
1111
+ header_primary: string;
1112
+ button_text_primary: string;
1113
+ button_text_secondary: string;
1114
+ header_secondary: string;
1115
+ message_primary: string;
1116
+ message_secondary: string;
1117
+ enabled: boolean;
1118
+ landing_url: string;
1119
+ [key: string]: unknown;
1120
+ }
1121
+
1122
+ interface ConsentVersion {
1123
+ AnalyticsOtherCookies: ConsentVersionValue;
1124
+ AnalyticsGoogleCookies: ConsentVersionValue;
1125
+ FunctionalCookies: ConsentVersionValue;
1126
+ NecessaryCookies: ConsentVersionValue;
1127
+ AnalyticsFirebaseCookies: ConsentVersionValue;
1128
+ marketing: ConsentVersionValue;
1129
+ privacy: ConsentVersionValue;
1130
+ terms: ConsentVersionValue;
1131
+ MarketingCookies: ConsentVersionValue;
1132
+ AnalyticsMetaCookies: ConsentVersionValue;
1133
+ AnalyticsBuzzebeesCookies: ConsentVersionValue;
1134
+ cookie: ConsentVersionValue;
1135
+ [key: string]: unknown;
1136
+ }
1137
+ interface ConsentVersionValue {
1138
+ latest_version: string;
1139
+ current_version: string;
1140
+ }
1141
+
1106
1142
  declare class AuthenticateApi extends BaseService {
1107
1143
  constructor(client: AxiosInstance, baseUrl: string);
1108
1144
  /**
@@ -2612,10 +2648,18 @@ declare class RequestHelpApi extends BaseService {
2612
2648
  }, requestOptions?: RequestOptions): Promise<ServiceResponse<LikeForumResponse>>;
2613
2649
  }
2614
2650
 
2651
+ declare class Blob extends BaseService {
2652
+ constructor(client: AxiosInstance, baseUrl: string);
2653
+ consentVersion(appId: string): Promise<ServiceResponse<ConsentVersion>>;
2654
+ maintenance(appId: string): Promise<ServiceResponse<Maintenance>>;
2655
+ blob(path: string, requestOptions?: RequestOptions): Promise<ServiceResponse<unknown>>;
2656
+ }
2657
+
2615
2658
  declare class BzbsService {
2616
2659
  client: AxiosInstance;
2617
2660
  baseUrl: string;
2618
2661
  baseLineUrl: string;
2662
+ baseBlobUrl: string;
2619
2663
  authApi: AuthenticateApi;
2620
2664
  badgeApi: BadgeApi;
2621
2665
  campaignApi: CampaignApi;
@@ -2634,7 +2678,8 @@ declare class BzbsService {
2634
2678
  addressApi: AddressApi;
2635
2679
  stampApi: StampApi;
2636
2680
  forumApi: RequestHelpApi;
2637
- constructor(client: AxiosInstance, baseUrl: string, baseLineUrl: string);
2681
+ blob: Blob;
2682
+ constructor(client: AxiosInstance, baseUrl: string, baseLineUrl: string, baseBlobUrl: string);
2638
2683
  }
2639
2684
 
2640
- export { type Address, AddressApi, AuthenticateApi, type Badge, BadgeApi, BaseService, 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, 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 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 };
2685
+ 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
@@ -61,6 +61,7 @@ __export(src_exports, {
61
61
  AuthenticateApi: () => AuthenticateApi,
62
62
  BadgeApi: () => BadgeApi,
63
63
  BaseService: () => BaseService,
64
+ Blob: () => Blob,
64
65
  BzbsService: () => BzbsService,
65
66
  CampaignApi: () => CampaignApi,
66
67
  CartApi: () => CartApi,
@@ -116,6 +117,35 @@ var BaseService = class {
116
117
  data
117
118
  };
118
119
  const response = yield this.client.request(__spreadValues({ method, url }, config));
120
+ if (response.status === 204) {
121
+ return { model: "", response, type: "success" };
122
+ }
123
+ if ("Success" in response.data) {
124
+ const data2 = response.data;
125
+ if (data2.Success) {
126
+ if ("Data" in response.data) {
127
+ return { model: data2.Data, response, type: "success" };
128
+ } else {
129
+ return { model: "", response, type: "success" };
130
+ }
131
+ } else {
132
+ const error = {
133
+ type: "server-error",
134
+ error: {
135
+ requestId: response.data.RequestId || "",
136
+ error: {
137
+ id: response.data.Code || 500,
138
+ message: response.data.Message || "An unexpected error occurred.",
139
+ code: response.data.Code || 500,
140
+ type: "buzzebees"
141
+ }
142
+ },
143
+ statusCode: response.data.Code || 500,
144
+ response
145
+ };
146
+ return this.normalizeError(error);
147
+ }
148
+ }
119
149
  return { model: response.data, response, type: "success" };
120
150
  } catch (error) {
121
151
  return this.normalizeError(error);
@@ -2231,13 +2261,35 @@ var RequestHelpApi = class extends BaseService {
2231
2261
  }
2232
2262
  };
2233
2263
 
2264
+ // src/api/blob/blob.ts
2265
+ var Blob = class extends BaseService {
2266
+ constructor(client, baseUrl) {
2267
+ super(client, baseUrl);
2268
+ }
2269
+ consentVersion(appId) {
2270
+ return __async(this, null, function* () {
2271
+ return this.get(`pdpaconsent/${appId}/version`);
2272
+ });
2273
+ }
2274
+ maintenance(appId) {
2275
+ return __async(this, null, function* () {
2276
+ return this.get(`config/maintenance/${appId}.json`);
2277
+ });
2278
+ }
2279
+ blob(path, requestOptions) {
2280
+ return __async(this, null, function* () {
2281
+ return this.get(path, requestOptions);
2282
+ });
2283
+ }
2284
+ };
2285
+
2234
2286
  // src/api/bzbs-service.ts
2235
2287
  var BzbsService = class {
2236
- constructor(client, baseUrl, baseLineUrl) {
2237
- var _a;
2288
+ constructor(client, baseUrl, baseLineUrl, baseBlobUrl) {
2238
2289
  this.client = client;
2239
2290
  this.baseUrl = baseUrl;
2240
2291
  this.baseLineUrl = baseLineUrl;
2292
+ this.baseBlobUrl = baseBlobUrl;
2241
2293
  this.authApi = new AuthenticateApi(this.client, this.baseUrl);
2242
2294
  this.badgeApi = new BadgeApi(this.client, this.baseUrl);
2243
2295
  this.campaignApi = new CampaignApi(this.client, this.baseUrl);
@@ -2247,7 +2299,7 @@ var BzbsService = class {
2247
2299
  this.couponApi = new CouponApi(this.client, this.baseUrl);
2248
2300
  this.dashboardApi = new DashboardApi(this.client, this.baseUrl);
2249
2301
  this.historyApi = new HistoryApi(this.client, this.baseUrl);
2250
- this.lineApi = new LineApi(this.client, (_a = this.baseLineUrl) != null ? _a : "");
2302
+ this.lineApi = new LineApi(this.client, this.baseLineUrl);
2251
2303
  this.notificationApi = new NotificationApi(this.client, this.baseUrl);
2252
2304
  this.placeApi = new PlaceApi(this.client, this.baseUrl);
2253
2305
  this.pointLogApi = new PointLogApi(this.client, this.baseUrl);
@@ -2256,6 +2308,7 @@ var BzbsService = class {
2256
2308
  this.addressApi = new AddressApi(this.client, this.baseUrl);
2257
2309
  this.stampApi = new StampApi(this.client, this.baseUrl);
2258
2310
  this.forumApi = new RequestHelpApi(this.client, this.baseUrl);
2311
+ this.blob = new Blob(this.client, this.baseBlobUrl);
2259
2312
  }
2260
2313
  };
2261
2314
  // Annotate the CommonJS export names for ESM import in node:
@@ -2264,6 +2317,7 @@ var BzbsService = class {
2264
2317
  AuthenticateApi,
2265
2318
  BadgeApi,
2266
2319
  BaseService,
2320
+ Blob,
2267
2321
  BzbsService,
2268
2322
  CampaignApi,
2269
2323
  CartApi,