HttpInterface
in
The contract {@see Http} fulfils. Depend on this rather than the concrete class so the transport can be decorated or faked (test doubles, alternative drivers, a local Bot API server).
execute() resolves with the unwrapped result member of the Bot API
envelope - a scalar, an array, or true - and rejects with a
HttpException subclass when ok is false.
Tags
Table of Contents
Methods
- download() : PromiseInterface<string|int, string>
- Downloads a file previously located with `getFile`, resolving with its bytes.
- execute() : PromiseInterface<string|int, mixed>
- Calls one Bot API method.
- fileUrl() : string
- The absolute URL a `file_path` resolves to, token included.
- setToken() : void
- Swap in a different bot token; queued requests pick it up.
Methods
download()
Downloads a file previously located with `getFile`, resolving with its bytes.
public
download(string $filePath) : PromiseInterface<string|int, string>
Parameters
- $filePath : string
-
The
file_pathfrom a File.
Return values
PromiseInterface<string|int, string>execute()
Calls one Bot API method.
public
execute(string $method[, array<string, mixed> $content = [] ]) : PromiseInterface<string|int, mixed>
Parameters
- $method : string
- $content : array<string, mixed> = []
-
Field name => value. Values may be scalars, arrays, JsonSerializable objects, or InputFile instances, which switch the request to
multipart/form-data.
Return values
PromiseInterface<string|int, mixed>fileUrl()
The absolute URL a `file_path` resolves to, token included.
public
fileUrl(string $filePath) : string
Parameters
- $filePath : string
Return values
stringsetToken()
Swap in a different bot token; queued requests pick it up.
public
setToken(string $token) : void
Parameters
- $token : string