import createClient, { type ClientOptions, type Middleware, } from "openapi-fetch"; import type { paths } from "../openapi/schema"; export * from "../openapi/schema"; export const AMOS_API_BASE_URL_PRODUCTION = "https://api.amos.com"; export const AMOS_API_BASE_URL_SANDBOX = "https://api-sandbox.amos.com"; export const AMOS_API_VERSION = "1"; /** * Create a typed `openapi-fetch` client for the Amos Pay API. * * The returned client exposes `GET`, `POST`, `PUT`, `DELETE`, etc., each * fully typed against the OpenAPI spec — paths, path/query/header params, * request bodies, and response bodies are all checked at compile time. * * Provide credentials and the required `X-Api-Version` header as default * `headers` here. Use `client.use(middleware)` to add per-request behavior * such as fresh idempotency keys. * * @example * ```ts * import { * createPayApiClient, * AMOS_API_BASE_URL_SANDBOX, * AMOS_API_VERSION, * } from "@amos.com/node"; * * const pay = createPayApiClient({ * baseUrl: AMOS_API_BASE_URL_SANDBOX, * headers: { * "X-Api-Key": process.env.AMOS_API_KEY!, * "X-Api-Version": AMOS_API_VERSION, * }, * }); * * const { data, error } = await pay.POST("/customers", { * body: { customer: { email: "alex@example.com" } }, * }); * ``` */ export function createPayApiClient(options: ClientOptions) { return createClient(options); } /** A configured Amos Pay API client returned by {@link createPayApiClient}. */ export type PayApiClient = ReturnType; export type { ClientOptions, Middleware };