View Source Tumbloire.Req (Tumbloire v0.1.0)

Low-level functions for building Req requests.

Generally intended to be used internally, but can also be used to work around missing endpoints or to customize how the request is made (by adding Req options, new steps, or attaching plugins).

Additional application's default Req options can be configured via :tumbloire, :req_options.

Summary

Functions

Returns a Req request with custom options and steps.

Makes the request and returns the body of the response or an error.

Functions

@spec new(keyword()) :: Req.Request.t()

Returns a Req request with custom options and steps.

It contains:

  • a custom step to keep the given auth method (API key in query parameters or explicit :auth Req option) or add the :access_token value configured by the application
  • a custom step (used internally) to move the request parameters from :params to form when the HTTP method specified is different than GET

You can find the full list of available options in the Req documentation

Link to this function

request(method, url, params, endpoint_params \\ [])

View Source
@spec request(method(), String.t(), keyword(), [atom()]) ::
  {:ok, map()} | {:error, Tumbloire.Error.t()}

Makes the request and returns the body of the response or an error.

Parameters

  • url: the endpoint's url (e.g. "/user/follow")
  • params: are the query parameters passed to the endpoint
  • endpoint_params: a list of atoms representing the available endpoint parameters

Parameters in params not present in endpoint_params are treated as Req options.

Examples

iex> Tumbloire.Req.request(:get, "blog/:blogname/info", path_params: [blogname: "name"])