Rocksky.Song.Builder (Rocksky v0.1.0)

Copy Markdown View Source

Builder for app.rocksky.song.createSong.

Example

alias Rocksky.Song.Builder, as: Song

Song.new(title: "Lithium", artist: "Nirvana")
|> Song.album("Nevermind")
|> Song.duration(257_000)
|> Song.isrc("USDW19811234")
|> Song.submit(client)

Summary

Functions

Set album on the builder.

Set albumArt on the builder.

Set albumArtist on the builder.

Set artist on the builder.

Set discNumber on the builder.

Set duration on the builder.

Set isrc on the builder.

Set lyrics on the builder.

Set mbId on the builder.

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 releaseDate on the builder.

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

Set title on the builder.

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

Set trackNumber on the builder.

Set year on the builder.

Types

t()

@type t() :: %Rocksky.Song.Builder{
  album: term(),
  albumArt: term(),
  albumArtist: term(),
  artist: term(),
  discNumber: term(),
  duration: term(),
  isrc: term(),
  lyrics: term(),
  mbId: term(),
  releaseDate: term(),
  title: term(),
  trackNumber: term(),
  year: term()
}

Functions

album(builder, value)

Set album on the builder.

album_art(builder, value)

Set albumArt on the builder.

album_artist(builder, value)

Set albumArtist on the builder.

artist(builder, value)

Set artist on the builder.

disc_number(builder, value)

Set discNumber on the builder.

duration(builder, value)

Set duration on the builder.

isrc(builder, value)

Set isrc on the builder.

lyrics(builder, value)

Set lyrics on the builder.

mb_id(builder, value)

Set mbId 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.

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.

release_date(builder, value)

Set releaseDate 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.

title(builder, value)

Set title on the builder.

to_body(builder)

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

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

track_number(builder, value)

Set trackNumber on the builder.

year(builder, value)

Set year on the builder.