Hunter.Api.Request (hunter v0.7.0)

Copy Markdown View Source

The single HTTP transport for Hunter.

request!/6 joins the endpoint path onto the base URL, sets authentication headers from the Hunter.Client (none for a bare base URL string), performs the request via Req, decodes the response through Hunter.Api.Transformer, and raises Hunter.Error on failure.

Summary

Functions

Performs a request against the Mastodon API and returns the transformed entity.

Functions

request!(conn_or_base_url, method, path, to, payload \\ [], opts \\ [])

Performs a request against the Mastodon API and returns the transformed entity.

Parameters

  • conn_or_base_url - a Hunter.Client (authenticated) or a base URL string (unauthenticated, e.g. app registration and OAuth flows)
  • method - :get, :post, :put, :patch or :delete
  • path - endpoint path, e.g. "/api/v1/statuses"
  • to - Hunter.Api.Transformer target (e.g. :status, :accounts, :empty), or nil for the JSON-decoded body untouched
  • payload - query params for :get/:delete; JSON body (map or keyword) or {:form_multipart, parts} for write verbs
  • opts - headers: [{name, value}] extra request headers

Raises Hunter.Error on non-2xx responses and transport errors.