Poodle.Response (poodle v1.0.0)

View Source

Response struct for the Poodle SDK.

Represents successful API responses with rate limit information.

Summary

Functions

Get the response message.

Create a new response from HTTP response data.

Get rate limit information from the response.

Check if the response indicates success.

Types

t()

@type t() :: %Poodle.Response{
  message: String.t(),
  rate_limit: Poodle.RateLimit.t() | nil,
  raw_response: map() | nil,
  success: boolean()
}

Functions

message(response)

@spec message(t()) :: String.t()

Get the response message.

Examples

iex> response = %Poodle.Response{message: "Email queued for sending"}
iex> Poodle.Response.message(response)
"Email queued for sending"

new(response_body, headers \\ %{})

@spec new(map(), map()) :: t()

Create a new response from HTTP response data.

Examples

iex> body = %{"success" => true, "message" => "Email queued for sending"}
iex> headers = %{"ratelimit-remaining" => "1"}
iex> Poodle.Response.new(body, headers)
%Poodle.Response{success: true, message: "Email queued for sending", ...}

rate_limit(response)

@spec rate_limit(t()) :: Poodle.RateLimit.t() | nil

Get rate limit information from the response.

Examples

iex> response = %Poodle.Response{rate_limit: %Poodle.RateLimit{remaining: 1}}
iex> Poodle.Response.rate_limit(response)
%Poodle.RateLimit{remaining: 1}

success?(response)

@spec success?(t()) :: boolean()

Check if the response indicates success.

Examples

iex> response = %Poodle.Response{success: true}
iex> Poodle.Response.success?(response)
true