Rocksky.Shout.ReportBuilder (Rocksky v0.1.0)

Copy Markdown View Source

Builder for app.rocksky.shout.reportShout.

Example

alias Rocksky.Shout.ReportBuilder, as: Report

Report.new(shout_id: "shout-123", reason: "spam")
|> Report.submit(client)

Summary

Functions

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

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

Set reason on the builder.

Set shoutId on the builder.

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.Shout.ReportBuilder{reason: term(), shoutId: term()}

Functions

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.

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.

reason(builder, value)

Set reason on the builder.

shout_id(builder, value)

Set shoutId on the builder.

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).