GoodAnalytics.Connectors.HTTP behaviour (GoodAnalytics v0.1.1)

Copy Markdown View Source

Behaviour-based HTTP adapter for connector delivery.

Connectors use this adapter to make HTTP calls. In production, Req is used. In tests, Mimic stubs the adapter for deterministic responses.

Configuration

config :good_analytics, :http_adapter, GoodAnalytics.Connectors.HTTP.ReqAdapter

Summary

Functions

Makes an HTTP request using the configured adapter.

Types

body()

@type body() :: String.t() | map()

headers()

@type headers() :: [{String.t(), String.t()}]

method()

@type method() :: :get | :post | :put | :patch | :delete

response()

@type response() :: %{
  status: integer(),
  body: term(),
  headers: [{String.t(), String.t()}]
}

url()

@type url() :: String.t()

Functions

request(method, url, headers \\ [], body \\ nil, opts \\ [])

@spec request(method(), url(), headers(), body(), keyword()) ::
  {:ok, response()} | {:error, term()}

Makes an HTTP request using the configured adapter.