diff --git a/src/at/xrpc.gleam b/src/at/xrpc.gleam index 8effe6a..e982f4e 100644 --- a/src/at/xrpc.gleam +++ b/src/at/xrpc.gleam @@ -3,6 +3,7 @@ import at/nsid.{type Nsid} import gleam/http.{Get, Https, Post} import gleam/http/request.{type Request, Request} +import gleam/json.{type Json} import gleam/option.{type Option, None, Some} import gleam/uri.{type Uri} @@ -10,7 +11,7 @@ import gleam/uri.{type Uri} /// /// -pub type Client { +pub opaque type Client { Client(host: String, port: Option(Int)) } @@ -59,15 +60,18 @@ pub fn procedure( client: Client, path: Nsid, parameters: List(#(String, String)), + body: Json, ) -> Request(String) { Request( method: Post, - headers: [], - body: "", + headers: [ + #("content-type", "application/json"), + ], + body: json.to_string(body), scheme: Https, host: client.host, port: client.port, - path: "/xrpx/" <> nsid.to_string(path), + path: "/xrpc/" <> nsid.to_string(path), query: case parameters { [] -> option.None _ -> option.Some(uri.query_to_string(parameters))