@bzbs/react-api-client 1.0.0 → 1.0.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 +82 -82
- package/dist/index.js +20 -6
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +17 -3
- package/dist/index.mjs.map +1 -1
- package/package.json +63 -63
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.js
CHANGED
|
@@ -55,8 +55,8 @@ var __async = (__this, __arguments, generator) => {
|
|
|
55
55
|
};
|
|
56
56
|
|
|
57
57
|
// src/index.ts
|
|
58
|
-
var
|
|
59
|
-
__export(
|
|
58
|
+
var src_exports = {};
|
|
59
|
+
__export(src_exports, {
|
|
60
60
|
AddressApi: () => AddressApi,
|
|
61
61
|
AuthenticateApi: () => AuthenticateApi,
|
|
62
62
|
BadgeApi: () => BadgeApi,
|
|
@@ -79,13 +79,15 @@ __export(index_exports, {
|
|
|
79
79
|
RequestHelpApi: () => RequestHelpApi,
|
|
80
80
|
StampApi: () => StampApi
|
|
81
81
|
});
|
|
82
|
-
module.exports = __toCommonJS(
|
|
82
|
+
module.exports = __toCommonJS(src_exports);
|
|
83
83
|
|
|
84
84
|
// src/api/base-service.ts
|
|
85
85
|
var BaseService = class {
|
|
86
86
|
constructor(client, baseUrl) {
|
|
87
|
-
if (!client)
|
|
88
|
-
|
|
87
|
+
if (!client)
|
|
88
|
+
throw new Error("Axios client is required.");
|
|
89
|
+
if (!baseUrl)
|
|
90
|
+
throw new Error("Base URL is required.");
|
|
89
91
|
this.client = client;
|
|
90
92
|
this.baseUrl = baseUrl;
|
|
91
93
|
}
|
|
@@ -1186,7 +1188,7 @@ var HistoryApi = class extends BaseService {
|
|
|
1186
1188
|
*/
|
|
1187
1189
|
redeemHistories(params, requestOptions) {
|
|
1188
1190
|
return __async(this, null, function* () {
|
|
1189
|
-
|
|
1191
|
+
const response = yield this.get(
|
|
1190
1192
|
"redeem",
|
|
1191
1193
|
__spreadValues({
|
|
1192
1194
|
byConfig: params.byConfig,
|
|
@@ -1199,6 +1201,18 @@ var HistoryApi = class extends BaseService {
|
|
|
1199
1201
|
}, params.options),
|
|
1200
1202
|
requestOptions
|
|
1201
1203
|
);
|
|
1204
|
+
if (response.type === "success") {
|
|
1205
|
+
const purchases = response.model.map((item) => {
|
|
1206
|
+
var _a, _b;
|
|
1207
|
+
return __spreadProps(__spreadValues({}, item), {
|
|
1208
|
+
ParcelNo: (_b = (_a = item.ParcelNo) != null ? _a : item.PacelNo) != null ? _b : void 0
|
|
1209
|
+
});
|
|
1210
|
+
});
|
|
1211
|
+
return __spreadProps(__spreadValues({}, response), {
|
|
1212
|
+
model: purchases
|
|
1213
|
+
});
|
|
1214
|
+
}
|
|
1215
|
+
return response;
|
|
1202
1216
|
});
|
|
1203
1217
|
}
|
|
1204
1218
|
/**
|