# `TwitterViewer.Document`
[🔗](https://github.com/TwitterViewer/twitterviewer-elixir/blob/v0.1.0/lib/twitterviewer/document.ex#L1)

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.

# `t`

```elixir
@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
}
```

# `save`

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

Writes the body to `path`.

# `to_convert_result`

```elixir
@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`.

---

*Consult [api-reference.md](api-reference.md) for complete listing*
