@natyapp/meta 1.2.0 → 1.3.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/README.md CHANGED
@@ -1,60 +1,60 @@
1
- # SDK MICROSSERVIÇO SECRETARIA NATY / META
2
-
3
- ## `_UNDER DEVELOPMENT_ `
4
-
5
- <!-- `(Will not work until March, please wait the Release)` -->
6
-
7
- <!-- ## HOW WILL WORK -->
8
-
9
- ##### First we will import and Initialize the sdk package
10
-
11
- 1. importing the package
12
-
13
- ```
14
- import SDKMeta from "NatyMeta"
15
- ```
16
-
17
- 2. initialize the class
18
-
19
- ```
20
- const SDK = new NatyMeta()
21
- // you can use new sdk(`YOUR-APP-TOKEN`) to connect right on the class creation
22
- ```
23
-
24
- 3. connect your app token (if you dont use your token on class creation)
25
-
26
- ```
27
- const connectSDK = await SDK.connect( {apptoken: { `YOUR-APP-TOKEN` } } )
28
-
29
- if(connectSDK.isError) throw new Error(connectSDK.isError.message)
30
-
31
- console.log(connectSDK.isSuccess)
32
- // Do what you need with the data... (connectSDK.isSuccess)
33
- ```
34
-
35
- 4. connect your app token (if you dont use your token on class creation)
36
-
37
- ```
38
- SDK.on('message', (res) => {
39
- res.sendTextMessage("teste");
40
- });
41
- ```
42
-
43
- 3. than set your application context to use all the individual classes
44
-
45
- #### In this example:
46
-
47
- - Retun of any Promise is {isSuccess:AuthReturnType, isError:ErrorHandlingType}
48
- - If successed method (like the SDK.connect example too),
49
- the sdk will abstract and will handle properly with the token for you,
50
- the token will be automatic joined into axios instance header
51
- - ErrorHandling type { code: number, message: string | Object }
52
- - On the exemple, we are using "throw new Error" on every ErrorHandling to
53
- stop and handle it on a simple way, but u can work at your way like
54
- returning an alert using some alert lib like toastfy for the user.
55
-
56
- <!-- ## Click on [NatyMeta](https://whatsapp.secretarianaty.com) for more information. -->
57
-
58
- ##### (The link will be avalible soon)
59
-
60
- ###### All Rights Reserved for Ikiradev
1
+ # SDK MICROSSERVIÇO SECRETARIA NATY / META
2
+
3
+ ## `_UNDER DEVELOPMENT_ `
4
+
5
+ <!-- `(Will not work until March, please wait the Release)` -->
6
+
7
+ <!-- ## HOW WILL WORK -->
8
+
9
+ ##### First we will import and Initialize the sdk package
10
+
11
+ 1. importing the package
12
+
13
+ ```
14
+ import SDKMeta from "NatyMeta"
15
+ ```
16
+
17
+ 2. initialize the class
18
+
19
+ ```
20
+ const SDK = new NatyMeta()
21
+ // you can use new sdk(`YOUR-APP-TOKEN`) to connect right on the class creation
22
+ ```
23
+
24
+ 3. connect your app token (if you dont use your token on class creation)
25
+
26
+ ```
27
+ const connectSDK = await SDK.connect( {apptoken: { `YOUR-APP-TOKEN` } } )
28
+
29
+ if(connectSDK.isError) throw new Error(connectSDK.isError.message)
30
+
31
+ console.log(connectSDK.isSuccess)
32
+ // Do what you need with the data... (connectSDK.isSuccess)
33
+ ```
34
+
35
+ 4. connect your app token (if you dont use your token on class creation)
36
+
37
+ ```
38
+ SDK.on('message', (res) => {
39
+ res.sendTextMessage("teste");
40
+ });
41
+ ```
42
+
43
+ 3. than set your application context to use all the individual classes
44
+
45
+ #### In this example:
46
+
47
+ - Retun of any Promise is {isSuccess:AuthReturnType, isError:ErrorHandlingType}
48
+ - If successed method (like the SDK.connect example too),
49
+ the sdk will abstract and will handle properly with the token for you,
50
+ the token will be automatic joined into axios instance header
51
+ - ErrorHandling type { code: number, message: string | Object }
52
+ - On the exemple, we are using "throw new Error" on every ErrorHandling to
53
+ stop and handle it on a simple way, but u can work at your way like
54
+ returning an alert using some alert lib like toastfy for the user.
55
+
56
+ <!-- ## Click on [NatyMeta](https://whatsapp.secretarianaty.com) for more information. -->
57
+
58
+ ##### (The link will be avalible soon)
59
+
60
+ ###### All Rights Reserved for Ikiradev
@@ -20,11 +20,13 @@ class WhatsappResponse {
20
20
  }
21
21
  async getApiInstanceToken() {
22
22
  var _a;
23
- const connection = await services_1.connectionMutations.SearchOne("phoneNumberId", this.phone_number_id);
23
+ const connection = await services_1.connectionMutations.getAll({page:0,size:1000});
24
24
  const { isSuccess, isError } = connection;
25
+ const thisInstance = isSuccess?.find(item=>item.id === `${this.companyId}/${this.phone_number_id}`)
26
+ console.log(`log from api updated`,{thisInstance,companyId:this.companyId,phoneNumberId:this.phone_number_id})
25
27
  if (isError)
26
28
  return;
27
- const token = (_a = isSuccess[0]) === null || _a === void 0 ? void 0 : _a.accessToken;
29
+ const token = (_a = thisInstance) === null || _a === void 0 ? void 0 : _a.accessToken;
28
30
  this.token = token;
29
31
  this.apiCall = (0, services_1.newAxiosInstance)({
30
32
  phone_number_id: this.phone_number_id,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@natyapp/meta",
3
- "version": "1.2.0",
3
+ "version": "1.3.0",
4
4
  "description": "",
5
5
  "main": "./dist/index.js",
6
6
  "types": "./dist/index.d.ts",