Rocksky.Scrobble.Builder (Rocksky v0.1.0)

Copy Markdown View Source

Builder for app.rocksky.scrobble.createScrobble.

Example

alias Rocksky.Scrobble.Builder, as: Scrobble

Scrobble.new(title: "In Bloom", artist: "Nirvana")
|> Scrobble.album("Nevermind")
|> Scrobble.album_art("https://...")
|> Scrobble.timestamp(System.system_time(:second))
|> Scrobble.submit(client)

The lighter-weight one-shot Rocksky.Scrobble.create_scrobble/2 is still available if you prefer a keyword list.

Summary

Functions

Set album on the builder.

Set albumArt on the builder.

Set appleMusicLink on the builder.

Set artist on the builder.

Set artistPicture on the builder.

Set composer on the builder.

Set copyrightMessage on the builder.

Set deezerLink on the builder.

Set discNumber on the builder.

Set duration on the builder.

Set isrc on the builder.

Set label on the builder.

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

Set spotifyLink on the builder.

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

Set tidalLink on the builder.

Set timestamp on the builder.

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.

Set youtubeLink on the builder.

Types

t()

@type t() :: %Rocksky.Scrobble.Builder{
  album: term(),
  albumArt: term(),
  appleMusicLink: term(),
  artist: term(),
  artistPicture: term(),
  composer: term(),
  copyrightMessage: term(),
  deezerLink: term(),
  discNumber: term(),
  duration: term(),
  isrc: term(),
  label: term(),
  lastfmLink: term(),
  lyrics: term(),
  mbId: term(),
  releaseDate: term(),
  spotifyLink: term(),
  tidalLink: term(),
  timestamp: term(),
  title: term(),
  trackNumber: term(),
  year: term(),
  youtubeLink: term()
}

Functions

album(builder, value)

Set album on the builder.

album_art(builder, value)

Set albumArt on the builder.

apple_music_link(builder, value)

Set appleMusicLink on the builder.

artist(builder, value)

Set artist on the builder.

artist_picture(builder, value)

Set artistPicture on the builder.

composer(builder, value)

Set composer on the builder.

deezer_link(builder, value)

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

label(builder, value)

Set label on the builder.

lastfm_link(builder, value)

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

spotify_link(builder, value)

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

tidal_link(builder, value)

Set tidalLink on the builder.

timestamp(builder, value)

Set timestamp on the builder.

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.

youtube_link(builder, value)

Set youtubeLink on the builder.