Class: Rocksky::Resources::Scrobble

Inherits:
Base
  • Object
show all
Defined in:
lib/rocksky/resources/scrobble.rb

Overview

‘app.rocksky.scrobble.*` endpoints.

Instance Attribute Summary

Attributes inherited from Base

#http

Instance Method Summary collapse

Methods inherited from Base

#initialize

Constructor Details

This class inherits a constructor from Rocksky::Resources::Base

Instance Method Details

#create_scrobble(title:, artist:, **extra) ⇒ Object

Create a new scrobble. Requires an authenticated client.

Required: ‘title`, `artist`. Everything else is optional metadata that gets forwarded as-is to the lexicon’s createScrobble body. Extra fields may be passed via ‘**extra`.

Example:

client.scrobble.create_scrobble(
  title: "In Bloom",
  artist: "Nirvana",
  album: "Nevermind",
  timestamp: Time.now.to_i
)


19
20
21
22
# File 'lib/rocksky/resources/scrobble.rb', line 19

def create_scrobble(title:, artist:, **extra)
  body = { title: title, artist: artist }.merge(extra).compact
  procedure("app.rocksky.scrobble.createScrobble", body: body)
end

#get_scrobble(uri:) ⇒ Object

Fetch a scrobble by URI.



25
26
27
# File 'lib/rocksky/resources/scrobble.rb', line 25

def get_scrobble(uri:)
  query("app.rocksky.scrobble.getScrobble", uri: uri)
end

#get_scrobbles(did: nil, following: nil, limit: nil, offset: nil) ⇒ Object

List scrobbles.



30
31
32
33
# File 'lib/rocksky/resources/scrobble.rb', line 30

def get_scrobbles(did: nil, following: nil, limit: nil, offset: nil)
  query("app.rocksky.scrobble.getScrobbles",
        did: did, following: following, limit: limit, offset: offset)
end