PhoenixKit.Modules.Emails.BrevoClient (phoenix_kit_emails v0.1.17)

Copy Markdown View Source

Thin wrapper around the Brevo transactional-email events API (GET /v3/smtp/statistics/events).

Isolated from BrevoPollingJob so tests can stub the HTTP layer with Req.Test instead of hitting the real network: pass req_options: [plug: {Req.Test, MyStubName}].

Summary

Functions

Fetches one page of events for the given date window.

Functions

fetch_events(api_key, params, req_options \\ [])

@spec fetch_events(String.t(), keyword(), keyword()) ::
  {:ok, [map()]} | {:error, term()}

Fetches one page of events for the given date window.

params is merged into the query string as-is — callers pass Brevo's real query keys (startDate, endDate, limit, offset, sort, ...).

Returns

  • {:ok, [event_map]} — the events array from a 200 response ([] when the response has no events key, e.g. an empty page)
  • {:error, :invalid_credentials} — 401
  • {:error, {:http_status, status}} — any other non-200 status
  • {:error, reason} — transport-level failure