@gramio/types
Advanced tools
Comparing version 7.0.7 to 7.0.8
/** | ||
* Based on Bot Api v7.0.0 (29.12.2023) | ||
* Generated at 2/2/2024, 12:18:23 AM using {@link https://github.com/gramiojs/types | [types]} and {@link https://ark0f.github.io/tg-bot-api | [schema]} generators | ||
* Generated at 2/2/2024, 4:07:25 PM using {@link https://github.com/gramiojs/types | [types]} and {@link https://ark0f.github.io/tg-bot-api | [schema]} generators | ||
*/ | ||
@@ -5,0 +5,0 @@ import * as Params from "./params" |
{ | ||
"name": "@gramio/types", | ||
"version": "7.0.7", | ||
"version": "7.0.8", | ||
"homepage": "https://github.com/gramiojs/types", | ||
@@ -5,0 +5,0 @@ "readme": "https://github.com/gramiojs/types", |
@@ -31,23 +31,19 @@ # Code-generated and Auto-published Telegram Bot API types | ||
```typescript | ||
import { stringify } from "node:querystring"; | ||
import type { ApiMethods } from "@gramio/types"; | ||
import type { ApiMethods, TelegramAPIResponse } from "@gramio/types"; | ||
const TBA_BASE_URL = "https://api.telegram.org/bot"; | ||
const TOKEN = ""; | ||
const api = new Proxy<ApiMethods>({} as ApiMethods, { | ||
get: (_target, method: string) => async (args: Record<string, any>) => { | ||
const url = | ||
`http://api.telegram.org/bot` + | ||
TOKEN + | ||
"/" + | ||
method + | ||
`?` + | ||
stringify(args); | ||
const response = await fetch(url, { | ||
method: "GET", | ||
const api = new Proxy({} as ApiMethods, { | ||
get: (_target, method: string) => async (args: Record<string, unknown>) => { | ||
const response = await fetch(`${TBA_BASE_URL}${TOKEN}/${method}`, { | ||
method: "POST", | ||
headers: { | ||
"Content-Type": "application/json", | ||
}, | ||
body: JSON.stringify(params), | ||
}); | ||
const data = await response.json(); | ||
if (!response.ok) throw new Error("some error"); | ||
const data = (await response.json()) as TelegramAPIResponse; | ||
if (!data.ok) throw new Error(`Some error occurred in ${method}`); | ||
@@ -54,0 +50,0 @@ return data.result; |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
386443
9381
108