@bzbs/react-api-client 1.0.1 → 1.0.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/README.md +82 -82
- package/dist/index.d.mts +10 -0
- package/dist/index.d.ts +10 -0
- package/dist/index.js +6 -8
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +3 -5
- 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.d.mts
CHANGED
|
@@ -696,6 +696,16 @@ interface ProfileResponse {
|
|
|
696
696
|
LineMarketing?: number;
|
|
697
697
|
updated_points?: UpdatedPoints;
|
|
698
698
|
Token?: string;
|
|
699
|
+
Info1?: string;
|
|
700
|
+
Info2?: string;
|
|
701
|
+
Info3?: string;
|
|
702
|
+
Info4?: string;
|
|
703
|
+
Info5?: string;
|
|
704
|
+
Info6?: string;
|
|
705
|
+
Info7?: string;
|
|
706
|
+
Info8?: string;
|
|
707
|
+
Info9?: string;
|
|
708
|
+
Info10?: string;
|
|
699
709
|
}
|
|
700
710
|
|
|
701
711
|
interface Purchase {
|
package/dist/index.d.ts
CHANGED
|
@@ -696,6 +696,16 @@ interface ProfileResponse {
|
|
|
696
696
|
LineMarketing?: number;
|
|
697
697
|
updated_points?: UpdatedPoints;
|
|
698
698
|
Token?: string;
|
|
699
|
+
Info1?: string;
|
|
700
|
+
Info2?: string;
|
|
701
|
+
Info3?: string;
|
|
702
|
+
Info4?: string;
|
|
703
|
+
Info5?: string;
|
|
704
|
+
Info6?: string;
|
|
705
|
+
Info7?: string;
|
|
706
|
+
Info8?: string;
|
|
707
|
+
Info9?: string;
|
|
708
|
+
Info10?: string;
|
|
699
709
|
}
|
|
700
710
|
|
|
701
711
|
interface Purchase {
|
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 index_exports = {};
|
|
59
|
+
__export(index_exports, {
|
|
60
60
|
AddressApi: () => AddressApi,
|
|
61
61
|
AuthenticateApi: () => AuthenticateApi,
|
|
62
62
|
BadgeApi: () => BadgeApi,
|
|
@@ -79,15 +79,13 @@ __export(src_exports, {
|
|
|
79
79
|
RequestHelpApi: () => RequestHelpApi,
|
|
80
80
|
StampApi: () => StampApi
|
|
81
81
|
});
|
|
82
|
-
module.exports = __toCommonJS(
|
|
82
|
+
module.exports = __toCommonJS(index_exports);
|
|
83
83
|
|
|
84
84
|
// src/api/base-service.ts
|
|
85
85
|
var BaseService = class {
|
|
86
86
|
constructor(client, baseUrl) {
|
|
87
|
-
if (!client)
|
|
88
|
-
|
|
89
|
-
if (!baseUrl)
|
|
90
|
-
throw new Error("Base URL is required.");
|
|
87
|
+
if (!client) throw new Error("Axios client is required.");
|
|
88
|
+
if (!baseUrl) throw new Error("Base URL is required.");
|
|
91
89
|
this.client = client;
|
|
92
90
|
this.baseUrl = baseUrl;
|
|
93
91
|
}
|
|
@@ -568,7 +566,7 @@ var AuthenticateApi = class extends BaseService {
|
|
|
568
566
|
validateOtp(params, requestOptions) {
|
|
569
567
|
return __async(this, null, function* () {
|
|
570
568
|
return yield this.post(
|
|
571
|
-
"auth/
|
|
569
|
+
"auth/validate_otp",
|
|
572
570
|
__spreadValues({
|
|
573
571
|
app_id: params.appId,
|
|
574
572
|
otp: params.otp,
|