The minimal Web API client, with the bot token.
callposts form parameters to{base_url}/{method}. A string goes as it is, any other value as JSON, andNoneis left out. It succeeds with the answer once Slack saysok.- An
ok: falseanswer fails with the reason for Slack's error code, which becomes the reason'sdetail.ratelimitedand an HTTP 429 giveRateLimitedwith theRetry-Afterwait. - A
writenever repeats once the request left: a transport failure, a server error or an unreadable answer isuncertain. A read retriesretryfailures unlessretry=False, waiting out a 429'sRetry-Afterunless it passesmax_retry_after: then the call fails at once withRateLimited. - The error's
opis the method name.
Functions#
__init__#
__init__(http, bot_token, base_url, max_retry_after=None) -> None| Parameter | Type | Description |
|---|---|---|
http | HttpClientService[HttpClientError, Never] | |
bot_token | Redacted[str] | |
base_url | str | |
max_retry_after | Duration | None = None |
def __init__(
self,
http: HttpClientService[HttpClientError, Never],
bot_token: Redacted[str],
base_url: str,
max_retry_after: Duration | None = None,
) -> None:
self._http = http
self._bot_token = bot_token
self._base_url = base_url
self._max_retry_after = max_retry_aftercall#
call(method, body, *, write=False, retry=True) -> Effect[Json, ChatError]Calls a Web API method with body as form fields and succeeds
with Slack's answer when it is ok. write marks a call that may
land without an answer, so a failure is uncertain rather than
retried; retry retries a safe failure, as retry_safe does.
| Parameter | Type | Description |
|---|---|---|
method | str | |
body | Mapping[str, object] | |
write | bool = False | |
retry | bool = True |
Returns Effect[Json, ChatError]
def call(
self, method: str, body: Mapping[str, object], *, write: bool = False, retry: bool = True
) -> Effect[Json, ChatError]:
"""Calls a Web API method with ``body`` as form fields and succeeds
with Slack's answer when it is ``ok``. ``write`` marks a call that may
land without an answer, so a failure is ``uncertain`` rather than
retried; ``retry`` retries a safe failure, as ``retry_safe`` does."""
once = self._once(method, body, write)
return retry_safe(once, max_retry_after=self._max_retry_after) if retry else once