@tiledesk/tiledesk-tybot-connector 0.2.6 → 0.2.7

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-tybot-connector",
3
- "version": "0.2.6",
3
+ "version": "0.2.7",
4
4
  "description": "Tiledesk Tybot connector",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -114,10 +114,10 @@ class DirReply {
114
114
  message,
115
115
  (err) => {
116
116
  if (err) {
117
- console.error("Error sending reply:", err.message);
117
+ console.error("Error sending reply:", err);
118
118
  }
119
119
  // if (this.log) {console.log("Reply message sent.");}
120
- console.log("Reply message sent.");
120
+ console.log("Reply message sent.", JSON.parse(message));
121
121
  callback();
122
122
  });
123
123
  }
@@ -137,14 +137,16 @@ class DirReply {
137
137
  };
138
138
  this.myrequest(
139
139
  HTTPREQUEST,
140
- function(err, response, resbody) {
141
- if (response.status === 200) {
140
+ function(err, resbody) {
141
+ if (err) {
142
142
  if (callback) {
143
- callback(null, resbody)
143
+ callback(err);
144
144
  }
145
145
  }
146
- else if (callback) {
147
- callback(err);
146
+ else {
147
+ if (callback) {
148
+ callback(null, resbody);
149
+ }
148
150
  }
149
151
  }, this.log
150
152
  );
@@ -154,6 +156,7 @@ class DirReply {
154
156
  // if (log) {
155
157
  console.log("API URL:", options.url);
156
158
  console.log("** Options:", JSON.stringify(options));
159
+ console.log("** Sending reply json:", JSON.stringify(options.json));
157
160
  // }
158
161
  axios(
159
162
  {
@@ -173,22 +176,22 @@ class DirReply {
173
176
  //console.log("******** Response for url:", res);
174
177
  // }
175
178
  if (res && res.status == 200 && res.data) {
176
- console.error("Status 200 OK");
179
+ console.log("Status 200 OK");
177
180
  if (callback) {
178
181
  callback(null, res.data);
179
182
  }
180
183
  }
181
184
  else {
185
+ console.error("Status ! 200");
182
186
  if (callback) {
183
- console.error("Status ! 200");
184
- callback({ message: "Response status not 200" });
187
+ callback({ message: "Response status not 200" }, null);
185
188
  }
186
189
  }
187
190
  })
188
191
  .catch((error) => {
189
- console.error("An error occurred:", error);
192
+ console.error("Reply error:", error);
190
193
  if (callback) {
191
- callback(error, null, null);
194
+ callback(error, null);
192
195
  }
193
196
  });
194
197
  }