@natyapp/meta 1.5.8 → 1.6.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,29 +1,37 @@
1
1
  # SDK MICROSSERVIÇO SECRETARIA NATY / META
2
2
 
3
- ## `_UNDER DEVELOPMENT_ `
3
+ ## `_UNDER DEVELOPMENT_`
4
4
 
5
5
  <!-- `(Will not work until March, please wait the Release)` -->
6
6
 
7
7
  <!-- ## HOW WILL WORK -->
8
8
 
9
- ##### First we will import and Initialize the sdk package
9
+ ### First we will import and Initialize the sdk package
10
10
 
11
- 1. importing the package
11
+ #### 1. importing the package
12
12
 
13
- ```
13
+ ```ts
14
14
  import SDKMeta from "NatyMeta"
15
15
  ```
16
16
 
17
- 2. initialize the class
17
+ #### 2. set environment variable
18
18
 
19
- ```
19
+ The API URL for the integration with the Meta API. The default value is `https://api.meta.naty.app`
20
+
21
+ ```text
22
+ API_META=https://api.meta.naty.app
23
+ ```
24
+
25
+ #### 3. initialize the class
26
+
27
+ ```ts
20
28
  const SDK = new NatyMeta()
21
29
  // you can use new sdk(`YOUR-APP-TOKEN`) to connect right on the class creation
22
30
  ```
23
31
 
24
- 3. connect your app token (if you dont use your token on class creation)
32
+ #### 4. connect your app token (if you dont use your token on class creation)
25
33
 
26
- ```
34
+ ```ts
27
35
  const connectSDK = await SDK.connect( {apptoken: { `YOUR-APP-TOKEN` } } )
28
36
 
29
37
  if(connectSDK.isError) throw new Error(connectSDK.isError.message)
@@ -32,26 +40,26 @@
32
40
  // Do what you need with the data... (connectSDK.isSuccess)
33
41
  ```
34
42
 
35
- 4. connect your app token (if you dont use your token on class creation)
43
+ #### 5. connect your app token (if you dont use your token on class creation)
36
44
 
37
- ```
45
+ ```ts
38
46
  SDK.on('message', (res) => {
39
47
  res.sendTextMessage("teste");
40
48
  });
41
49
  ```
42
50
 
43
- 3. than set your application context to use all the individual classes
51
+ #### 6. than set your application context to use all the individual classes
44
52
 
45
- #### In this example:
53
+ #### In this example
46
54
 
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
+ - Retun of any Promise is {isSuccess:AuthReturnType, isError:ErrorHandlingType}
56
+ - If successed method (like the SDK.connect example too),
57
+ the sdk will abstract and will handle properly with the token for you,
58
+ the token will be automatic joined into axios instance header
59
+ - ErrorHandling type { code: number, message: string | Object }
60
+ - On the exemple, we are using "throw new Error" on every ErrorHandling to
61
+ stop and handle it on a simple way, but u can work at your way like
62
+ returning an alert using some alert lib like toastfy for the user.
55
63
 
56
64
  <!-- ## Click on [NatyMeta](https://whatsapp.secretarianaty.com) for more information. -->
57
65
 
@@ -5,7 +5,6 @@ const Either_1 = require("../../Errors/Either");
5
5
  const axiosInstances_1 = require("../axiosInstances");
6
6
  exports.connectionMutations = {
7
7
  insert: async (connection) => {
8
- console.log("connection.insert:", axiosInstances_1.api);
9
8
  const call = await axiosInstances_1.api.post(`/connections`, connection);
10
9
  if (!call.data)
11
10
  return (0, Either_1.throwError)("");
@@ -24,7 +23,6 @@ exports.connectionMutations = {
24
23
  return (0, Either_1.throwSuccess)(call.data);
25
24
  },
26
25
  getAll: async (props) => {
27
- console.log("connection.getAll:", axiosInstances_1.api);
28
26
  const call = await axiosInstances_1.api.get(`/connections`, { params: props });
29
27
  if (!call.data)
30
28
  return (0, Either_1.throwError)("");
@@ -5,7 +5,6 @@ const Either_1 = require("../../Errors/Either");
5
5
  const axiosInstances_1 = require("../axiosInstances");
6
6
  exports.webhooksMutations = {
7
7
  insert: async (connection) => {
8
- console.log(axiosInstances_1.api);
9
8
  const call = await axiosInstances_1.api.post(`/webhooks`, connection);
10
9
  if (!call.data)
11
10
  return (0, Either_1.throwError)("");
@@ -6,7 +6,6 @@ import Webhook from "../webhook";
6
6
  import Log from "../log";
7
7
  import { Express } from "express";
8
8
  import { NatyEvents } from "../events/NatyEvents";
9
- import { IApiMetaConfig } from "../../interfaces/IApiMetaConfig";
10
9
  export declare class NatyMeta extends NatyEvents implements ISdk {
11
10
  connected: boolean;
12
11
  Connection: typeof Connection;
@@ -14,7 +13,7 @@ export declare class NatyMeta extends NatyEvents implements ISdk {
14
13
  Webhook: typeof Webhook;
15
14
  Log: typeof Log;
16
15
  app: Express;
17
- constructor(apiMeta?: IApiMetaConfig, app?: Express);
16
+ constructor(app?: Express);
18
17
  connect({ appToken, pathname, app, }: ConnectProps): Promise<Response<ConnectErrors, boolean>>;
19
18
  initializeRoutes(path?: string): void;
20
19
  }
@@ -13,12 +13,10 @@ const webhook_1 = __importDefault(require("../webhook"));
13
13
  const log_1 = __importDefault(require("../log"));
14
14
  const routes_1 = require("../../routes");
15
15
  const NatyEvents_1 = require("../events/NatyEvents");
16
- const apiConfig_1 = require("../../configs/apiConfig");
17
16
  class NatyMeta extends NatyEvents_1.NatyEvents {
18
- constructor(apiMeta, app) {
17
+ constructor(app) {
19
18
  super();
20
19
  this.connected = false;
21
- apiConfig_1.ApiConfig.getInstance(apiMeta);
22
20
  if (app) {
23
21
  this.app = app;
24
22
  this.connect({ appToken: "" });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@natyapp/meta",
3
- "version": "1.5.8",
3
+ "version": "1.6.0",
4
4
  "description": "",
5
5
  "main": "./dist/index.js",
6
6
  "types": "./dist/index.d.ts",
@@ -1,8 +0,0 @@
1
- import { IApiMetaConfig } from "../interfaces/IApiMetaConfig";
2
- declare class ApiConfig {
3
- private static instance;
4
- Url: string;
5
- private constructor();
6
- static getInstance(config?: IApiMetaConfig): ApiConfig;
7
- }
8
- export { ApiConfig };
@@ -1,15 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.ApiConfig = void 0;
4
- class ApiConfig {
5
- constructor(config) {
6
- this.Url = (config === null || config === void 0 ? void 0 : config.Url) || "https://meta.api.secretarianaty.com";
7
- }
8
- static getInstance(config) {
9
- if (!ApiConfig.instance) {
10
- ApiConfig.instance = new ApiConfig(config);
11
- }
12
- return ApiConfig.instance;
13
- }
14
- }
15
- exports.ApiConfig = ApiConfig;
@@ -1,3 +0,0 @@
1
- export interface IApiMetaConfig {
2
- Url?: string;
3
- }
@@ -1,2 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });