CalCom. Response
(cal_com v0.3.0)
Copy Markdown
One HTTP response as the caller's transport hands it back.
headers keeps the wire shape the major clients produce — a map of
lowercased names to value lists — and body is the raw undecoded binary:
parsing belongs to this package, not the transport.
Summary
Functions
The first value of name, matched case-insensitively, or nil.
The instant a Retry-After header points at, or nil when it is absent
or unreadable.
Types
Lowercased header name to its values, as received.
@type t() :: %CalCom.Response{ body: binary(), headers: headers(), status: pos_integer() }
A raw response; body is undecoded bytes.
Functions
The first value of name, matched case-insensitively, or nil.
Examples
iex> response = %CalCom.Response{status: 200, headers: %{"x-rate" => ["10"]}}
iex> CalCom.Response.header(response, "X-Rate")
"10"
iex> CalCom.Response.header(response, "absent")
nil
@spec retry_after(t()) :: DateTime.t() | nil
The instant a Retry-After header points at, or nil when it is absent
or unreadable.
Only the whole-seconds form is read. The HTTP-date form is legal but the provider does not send it, and guessing at a date format would invent a resume time rather than read one.
Examples
iex> response = %CalCom.Response{status: 429, headers: %{"retry-after" => ["30"]}}
iex> DateTime.diff(CalCom.Response.retry_after(response), DateTime.utc_now()) > 28
true
iex> CalCom.Response.retry_after(%CalCom.Response{status: 429})
nil