Class: SpotifyWebApi::PublicUserObject
- Inherits:
-
BaseModel
- Object
- CoreLibrary::BaseModel
- BaseModel
- SpotifyWebApi::PublicUserObject
- Defined in:
- lib/spotify_web_api/models/public_user_object.rb
Overview
PublicUserObject Model.
Instance Attribute Summary collapse
-
#display_name ⇒ String
The name displayed on the user’s profile.
-
#external_urls ⇒ ExternalUrlObject
Known public external URLs for this user.
-
#followers ⇒ FollowersObject
Information about the followers of this user.
-
#href ⇒ String
A link to the Web API endpoint for this user.
-
#id ⇒ String
The [Spotify user ID](/documentation/web-api/concepts/spotify-uris-ids) for this user.
-
#images ⇒ Array[ImageObject]
The user’s profile image.
-
#type ⇒ Type4Enum
The object type.
-
#uri ⇒ String
The [Spotify URI](/documentation/web-api/concepts/spotify-uris-ids) for this user.
Class Method Summary collapse
-
.from_hash(hash) ⇒ Object
Creates an instance of the object from a hash.
-
.names ⇒ Object
A mapping from model property names to API property names.
-
.nullables ⇒ Object
An array for nullable fields.
-
.optionals ⇒ Object
An array for optional fields.
Instance Method Summary collapse
-
#initialize(display_name = SKIP, external_urls = SKIP, followers = SKIP, href = SKIP, id = SKIP, images = SKIP, type = SKIP, uri = SKIP) ⇒ PublicUserObject
constructor
A new instance of PublicUserObject.
Methods inherited from BaseModel
Constructor Details
#initialize(display_name = SKIP, external_urls = SKIP, followers = SKIP, href = SKIP, id = SKIP, images = SKIP, type = SKIP, uri = SKIP) ⇒ PublicUserObject
Returns a new instance of PublicUserObject.
81 82 83 84 85 86 87 88 89 90 91 92 |
# File 'lib/spotify_web_api/models/public_user_object.rb', line 81 def initialize(display_name = SKIP, external_urls = SKIP, followers = SKIP, href = SKIP, id = SKIP, images = SKIP, type = SKIP, uri = SKIP) @display_name = display_name unless display_name == SKIP @external_urls = external_urls unless external_urls == SKIP @followers = followers unless followers == SKIP @href = href unless href == SKIP @id = id unless id == SKIP @images = images unless images == SKIP @type = type unless type == SKIP @uri = uri unless uri == SKIP end |
Instance Attribute Details
#display_name ⇒ String
The name displayed on the user’s profile. ‘null` if not available.
14 15 16 |
# File 'lib/spotify_web_api/models/public_user_object.rb', line 14 def display_name @display_name end |
#external_urls ⇒ ExternalUrlObject
Known public external URLs for this user.
18 19 20 |
# File 'lib/spotify_web_api/models/public_user_object.rb', line 18 def external_urls @external_urls end |
#followers ⇒ FollowersObject
Information about the followers of this user.
22 23 24 |
# File 'lib/spotify_web_api/models/public_user_object.rb', line 22 def followers @followers end |
#href ⇒ String
A link to the Web API endpoint for this user.
26 27 28 |
# File 'lib/spotify_web_api/models/public_user_object.rb', line 26 def href @href end |
#id ⇒ String
The [Spotify user ID](/documentation/web-api/concepts/spotify-uris-ids) for this user.
31 32 33 |
# File 'lib/spotify_web_api/models/public_user_object.rb', line 31 def id @id end |
#images ⇒ Array[ImageObject]
The user’s profile image.
35 36 37 |
# File 'lib/spotify_web_api/models/public_user_object.rb', line 35 def images @images end |
#type ⇒ Type4Enum
The object type.
39 40 41 |
# File 'lib/spotify_web_api/models/public_user_object.rb', line 39 def type @type end |
#uri ⇒ String
The [Spotify URI](/documentation/web-api/concepts/spotify-uris-ids) for this user.
44 45 46 |
# File 'lib/spotify_web_api/models/public_user_object.rb', line 44 def uri @uri end |
Class Method Details
.from_hash(hash) ⇒ Object
Creates an instance of the object from a hash.
95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 |
# File 'lib/spotify_web_api/models/public_user_object.rb', line 95 def self.from_hash(hash) return nil unless hash # Extract variables from the hash. display_name = hash.key?('display_name') ? hash['display_name'] : SKIP external_urls = ExternalUrlObject.from_hash(hash['external_urls']) if hash['external_urls'] followers = FollowersObject.from_hash(hash['followers']) if hash['followers'] href = hash.key?('href') ? hash['href'] : SKIP id = hash.key?('id') ? hash['id'] : SKIP # Parameter is an array, so we need to iterate through it images = nil unless hash['images'].nil? images = [] hash['images'].each do |structure| images << (ImageObject.from_hash(structure) if structure) end end images = SKIP unless hash.key?('images') type = hash.key?('type') ? hash['type'] : SKIP uri = hash.key?('uri') ? hash['uri'] : SKIP # Create object from extracted values. PublicUserObject.new(display_name, external_urls, followers, href, id, images, type, uri) end |
.names ⇒ Object
A mapping from model property names to API property names.
47 48 49 50 51 52 53 54 55 56 57 58 |
# File 'lib/spotify_web_api/models/public_user_object.rb', line 47 def self.names @_hash = {} if @_hash.nil? @_hash['display_name'] = 'display_name' @_hash['external_urls'] = 'external_urls' @_hash['followers'] = 'followers' @_hash['href'] = 'href' @_hash['id'] = 'id' @_hash['images'] = 'images' @_hash['type'] = 'type' @_hash['uri'] = 'uri' @_hash end |
.nullables ⇒ Object
An array for nullable fields
75 76 77 78 79 |
# File 'lib/spotify_web_api/models/public_user_object.rb', line 75 def self.nullables %w[ display_name ] end |
.optionals ⇒ Object
An array for optional fields
61 62 63 64 65 66 67 68 69 70 71 72 |
# File 'lib/spotify_web_api/models/public_user_object.rb', line 61 def self.optionals %w[ display_name external_urls followers href id images type uri ] end |