TwitterViewer.Document (TwitterViewer v0.1.0)

Copy Markdown View Source

A raw response body (Markdown, plain text, PDF or JSON) with the metadata sent in the response headers.

  • :body - text in UTF-8, or the binary PDF
  • :content_type - content type of the body
  • :filename - suggested file name in UTF-8, PDF only; contains no path separators
  • :credits_charged - credits charged by this call
  • :credits_remaining - credits left
  • :rate_limit_remaining - requests left in this minute; nil for accounts without a limit
  • :posts_returned - posts in the document, quoted posts included; Markdown and text only

to_string/1 returns the body.

Summary

Functions

Writes the body to path.

Parses the body of a swap call made with format: :json into a TwitterViewer.ConvertResult.

Types

t()

@type t() :: %TwitterViewer.Document{
  body: binary(),
  content_type: String.t(),
  credits_charged: non_neg_integer() | nil,
  credits_remaining: non_neg_integer() | nil,
  filename: String.t() | nil,
  posts_returned: non_neg_integer() | nil,
  rate_limit_remaining: non_neg_integer() | nil
}

Functions

save(document, path)

@spec save(t(), Path.t()) :: :ok | {:error, File.posix()}

Writes the body to path.

to_convert_result(document)

@spec to_convert_result(t()) ::
  {:ok, TwitterViewer.ConvertResult.t()}
  | {:error, TwitterViewer.UnexpectedResponseError.t()}

Parses the body of a swap call made with format: :json into a TwitterViewer.ConvertResult.