@tiledesk/tiledesk-tybot-connector 0.2.8 → 0.2.9

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/CHANGELOG.md CHANGED
@@ -5,7 +5,8 @@
5
5
  available on:
6
6
  ▶️ https://www.npmjs.com/package/@tiledesk/tiledesk-tybot-connector
7
7
 
8
- ### 0.2.5 - prod debug
8
+ ### 0.2.9 - online
9
+ - restored logs
9
10
 
10
11
  ### 0.2.1 - online
11
12
  - bug fix: /ext/parameters/requests/:requestid replies with res.send([]);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tiledesk/tiledesk-tybot-connector",
3
- "version": "0.2.8",
3
+ "version": "0.2.9",
4
4
  "description": "Tiledesk Tybot connector",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -98,103 +98,96 @@ class DirReply {
98
98
  }
99
99
  // send!
100
100
  if (this.log) {console.log("Reply:", JSON.stringify(message))};
101
- // this.context.tdclient.sendSupportMessage(
102
- // this.requestId,
103
- // message,
104
- // (err) => {
105
- // if (err) {
106
- // console.error("Error sending reply:", err.message);
107
- // }
108
- // if (this.log) {console.log("Reply message sent.");}
109
- // callback();
110
- // });
111
-
112
- this.sendSupportMessage(
101
+ this.context.tdclient.sendSupportMessage(
113
102
  this.requestId,
114
103
  message,
115
104
  (err) => {
116
105
  if (err) {
117
106
  console.error("Error sending reply:", err);
118
107
  }
119
- // if (this.log) {console.log("Reply message sent.");}
120
- console.log("Reply message sent.", JSON.stringify(message));
108
+ if (this.log) {console.log("Reply message sent");}
121
109
  callback();
122
- });
123
- }
110
+ });
124
111
 
125
- sendSupportMessage(requestId, message, callback) {
126
- // const jwt_token = TiledeskClient.fixToken(this.token);
127
- //const url = `${this.APIURL}/${this.projectId}/requests/${requestId}/messages`;
128
- const url = `${this.context.tdclient.APIURL}/${this.projectId}/requests/${requestId}/messages`
129
- const HTTPREQUEST = {
130
- url: url,
131
- headers: {
132
- 'Content-Type' : 'application/json',
133
- 'Authorization': "JWT " + this.token
134
- },
135
- json: message,
136
- method: 'POST'
137
- };
138
- this.myrequest(
139
- HTTPREQUEST,
140
- function(err, resbody) {
141
- if (err) {
142
- if (callback) {
143
- callback(err);
144
- }
145
- }
146
- else {
147
- if (callback) {
148
- callback(null, resbody);
149
- }
150
- }
151
- }, this.log
152
- );
112
+ // this.sendSupportMessage(
113
+ // this.requestId,
114
+ // message,
115
+ // (err) => {
116
+ // if (err) {
117
+ // console.error("Error sending reply:", err);
118
+ // }
119
+ // // if (this.log) {console.log("Reply message sent.");}
120
+ // console.log("Reply message sent.", JSON.stringify(message));
121
+ // callback();
122
+ // }
123
+ // );
153
124
  }
154
125
 
155
- myrequest(options, callback, log) {
156
- // if (log) {
157
- console.log("API URL:", options.url);
158
- console.log("** Options:", JSON.stringify(options));
159
- console.log("** Sending reply json:", JSON.stringify(options.json));
126
+ // sendSupportMessage(requestId, message, callback) {
127
+ // const url = `${this.context.tdclient.APIURL}/${this.projectId}/requests/${requestId}/messages`
128
+ // const HTTPREQUEST = {
129
+ // url: url,
130
+ // headers: {
131
+ // 'Content-Type' : 'application/json',
132
+ // 'Authorization': "JWT " + this.token
133
+ // },
134
+ // json: message,
135
+ // method: 'POST'
136
+ // };
137
+ // this.myrequest(
138
+ // HTTPREQUEST,
139
+ // function(err, resbody) {
140
+ // if (err) {
141
+ // if (callback) {
142
+ // callback(err);
143
+ // }
144
+ // }
145
+ // else {
146
+ // if (callback) {
147
+ // callback(null, resbody);
148
+ // }
149
+ // }
150
+ // }, this.log
151
+ // );
160
152
  // }
161
- axios(
162
- {
163
- url: options.url,
164
- method: options.method,
165
- data: options.json,
166
- params: options.params,
167
- headers: options.headers
168
- })
169
- .then((res) => {
170
- // if (log) {
171
- console.log("Reply: Response for url:", options.url);
172
- console.log("Reply: Response headers:\n", JSON.stringify(res.headers));
173
- console.log("Reply: Status:", res.status);
174
- console.log("Reply: Data:", JSON.stringify(res.data));
175
-
176
- //console.log("******** Response for url:", res);
177
- // }
178
- if (res && res.status == 200 && res.data) {
179
- console.log("Status 200 OK");
180
- if (callback) {
181
- callback(null, res.data);
182
- }
183
- }
184
- else {
185
- console.error("Status ! 200");
186
- if (callback) {
187
- callback({ message: "Response status not 200" }, null);
188
- }
189
- }
190
- })
191
- .catch((error) => {
192
- console.error("Reply error:", error);
193
- if (callback) {
194
- callback(error, null);
195
- }
196
- });
197
- }
153
+
154
+ // myrequest(options, callback, log) {
155
+ // console.log("API URL:", options.url);
156
+ // console.log("** Options:", JSON.stringify(options));
157
+ // console.log("** Sending reply json:", JSON.stringify(options.json));
158
+ // axios(
159
+ // {
160
+ // url: options.url,
161
+ // method: options.method,
162
+ // data: options.json,
163
+ // params: options.params,
164
+ // headers: options.headers
165
+ // })
166
+ // .then((res) => {
167
+ // console.log("Reply: Response for url:", options.url);
168
+ // console.log("Reply: Response headers:\n", JSON.stringify(res.headers));
169
+ // console.log("Reply: Status:", res.status);
170
+ // console.log("Reply: Data:", JSON.stringify(res.data));
171
+ // if (res && res.status == 200 && res.data) {
172
+ // console.log("Status 200 OK");
173
+ // if (callback) {
174
+ // callback(null, res.data);
175
+ // }
176
+ // }
177
+ // else {
178
+ // console.error("Status ! 200");
179
+ // if (callback) {
180
+ // callback({ message: "Response status not 200" }, null);
181
+ // }
182
+ // }
183
+ // })
184
+ // .catch((error) => {
185
+ // console.error("Reply error:", error);
186
+ // if (callback) {
187
+ // callback(error, null);
188
+ // }
189
+ // });
190
+ // }
198
191
 
199
192
  }
200
193