use Rocksky.Builder turns a module into a chainable, pipe-friendly request
builder for a single XRPC procedure.
Example
defmodule Rocksky.Scrobble.Builder do
use Rocksky.Builder,
nsid: "app.rocksky.scrobble.createScrobble",
required: [:title, :artist],
optional: [:album, :duration, :mbId, :isrc, :albumArt, :timestamp]
end
alias Rocksky.Scrobble.Builder, as: Scrobble
Scrobble.new(title: "In Bloom", artist: "Nirvana")
|> Scrobble.album("Nevermind")
|> Scrobble.timestamp(System.system_time(:second))
|> Scrobble.submit(client)What you get
For each field listed in :required or :optional the macro generates a
field/2 setter that returns the updated builder (snake-cased: a :mbId
field becomes mb_id/2).
In addition:
new/1— build from a keyword list / map. Returns a%__MODULE__{}.put/2— generic batch setter that accepts a keyword list or map.submit/2— issue the underlying XRPC procedure with the current builder as the JSON body. Returns{:ok, body} | {:error, Rocksky.Error.t()}. If any:requiredfield isnil, returns{:error, %Rocksky.Error{reason: :missing_fields, ...}}without making a network call.to_body/1— return the body that would be sent, withnilfields stripped. Useful for inspection in tests.