Skip to content

Commit c8d309d

Browse files
committed
fix POST requests
1 parent 9062b1c commit c8d309d

1 file changed

Lines changed: 16 additions & 17 deletions

File tree

src/telegram_api.ts

Lines changed: 16 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -215,7 +215,7 @@ export default class TelegramApi {
215215
* @returns Promise with the API response
216216
*/
217217
async sendChatAction(botApi: string, data: SendChatActionParams): Promise<Response> {
218-
const url = this.getApiUrl(botApi, '', data, 'POST');
218+
const url = this.getApiUrl(botApi, 'sendChatAction', data, 'POST');
219219
return await this.fetchAndLog(url, 'sendChatAction', data);
220220
}
221221

@@ -231,8 +231,7 @@ export default class TelegramApi {
231231
throw new Error('No file_id provided');
232232
}
233233

234-
const url = this.getApiUrl(botApi, '', data, 'POST');
235-
const response = await this.fetchAndLog(url, 'getFile', data);
234+
const url = this.getApiUrl(botApi, 'getFile', data, 'POST');const response = await this.fetchAndLog(url, 'getFile', data);
236235

237236
const json: { ok: boolean; result?: { file_path: string }; description?: string } = await response.json();
238237

@@ -254,7 +253,7 @@ export default class TelegramApi {
254253
* @returns Promise with the API response
255254
*/
256255
async sendMessage(botApi: string, data: SendMessageParams): Promise<Response> {
257-
const url = this.getApiUrl(botApi, '', data, 'POST');
256+
const url = this.getApiUrl(botApi, 'sendMessage', data, 'POST');
258257
return await this.fetchAndLog(url, 'sendMessage', data);
259258
}
260259

@@ -265,7 +264,7 @@ export default class TelegramApi {
265264
* @returns Promise with the API response
266265
*/
267266
async sendVideo(botApi: string, data: SendVideoParams): Promise<Response> {
268-
const url = this.getApiUrl(botApi, '', data, 'POST');
267+
const url = this.getApiUrl(botApi, 'sendVideo', data, 'POST');
269268
return await this.fetchAndLog(url, 'sendVideo', data);
270269
}
271270

@@ -276,7 +275,7 @@ export default class TelegramApi {
276275
* @returns Promise with the API response
277276
*/
278277
async sendPhoto(botApi: string, data: SendPhotoParams): Promise<Response> {
279-
const url = this.getApiUrl(botApi, '', data, 'POST');
278+
const url = this.getApiUrl(botApi, 'sendPhoto', data, 'POST');
280279
return await this.fetchAndLog(url, 'sendPhoto', data);
281280
}
282281

@@ -287,7 +286,7 @@ export default class TelegramApi {
287286
* @returns Promise with the API response
288287
*/
289288
async sendVoice(botApi: string, data: SendVoiceParams): Promise<Response> {
290-
const url = this.getApiUrl(botApi, '', data, 'POST');
289+
const url = this.getApiUrl(botApi, 'sendVoice', data, 'POST');
291290
return await this.fetchAndLog(url, 'sendVoice', data);
292291
}
293292

@@ -305,7 +304,7 @@ export default class TelegramApi {
305304
is_personal: data.is_personal,
306305
next_offset: data.next_offset,
307306
};
308-
const url = this.getApiUrl(botApi, 'answerInlineQuery', params);
307+
const url = this.getApiUrl(botApi, 'answerInlineQuery', params, 'POST');
309308
return await this.fetchAndLog(url, 'answerInlineQuery', params);
310309
}
311310

@@ -316,7 +315,7 @@ export default class TelegramApi {
316315
* @returns Promise with the API response
317316
*/
318317
async answerCallback(botApi: string, data: AnswerCallbackParams): Promise<Response> {
319-
const url = this.getApiUrl(botApi, '', data, 'POST');
318+
const url = this.getApiUrl(botApi, 'answerCallbackQuery', data, 'POST');
320319
return await this.fetchAndLog(url, 'answerCallbackQuery', data);
321320
}
322321

@@ -327,7 +326,7 @@ export default class TelegramApi {
327326
* @returns Promise with the API response
328327
*/
329328
async answerGuestQuery(botApi: string, data: AnswerGuestParams): Promise<Response> {
330-
const url = this.getApiUrl(botApi, '', data, 'POST');
329+
const url = this.getApiUrl(botApi, 'answerGuestQuery', data, 'POST');
331330
return await this.fetchAndLog(url, 'answerGuestQuery', data);
332331
}
333332

@@ -338,7 +337,7 @@ export default class TelegramApi {
338337
* @returns Promise with the API response
339338
*/
340339
async deleteMessage(botApi: string, data: { chat_id: number | string; message_id: number }): Promise<Response> {
341-
const url = this.getApiUrl(botApi, '', data, 'POST');
340+
const url = this.getApiUrl(botApi, 'deleteMessage', data, 'POST');
342341
return await this.fetchAndLog(url, 'deleteMessage', data);
343342
}
344343

@@ -352,15 +351,15 @@ export default class TelegramApi {
352351
botApi: string,
353352
data: EditMessageTextParams,
354353
): Promise<Response> {
355-
const url = this.getApiUrl(botApi, '', data, 'POST');
354+
const url = this.getApiUrl(botApi, 'editMessageText', data, 'POST');
356355
return await this.fetchAndLog(url, 'editMessageText', data);
357356
}
358357

359358
async sendMessageDraft(
360359
botApi: string,
361360
data: SendMessageDraftParams,
362361
): Promise<Response> {
363-
const url = this.getApiUrl(botApi, '', data, 'POST');
362+
const url = this.getApiUrl(botApi, 'sendMessageDraft', data, 'POST');
364363
return await this.fetchAndLog(url, 'sendMessageDraft', data);
365364
}
366365

@@ -371,7 +370,7 @@ export default class TelegramApi {
371370
* @returns Promise with the API response
372371
*/
373372
async sendInvoice(botApi: string, data: SendInvoiceParams): Promise<Response> {
374-
const url = this.getApiUrl(botApi, '', data, 'POST');
373+
const url = this.getApiUrl(botApi, 'sendInvoice', data, 'POST');
375374
return await this.fetchAndLog(url, 'sendInvoice', data);
376375
}
377376

@@ -382,7 +381,7 @@ export default class TelegramApi {
382381
* @returns Promise with the API response
383382
*/
384383
async answerPreCheckoutQuery(botApi: string, data: AnswerPreCheckoutParams): Promise<Response> {
385-
const url = this.getApiUrl(botApi, '', data, 'POST');
384+
const url = this.getApiUrl(botApi, 'answerPreCheckoutQuery', data, 'POST');
386385
return await this.fetchAndLog(url, 'answerPreCheckoutQuery', data);
387386
}
388387

@@ -393,7 +392,7 @@ export default class TelegramApi {
393392
* @returns Promise with the API response
394393
*/
395394
async getBusinessConnection(botApi: string, business_connection_id: string): Promise<Response> {
396-
const url = this.getApiUrl(botApi, 'getBusinessConnection', { business_connection_id });
395+
const url = this.getApiUrl(botApi, 'getBusinessConnection', { business_connection_id }, 'POST');
397396
return await this.fetchAndLog(url, 'getBusinessConnection', { business_connection_id });
398397
}
399398

@@ -403,7 +402,7 @@ export default class TelegramApi {
403402
* @returns Promise with the API response
404403
*/
405404
async getMe(botApi: string): Promise<Response> {
406-
const url = this.getApiUrl(botApi, 'getMe', {});
405+
const url = this.getApiUrl(botApi, 'getMe', {}, 'GET');
407406
return await this.fetchAndLog(url, 'getMe', {});
408407
}
409408
}

0 commit comments

Comments
 (0)