Rocksky.Mirror.Builder (Rocksky v0.1.0)

Copy Markdown View Source

Builder for app.rocksky.mirror.putMirrorSource.

Example

alias Rocksky.Mirror.Builder, as: Mirror

Mirror.new(provider: "lastfm", enabled: true)
|> Mirror.external_username("alice")
|> Mirror.api_key("...")
|> Mirror.submit(client)

Summary

Functions

Set apiKey on the builder.

Set enabled on the builder.

Set externalUsername on the builder.

Build a new request from a keyword list or map of fields.

Set provider on the builder.

Batch-set fields. attrs is a keyword list or map. Accepts the same key forms as new/1.

Submit the builder. Returns {:ok, body} on success or {:error, %Rocksky.Error{}} on failure.

Return the JSON body that would be sent (nil fields stripped).

Types

t()

@type t() :: %Rocksky.Mirror.Builder{
  apiKey: term(),
  enabled: term(),
  externalUsername: term(),
  provider: term()
}

Functions

api_key(builder, value)

Set apiKey on the builder.

enabled(builder, value)

Set enabled on the builder.

external_username(builder, value)

Set externalUsername on the builder.

new(attrs \\ [])

@spec new(keyword() | map()) :: t()

Build a new request from a keyword list or map of fields.

Accepts either the canonical lexicon key (:mbId) or its snake-cased equivalent (:mb_id). Unknown keys raise.

provider(builder, value)

Set provider on the builder.

put(builder, attrs)

@spec put(t(), keyword() | map()) :: t()

Batch-set fields. attrs is a keyword list or map. Accepts the same key forms as new/1.

submit(builder, client)

@spec submit(t(), Rocksky.Client.t()) :: {:ok, term()} | {:error, Rocksky.Error.t()}

Submit the builder. Returns {:ok, body} on success or {:error, %Rocksky.Error{}} on failure.

Returns {:error, %Rocksky.Error{reason: :missing_fields}} without making a network call when any required field is nil.

to_body(builder)

@spec to_body(t()) :: map()

Return the JSON body that would be sent (nil fields stripped).