defmodule Tarakan.Billing.Stripe do
  @moduledoc """
  Thin Stripe REST client boundary.

  The real implementation (`Tarakan.Billing.Stripe.API`) talks to Stripe over
  HTTP with Req; tests bind `Tarakan.Billing.StripeStub` via the `:stripe_api`
  config key, mirroring the `Tarakan.GitHubClient` / `Tarakan.GitHubStub`
  pattern.
  """

  @type method :: :get | :post | :delete

  @doc """
  Performs a Stripe API request.

  `body_or_params` is form-encoded for POST/DELETE and sent as query params
  for GET. Returns the decoded response body map on 2xx.
  """
  @callback request(method(), String.t(), map() | list() | nil) ::
              {:ok, map()} | {:error, term()}

  def request(method, path, body_or_params \\ nil) do
    api().request(method, path, body_or_params)
  end

  defp api, do: Application.get_env(:tarakan, :stripe_api)
end
