GitHub

WhatsAppGraphApiService

API reference for WhatsAppGraphApiService.

The minimal Graph API client, with the access token.

  • call requests {base_url}/{path} with the token as a bearer token, and succeeds with the JSON of a 2xx answer. body goes as JSON, form as multipart/form-data (as a media upload does) and params as query parameters. method is GET, or POST when there is a body or a form.
  • Another answer fails with the reason for its Graph error code, whose detail is graph_{code} and whose cause is the Graph error object, or for its HTTP status when it has no Graph error.
  • A write never repeats once the request left: a transport failure, a server error or an unreadable answer is uncertain. A refusal Meta answers before sending, such as a rate limit, is retried unless retry=False, as a read's retry failures are.
  • A rate limit is retried after the answer's Retry-After, however long, unless max_retry_after is set: a longer wait then fails at once with RateLimited, its retry_after the wait asked for. Without the header the backoff starts at 500 milliseconds.
  • The error's op is the path.

Functions

__init__

__init__(http, access_token, base_url, max_retry_after=None) -> None
ParameterTypeDescription
httpHttpClientService[HttpClientError, Never]
access_tokenRedacted[str]
base_urlstr
max_retry_afterDuration | None = None
def __init__(
    self,
    http: HttpClientService[HttpClientError, Never],
    access_token: Redacted[str],
    base_url: str,
    max_retry_after: Duration | None = None,
) -> None:
    self._http = http
    self._access_token = access_token
    self._base_url = base_url
    self._max_retry_after = max_retry_after

call

call(path, *, method=None, body=None, form=None, params=None, write=False, retry=True) -> Effect[Json, ChatError]

Calls {base_url}/{path} and succeeds with the JSON of a 2xx answer; see the class.

ParameterTypeDescription
pathstr
methodMethod | None = None
bodyMapping[str, object] | None = None
formhttp_body.FormData | None = None
paramsMapping[str, str] | None = None
writebool = False
retrybool = True

Returns Effect[Json, ChatError]

def call(
    self,
    path: str,
    *,
    method: Method | None = None,
    body: Mapping[str, object] | None = None,
    form: http_body.FormData | None = None,
    params: Mapping[str, str] | None = None,
    write: bool = False,
    retry: bool = True,
) -> Effect[Json, ChatError]:
    """Calls ``{base_url}/{path}`` and succeeds with the JSON of a 2xx
    answer; see the class."""
    once = self._once(path, method, body, form, params, write)
    return retry_safe(once, max_retry_after=self._max_retry_after) if retry else once