The client struct every resource function takes as its first argument.
Build one with FoPost.new/1 and pass it around explicitly — there is no global client
and no process state, so a client is just data and is safe to share between processes.
client = FoPost.new(api_key: "fp_...")Transport
Requests go out over Req, which pools connections through the Finch instance Req starts with its own application. Nothing needs to be added to a host application's supervision tree. To use your own pool, pass it through:
FoPost.new(api_key: key, req_options: [finch: MyApp.Finch]):req_options is merged last, so it wins over everything the SDK sets — including the
retry policy. It is the escape hatch for proxies, custom TLS, and test stubs.
Summary
Functions
Builds a client. See FoPost.new/1 for the options.
Sends one authenticated request and decodes the response.
The SDK version, as reported in the User-Agent header.
Types
@type t() :: %FoPost.Client{ api_key: String.t(), base_url: String.t(), max_retries: non_neg_integer(), receive_timeout: pos_integer(), req_options: keyword(), user_agent: String.t() }
Functions
Builds a client. See FoPost.new/1 for the options.
Sends one authenticated request and decodes the response.
method is an atom (:get, :post, :put, :delete), path is relative to the
client's base URL. Options are passed straight through to Req, so :params, :json,
and :form_multipart all work, plus one of our own:
:unwrap— peel the{"data": ...}envelope off a successful response. Defaults totrue; list endpoints that also needmetapassfalse.
Answers {:ok, body} or {:error, %FoPost.Error{}}.
@spec version() :: String.t()
The SDK version, as reported in the User-Agent header.