Class: SpotifyWebApi::PrivateUserObject

Inherits:
BaseModel
  • Object
show all
Defined in:
lib/spotify_web_api/models/private_user_object.rb

Overview

PrivateUserObject Model.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from BaseModel

#to_hash, #to_json

Constructor Details

#initialize(country = SKIP, display_name = SKIP, email = SKIP, explicit_content = SKIP, external_urls = SKIP, followers = SKIP, href = SKIP, id = SKIP, images = SKIP, product = SKIP, type = SKIP, uri = SKIP) ⇒ PrivateUserObject

Returns a new instance of PrivateUserObject.



120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
# File 'lib/spotify_web_api/models/private_user_object.rb', line 120

def initialize(country = SKIP, display_name = SKIP, email = SKIP,
               explicit_content = SKIP, external_urls = SKIP,
               followers = SKIP, href = SKIP, id = SKIP, images = SKIP,
               product = SKIP, type = SKIP, uri = SKIP)
  @country = country unless country == SKIP
  @display_name = display_name unless display_name == SKIP
  @email = email unless email == SKIP
  @explicit_content = explicit_content unless explicit_content == 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
  @product = product unless product == SKIP
  @type = type unless type == SKIP
  @uri = uri unless uri == SKIP
end

Instance Attribute Details

#countryString

The country of the user, as set in the user’s account profile. An [ISO 3166-1 alpha-2 country code](en.wikipedia.org/wiki/ISO_3166-1_alpha-2). _This field is only available when the current user has granted access to the [user-read-private](/documentation/web-api/concepts/scopes/#list-of-scopes ) scope._

Returns:

  • (String)


19
20
21
# File 'lib/spotify_web_api/models/private_user_object.rb', line 19

def country
  @country
end

#display_nameString

The name displayed on the user’s profile. ‘null` if not available.

Returns:

  • (String)


23
24
25
# File 'lib/spotify_web_api/models/private_user_object.rb', line 23

def display_name
  @display_name
end

#emailString

The user’s email address, as entered by the user when creating their account. _**Important!** This email address is unverified; there is no proof that it actually belongs to the user._ _This field is only available when the current user has granted access to the [user-read-email](/documentation/web-api/concepts/scopes/#list-of-scopes) scope._

Returns:

  • (String)


32
33
34
# File 'lib/spotify_web_api/models/private_user_object.rb', line 32

def email
  @email
end

#explicit_contentExplicitContentSettingsObject

The user’s explicit content settings. _This field is only available when the current user has granted access to the [user-read-private](/documentation/web-api/concepts/scopes/#list-of-scopes ) scope._



39
40
41
# File 'lib/spotify_web_api/models/private_user_object.rb', line 39

def explicit_content
  @explicit_content
end

#external_urlsExternalUrlObject

Known external URLs for this user.

Returns:



43
44
45
# File 'lib/spotify_web_api/models/private_user_object.rb', line 43

def external_urls
  @external_urls
end

#followersFollowersObject

Information about the followers of the user.

Returns:



47
48
49
# File 'lib/spotify_web_api/models/private_user_object.rb', line 47

def followers
  @followers
end

#hrefString

A link to the Web API endpoint for this user.

Returns:

  • (String)


51
52
53
# File 'lib/spotify_web_api/models/private_user_object.rb', line 51

def href
  @href
end

#idString

The [Spotify user ID](/documentation/web-api/concepts/spotify-uris-ids) for the user.

Returns:

  • (String)


56
57
58
# File 'lib/spotify_web_api/models/private_user_object.rb', line 56

def id
  @id
end

#imagesArray[ImageObject]

The user’s profile image.

Returns:



60
61
62
# File 'lib/spotify_web_api/models/private_user_object.rb', line 60

def images
  @images
end

#productString

The user’s Spotify subscription level: “premium”, “free”, etc. (The subscription level “open” can be considered the same as “free”.) _This field is only available when the current user has granted access to the [user-read-private](/documentation/web-api/concepts/scopes/#list-of-scopes ) scope._

Returns:

  • (String)


68
69
70
# File 'lib/spotify_web_api/models/private_user_object.rb', line 68

def product
  @product
end

#typeString

The object type: “user”

Returns:

  • (String)


72
73
74
# File 'lib/spotify_web_api/models/private_user_object.rb', line 72

def type
  @type
end

#uriString

The [Spotify URI](/documentation/web-api/concepts/spotify-uris-ids) for the user.

Returns:

  • (String)


77
78
79
# File 'lib/spotify_web_api/models/private_user_object.rb', line 77

def uri
  @uri
end

Class Method Details

.from_hash(hash) ⇒ Object

Creates an instance of the object from a hash.



139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
# File 'lib/spotify_web_api/models/private_user_object.rb', line 139

def self.from_hash(hash)
  return nil unless hash

  # Extract variables from the hash.
  country = hash.key?('country') ? hash['country'] : SKIP
  display_name = hash.key?('display_name') ? hash['display_name'] : SKIP
  email = hash.key?('email') ? hash['email'] : SKIP
  explicit_content = ExplicitContentSettingsObject.from_hash(hash['explicit_content']) if
    hash['explicit_content']
  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')
  product = hash.key?('product') ? hash['product'] : SKIP
  type = hash.key?('type') ? hash['type'] : SKIP
  uri = hash.key?('uri') ? hash['uri'] : SKIP

  # Create object from extracted values.
  PrivateUserObject.new(country,
                        display_name,
                        email,
                        explicit_content,
                        external_urls,
                        followers,
                        href,
                        id,
                        images,
                        product,
                        type,
                        uri)
end

.namesObject

A mapping from model property names to API property names.



80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
# File 'lib/spotify_web_api/models/private_user_object.rb', line 80

def self.names
  @_hash = {} if @_hash.nil?
  @_hash['country'] = 'country'
  @_hash['display_name'] = 'display_name'
  @_hash['email'] = 'email'
  @_hash['explicit_content'] = 'explicit_content'
  @_hash['external_urls'] = 'external_urls'
  @_hash['followers'] = 'followers'
  @_hash['href'] = 'href'
  @_hash['id'] = 'id'
  @_hash['images'] = 'images'
  @_hash['product'] = 'product'
  @_hash['type'] = 'type'
  @_hash['uri'] = 'uri'
  @_hash
end

.nullablesObject

An array for nullable fields



116
117
118
# File 'lib/spotify_web_api/models/private_user_object.rb', line 116

def self.nullables
  []
end

.optionalsObject

An array for optional fields



98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
# File 'lib/spotify_web_api/models/private_user_object.rb', line 98

def self.optionals
  %w[
    country
    display_name
    email
    explicit_content
    external_urls
    followers
    href
    id
    images
    product
    type
    uri
  ]
end