Class: Spotify::SDK::Me::Info

Inherits:
Spotify::SDK::Model show all
Defined in:
lib/spotify/sdk/me/info.rb

Instance Attribute Summary

Attributes inherited from Spotify::SDK::Model

#parent

Instance Method Summary collapse

Methods inherited from Spotify::SDK::Model

alias_attribute, hash_selector, #initialize, #to_h, #to_json

Constructor Details

This class inherits a constructor from Spotify::SDK::Model

Instance Method Details

#birthdateDate, NilClass

Get the user’s birthdate. Requires the ‘user-read-birthdate` scope, otherwise it will return nil.

Examples:

@sdk.me.info.birthdate # => Wed, 10 May 1985

Returns:

  • (Date, NilClass)

    birthdate Return the user’s birthdate, otherwise return nil.



40
41
42
# File 'lib/spotify/sdk/me/info.rb', line 40

def birthdate
  Date.parse(super) if super
end

#display_name?TrueClass, FalseClass

Does the user have a valid display_name?

Examples:

@sdk.me.info.display_name? # => false

Returns:

  • (TrueClass, FalseClass)

    has_display_name Return true if the user has a non-empty display name.



52
53
54
# File 'lib/spotify/sdk/me/info.rb', line 52

def display_name?
  !display_name.to_s.empty?
end

#followersInteger

Return the followers on Spotify for this user.

Examples:

me = @sdk.me.info
me.followers # => 13913

Returns:

  • (Integer)

    followers The number of users following this user.



80
81
82
# File 'lib/spotify/sdk/me/info.rb', line 80

def followers
  super[:total]
end

#free?TrueClass, FalseClass

Is the user currently on Spotify Free?

Examples:

@sdk.me.info.free?

Returns:

  • (TrueClass, FalseClass)

    is_free Return true if user is on Spotify Free.



15
16
17
# File 'lib/spotify/sdk/me/info.rb', line 15

def free?
  product == "free"
end

#imagesArray

Get the images for the user.

Examples:

@sdk.me.info.images[0].spotify_uri # => "spotify:image:..."
@sdk.me.info.images[0].spotify_url # => "https://profile-images.scdn.co/..."

Returns:

  • (Array)

    images A list of all user photos wrapped in Spotify::SDK::Image



65
66
67
68
69
# File 'lib/spotify/sdk/me/info.rb', line 65

def images
  super.map do |image|
    Spotify::SDK::Image.new(image, parent)
  end
end

#premium?TrueClass, FalseClass

Is the user currently on Spotify Premium?

Examples:

@sdk.me.info.premium?

Returns:

  • (TrueClass, FalseClass)

    is_premium Return true if user is on Spotify Premium.



27
28
29
# File 'lib/spotify/sdk/me/info.rb', line 27

def premium?
  product == "premium"
end

#spotify_uriString

Get the Spotify URI for this user. Alias to self.uri

Examples:

@sdk.me.info.spotify_uri # => "spotify:user:..."

Returns:

  • (String)

    spotify_uri The direct URI to this Spotify resource.



93
# File 'lib/spotify/sdk/me/info.rb', line 93

alias_attribute :spotify_uri, :uri

#spotify_urlString

Get the Spotify HTTP URL for this user. Alias to self.external_urls

Examples:

@sdk.me.info.spotify_url # => "https://open.spotify.com/..."

Returns:

  • (String)

    spotify_url The direct HTTP URL to this Spotify resource.



104
# File 'lib/spotify/sdk/me/info.rb', line 104

alias_attribute :spotify_url, "external_urls.spotify"