@tiledesk/tiledesk-whatsapp-connector 0.1.4 → 0.1.5

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tiledesk/tiledesk-whatsapp-connector",
3
- "version": "0.1.4",
3
+ "version": "0.1.5",
4
4
  "description": "Tiledesk Whatsapp connector",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -43,7 +43,7 @@
43
43
  <div>
44
44
 
45
45
  <h1 style="margin-top: 0px; margin-bottom: 2px; min-width: 500px;">WhatsApp Business (Test)</h1>
46
- <h7 style="color: rgb(140, 140, 140);">by Tiledesk (v. 0.1.4)</h7>
46
+ <h7 style="color: rgb(140, 140, 140);">by Tiledesk (v. 0.1.5)</h7>
47
47
 
48
48
  {{#if wab_token}}
49
49
  <div style="margin-top: 20px;">
@@ -32,10 +32,15 @@ class TiledeskWhatsapp {
32
32
  // this.media = config.channelMedia;
33
33
  this.token = config.token;
34
34
  this.GRAPH_URL = config.GRAPH_URL
35
+
36
+ this.log = false;
37
+ if (config.log) {
38
+ this.log = config.log;
39
+ }
35
40
  }
36
41
 
37
42
  async sendMessage(phone_number_id, message) {
38
- if (log) {
43
+ if (this.log) {
39
44
  console.log("[Tiledesk Whatsapp] Sending message...", message);
40
45
  } else {
41
46
  console.log("[Tiledesk Whatsapp] Sending message...");
@@ -58,7 +63,7 @@ class TiledeskWhatsapp {
58
63
  }
59
64
 
60
65
  async downloadMedia(mediaId) {
61
- if (log) {
66
+ if (this.log) {
62
67
  console.log("[Tiledesk Whatsapp] Download media with id: ", mediaId);
63
68
  }
64
69
 
@@ -128,7 +133,7 @@ class TiledeskWhatsapp {
128
133
  }
129
134
 
130
135
  return await axios.post(url, form, request_config).then((response) => {
131
- if (log) {
136
+ if (this.log) {
132
137
  console.log("[Tiledesk Whatsapp] upload response: ", response.data);
133
138
  }
134
139
 
@@ -146,7 +151,7 @@ class TiledeskWhatsapp {
146
151
 
147
152
  // HTTP REQUEST
148
153
  static async myrequest(options, callback, log) {
149
- if (log) {
154
+ if (this.log) {
150
155
  console.log("API URL: ", options.url);
151
156
  console.log("** Options: ", options);
152
157
  }
@@ -157,7 +162,7 @@ class TiledeskWhatsapp {
157
162
  params: options.params,
158
163
  headers: options.headers
159
164
  }).then((res) => {
160
- if (log) {
165
+ if (this.log) {
161
166
  console.log("Response for url:", options.url);
162
167
  console.log("Response headers:\n", res.headers);
163
168
  }