spotify-api-sdk 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/LICENSE +30 -0
- data/README.md +107 -0
- data/lib/spotify_web_api/api_helper.rb +10 -0
- data/lib/spotify_web_api/client.rb +154 -0
- data/lib/spotify_web_api/configuration.rb +180 -0
- data/lib/spotify_web_api/controllers/albums_controller.rb +295 -0
- data/lib/spotify_web_api/controllers/artists_controller.rb +187 -0
- data/lib/spotify_web_api/controllers/audiobooks_controller.rb +258 -0
- data/lib/spotify_web_api/controllers/base_controller.rb +66 -0
- data/lib/spotify_web_api/controllers/categories_controller.rb +83 -0
- data/lib/spotify_web_api/controllers/chapters_controller.rb +82 -0
- data/lib/spotify_web_api/controllers/episodes_controller.rb +239 -0
- data/lib/spotify_web_api/controllers/genres_controller.rb +39 -0
- data/lib/spotify_web_api/controllers/markets_controller.rb +38 -0
- data/lib/spotify_web_api/controllers/o_auth_authorization_controller.rb +82 -0
- data/lib/spotify_web_api/controllers/player_controller.rb +509 -0
- data/lib/spotify_web_api/controllers/playlists_controller.rb +521 -0
- data/lib/spotify_web_api/controllers/search_controller.rb +60 -0
- data/lib/spotify_web_api/controllers/shows_controller.rb +261 -0
- data/lib/spotify_web_api/controllers/tracks_controller.rb +491 -0
- data/lib/spotify_web_api/controllers/users_controller.rb +396 -0
- data/lib/spotify_web_api/exceptions/api_exception.rb +10 -0
- data/lib/spotify_web_api/exceptions/bad_request_exception.rb +32 -0
- data/lib/spotify_web_api/exceptions/forbidden_exception.rb +32 -0
- data/lib/spotify_web_api/exceptions/not_found_exception.rb +32 -0
- data/lib/spotify_web_api/exceptions/o_auth_provider_exception.rb +48 -0
- data/lib/spotify_web_api/exceptions/too_many_requests_exception.rb +32 -0
- data/lib/spotify_web_api/exceptions/unauthorized_exception.rb +32 -0
- data/lib/spotify_web_api/http/api_response.rb +21 -0
- data/lib/spotify_web_api/http/auth/o_auth2.rb +146 -0
- data/lib/spotify_web_api/http/http_call_back.rb +10 -0
- data/lib/spotify_web_api/http/http_method_enum.rb +10 -0
- data/lib/spotify_web_api/http/http_request.rb +10 -0
- data/lib/spotify_web_api/http/http_response.rb +10 -0
- data/lib/spotify_web_api/models/album_base.rb +168 -0
- data/lib/spotify_web_api/models/album_group_enum.rb +29 -0
- data/lib/spotify_web_api/models/album_object.rb +247 -0
- data/lib/spotify_web_api/models/album_restriction_object.rb +53 -0
- data/lib/spotify_web_api/models/album_type_enum.rb +26 -0
- data/lib/spotify_web_api/models/artist_discography_album_object.rb +194 -0
- data/lib/spotify_web_api/models/artist_object.rb +147 -0
- data/lib/spotify_web_api/models/audio_analysis_object.rb +156 -0
- data/lib/spotify_web_api/models/audio_features_object.rb +249 -0
- data/lib/spotify_web_api/models/audiobook_base.rb +245 -0
- data/lib/spotify_web_api/models/audiobook_object.rb +253 -0
- data/lib/spotify_web_api/models/author_object.rb +50 -0
- data/lib/spotify_web_api/models/base_model.rb +62 -0
- data/lib/spotify_web_api/models/categories.rb +110 -0
- data/lib/spotify_web_api/models/category_object.rb +82 -0
- data/lib/spotify_web_api/models/chapter_base.rb +237 -0
- data/lib/spotify_web_api/models/chapter_object.rb +245 -0
- data/lib/spotify_web_api/models/chapter_restriction_object.rb +59 -0
- data/lib/spotify_web_api/models/context_object.rb +78 -0
- data/lib/spotify_web_api/models/copyright_object.rb +60 -0
- data/lib/spotify_web_api/models/currently_playing_context_object.rb +137 -0
- data/lib/spotify_web_api/models/currently_playing_object.rb +109 -0
- data/lib/spotify_web_api/models/cursor_object.rb +59 -0
- data/lib/spotify_web_api/models/cursor_paged_artists.rb +48 -0
- data/lib/spotify_web_api/models/cursor_paging_object.rb +88 -0
- data/lib/spotify_web_api/models/cursor_paging_play_history_object.rb +106 -0
- data/lib/spotify_web_api/models/cursor_paging_simplified_artist_object.rb +106 -0
- data/lib/spotify_web_api/models/device_object.rb +126 -0
- data/lib/spotify_web_api/models/disallows_object.rb +140 -0
- data/lib/spotify_web_api/models/episode_base.rb +237 -0
- data/lib/spotify_web_api/models/episode_object.rb +246 -0
- data/lib/spotify_web_api/models/episode_restriction_object.rb +58 -0
- data/lib/spotify_web_api/models/error_object.rb +59 -0
- data/lib/spotify_web_api/models/explicit_content_settings_object.rb +61 -0
- data/lib/spotify_web_api/models/external_id_object.rb +72 -0
- data/lib/spotify_web_api/models/external_url_object.rb +51 -0
- data/lib/spotify_web_api/models/followers_object.rb +62 -0
- data/lib/spotify_web_api/models/image_object.rb +67 -0
- data/lib/spotify_web_api/models/include_external_enum.rb +23 -0
- data/lib/spotify_web_api/models/item_type1_enum.rb +20 -0
- data/lib/spotify_web_api/models/item_type2_enum.rb +23 -0
- data/lib/spotify_web_api/models/item_type3_enum.rb +23 -0
- data/lib/spotify_web_api/models/item_type_enum.rb +38 -0
- data/lib/spotify_web_api/models/linked_track_object.rb +89 -0
- data/lib/spotify_web_api/models/many_albums.rb +57 -0
- data/lib/spotify_web_api/models/many_artists.rb +57 -0
- data/lib/spotify_web_api/models/many_audio_features.rb +57 -0
- data/lib/spotify_web_api/models/many_audiobooks.rb +57 -0
- data/lib/spotify_web_api/models/many_chapters.rb +57 -0
- data/lib/spotify_web_api/models/many_devices.rb +57 -0
- data/lib/spotify_web_api/models/many_episodes.rb +57 -0
- data/lib/spotify_web_api/models/many_genres.rb +48 -0
- data/lib/spotify_web_api/models/many_simplified_shows.rb +57 -0
- data/lib/spotify_web_api/models/many_tracks.rb +57 -0
- data/lib/spotify_web_api/models/markets.rb +50 -0
- data/lib/spotify_web_api/models/me_albums_request.rb +55 -0
- data/lib/spotify_web_api/models/me_episodes_request.rb +52 -0
- data/lib/spotify_web_api/models/me_episodes_request1.rb +54 -0
- data/lib/spotify_web_api/models/me_following_request.rb +53 -0
- data/lib/spotify_web_api/models/me_following_request1.rb +55 -0
- data/lib/spotify_web_api/models/me_player_play_request.rb +89 -0
- data/lib/spotify_web_api/models/me_player_request.rb +63 -0
- data/lib/spotify_web_api/models/me_shows_request.rb +55 -0
- data/lib/spotify_web_api/models/me_tracks_request.rb +53 -0
- data/lib/spotify_web_api/models/me_tracks_request1.rb +55 -0
- data/lib/spotify_web_api/models/meta.rb +110 -0
- data/lib/spotify_web_api/models/mode_enum.rb +30 -0
- data/lib/spotify_web_api/models/narrator_object.rb +50 -0
- data/lib/spotify_web_api/models/o_auth_provider_error_enum.rb +45 -0
- data/lib/spotify_web_api/models/o_auth_scope_enum.rb +94 -0
- data/lib/spotify_web_api/models/o_auth_token.rb +96 -0
- data/lib/spotify_web_api/models/paged_albums.rb +48 -0
- data/lib/spotify_web_api/models/paged_categories.rb +48 -0
- data/lib/spotify_web_api/models/paging_artist_discography_album_object.rb +110 -0
- data/lib/spotify_web_api/models/paging_artist_object.rb +110 -0
- data/lib/spotify_web_api/models/paging_featured_playlist_object.rb +59 -0
- data/lib/spotify_web_api/models/paging_object.rb +93 -0
- data/lib/spotify_web_api/models/paging_playlist_object.rb +110 -0
- data/lib/spotify_web_api/models/paging_playlist_track_object.rb +110 -0
- data/lib/spotify_web_api/models/paging_saved_album_object.rb +110 -0
- data/lib/spotify_web_api/models/paging_saved_audiobook_object.rb +110 -0
- data/lib/spotify_web_api/models/paging_saved_episode_object.rb +110 -0
- data/lib/spotify_web_api/models/paging_saved_show_object.rb +110 -0
- data/lib/spotify_web_api/models/paging_saved_track_object.rb +110 -0
- data/lib/spotify_web_api/models/paging_simplified_album_object.rb +110 -0
- data/lib/spotify_web_api/models/paging_simplified_audiobook_object.rb +110 -0
- data/lib/spotify_web_api/models/paging_simplified_chapter_object.rb +110 -0
- data/lib/spotify_web_api/models/paging_simplified_episode_object.rb +110 -0
- data/lib/spotify_web_api/models/paging_simplified_show_object.rb +110 -0
- data/lib/spotify_web_api/models/paging_simplified_track_object.rb +110 -0
- data/lib/spotify_web_api/models/paging_track_object.rb +110 -0
- data/lib/spotify_web_api/models/play_history_object.rb +77 -0
- data/lib/spotify_web_api/models/playlist_object.rb +193 -0
- data/lib/spotify_web_api/models/playlist_owner_object.rb +109 -0
- data/lib/spotify_web_api/models/playlist_snapshot_id.rb +50 -0
- data/lib/spotify_web_api/models/playlist_track_object.rb +90 -0
- data/lib/spotify_web_api/models/playlist_tracks_ref_object.rb +60 -0
- data/lib/spotify_web_api/models/playlist_user_object.rb +98 -0
- data/lib/spotify_web_api/models/playlists_followers_request.rb +51 -0
- data/lib/spotify_web_api/models/playlists_request.rb +82 -0
- data/lib/spotify_web_api/models/playlists_tracks_request.rb +72 -0
- data/lib/spotify_web_api/models/playlists_tracks_request1.rb +97 -0
- data/lib/spotify_web_api/models/playlists_tracks_request2.rb +75 -0
- data/lib/spotify_web_api/models/private_user_object.rb +181 -0
- data/lib/spotify_web_api/models/public_user_object.rb +128 -0
- data/lib/spotify_web_api/models/queue_object.rb +60 -0
- data/lib/spotify_web_api/models/reason_enum.rb +29 -0
- data/lib/spotify_web_api/models/recommendation_seed_object.rb +104 -0
- data/lib/spotify_web_api/models/recommendations_object.rb +74 -0
- data/lib/spotify_web_api/models/release_date_precision_enum.rb +26 -0
- data/lib/spotify_web_api/models/resume_point_object.rb +60 -0
- data/lib/spotify_web_api/models/saved_album_object.rb +73 -0
- data/lib/spotify_web_api/models/saved_audiobook_object.rb +73 -0
- data/lib/spotify_web_api/models/saved_episode_object.rb +70 -0
- data/lib/spotify_web_api/models/saved_show_object.rb +73 -0
- data/lib/spotify_web_api/models/saved_track_object.rb +73 -0
- data/lib/spotify_web_api/models/search_items.rb +107 -0
- data/lib/spotify_web_api/models/section_object.rb +180 -0
- data/lib/spotify_web_api/models/segment_object.rb +166 -0
- data/lib/spotify_web_api/models/show_base.rb +211 -0
- data/lib/spotify_web_api/models/show_object.rb +219 -0
- data/lib/spotify_web_api/models/simplified_album_object.rb +186 -0
- data/lib/spotify_web_api/models/simplified_artist_object.rb +98 -0
- data/lib/spotify_web_api/models/simplified_playlist_object.rb +184 -0
- data/lib/spotify_web_api/models/simplified_track_object.rb +227 -0
- data/lib/spotify_web_api/models/time_interval_object.rb +68 -0
- data/lib/spotify_web_api/models/track.rb +331 -0
- data/lib/spotify_web_api/models/track1.rb +50 -0
- data/lib/spotify_web_api/models/track_object.rb +265 -0
- data/lib/spotify_web_api/models/track_restriction_object.rb +58 -0
- data/lib/spotify_web_api/models/type2_enum.rb +20 -0
- data/lib/spotify_web_api/models/type3_enum.rb +20 -0
- data/lib/spotify_web_api/models/type4_enum.rb +20 -0
- data/lib/spotify_web_api/models/type6_enum.rb +20 -0
- data/lib/spotify_web_api/models/type7_enum.rb +20 -0
- data/lib/spotify_web_api/models/type8_enum.rb +20 -0
- data/lib/spotify_web_api/models/type9_enum.rb +20 -0
- data/lib/spotify_web_api/models/type_enum.rb +20 -0
- data/lib/spotify_web_api/models/users_playlists_request.rb +87 -0
- data/lib/spotify_web_api/utilities/date_time_helper.rb +11 -0
- data/lib/spotify_web_api/utilities/file_wrapper.rb +16 -0
- data/lib/spotify_web_api.rb +198 -0
- metadata +264 -0
@@ -0,0 +1,146 @@
|
|
1
|
+
# spotify_web_api
|
2
|
+
#
|
3
|
+
# This file was automatically generated by APIMATIC v2.0
|
4
|
+
# ( https://apimatic.io ).
|
5
|
+
|
6
|
+
module SpotifyWebApi
|
7
|
+
# Utility class for OAuth 2 authorization and token management.
|
8
|
+
class OAuth2 < CoreLibrary::HeaderAuth
|
9
|
+
include CoreLibrary
|
10
|
+
# Display error message on occurrence of authentication failure.
|
11
|
+
# @returns [String] The oAuth error message.
|
12
|
+
def error_message
|
13
|
+
'AuthorizationCodeAuth: OAuthToken is undefined or expired.'
|
14
|
+
end
|
15
|
+
|
16
|
+
# Initialization constructor.
|
17
|
+
def initialize(authorization_code_auth_credentials, config)
|
18
|
+
auth_params = {}
|
19
|
+
@_o_auth_client_id = authorization_code_auth_credentials.o_auth_client_id unless
|
20
|
+
authorization_code_auth_credentials.nil? || authorization_code_auth_credentials.o_auth_client_id.nil?
|
21
|
+
@_o_auth_client_secret = authorization_code_auth_credentials.o_auth_client_secret unless
|
22
|
+
authorization_code_auth_credentials.nil? || authorization_code_auth_credentials.o_auth_client_secret.nil?
|
23
|
+
@_o_auth_redirect_uri = authorization_code_auth_credentials.o_auth_redirect_uri unless
|
24
|
+
authorization_code_auth_credentials.nil? || authorization_code_auth_credentials.o_auth_redirect_uri.nil?
|
25
|
+
@_o_auth_token = authorization_code_auth_credentials.o_auth_token unless
|
26
|
+
authorization_code_auth_credentials.nil? || authorization_code_auth_credentials.o_auth_token.nil?
|
27
|
+
@_o_auth_scopes = authorization_code_auth_credentials.o_auth_scopes unless
|
28
|
+
authorization_code_auth_credentials.nil? || authorization_code_auth_credentials.o_auth_scopes.nil?
|
29
|
+
@_config = config
|
30
|
+
@_o_auth_api = OAuthAuthorizationController.new(config)
|
31
|
+
auth_params['Authorization'] = "Bearer #{@_o_auth_token.access_token}" unless @_o_auth_token.nil?
|
32
|
+
|
33
|
+
super auth_params
|
34
|
+
end
|
35
|
+
|
36
|
+
# Validates the oAuth token.
|
37
|
+
# @return [Boolean] true if the token is present and not expired.
|
38
|
+
def valid
|
39
|
+
!@_o_auth_token.nil? && !token_expired?(@_o_auth_token)
|
40
|
+
end
|
41
|
+
|
42
|
+
# Builds and returns an authorization URL.
|
43
|
+
# The user is expected to obtain an authorization code from this URL and then call the
|
44
|
+
# fetch token function with that authorization code.
|
45
|
+
# @param [String] state An opaque state string.
|
46
|
+
# @param [Hash] additional_params Any additional query parameters to be added to the URL.
|
47
|
+
# @return [String] additional_params The authorization URL.
|
48
|
+
def get_authorization_url(state: nil, additional_params: nil)
|
49
|
+
auth_url = @_config.get_base_uri(Server.AUTH_SERVER)
|
50
|
+
auth_url += '/authorize'
|
51
|
+
query_params = {
|
52
|
+
'response_type' => 'code',
|
53
|
+
'client_id' => @_o_auth_client_id,
|
54
|
+
'redirect_uri' => @_o_auth_client_id
|
55
|
+
}
|
56
|
+
query_params['scope'] = Array(@_o_auth_scopes).compact.join(' ') if @_o_auth_scopes
|
57
|
+
query_params['state'] = state if state
|
58
|
+
query_params.merge!(additional_params) if additional_params
|
59
|
+
auth_url = APIHelper.append_url_with_query_parameters(auth_url,
|
60
|
+
query_params)
|
61
|
+
APIHelper.clean_url(auth_url)
|
62
|
+
end
|
63
|
+
|
64
|
+
# Builds the basic auth header for endpoints in the OAuth Authorization Controller.
|
65
|
+
# @return [String] The value of the Authentication header.
|
66
|
+
def build_basic_auth_header
|
67
|
+
"Basic #{AuthHelper.get_base64_encoded_value(@_o_auth_client_id, @_o_auth_client_secret)}"
|
68
|
+
end
|
69
|
+
|
70
|
+
# Fetches the token.
|
71
|
+
# @param [String] auth_code The authentication code.
|
72
|
+
# @param [Hash] additional_params Any additional form parameters.
|
73
|
+
# @return [OAuthToken] The oAuth token instance.
|
74
|
+
def fetch_token(auth_code, additional_params: nil)
|
75
|
+
token = @_o_auth_api.request_token(
|
76
|
+
build_basic_auth_header,
|
77
|
+
auth_code,
|
78
|
+
@_o_auth_redirect_uri,
|
79
|
+
_field_parameters: additional_params
|
80
|
+
).data
|
81
|
+
if token.respond_to?('expires_in') && !token.expires_in.nil?
|
82
|
+
token.expiry = AuthHelper.get_token_expiry(token.expires_in, Time.now.utc.to_i)
|
83
|
+
end
|
84
|
+
token
|
85
|
+
end
|
86
|
+
|
87
|
+
# Checks if OAuth token has expired.
|
88
|
+
# @param [OAuthToken] token The oAuth token instance.
|
89
|
+
# @return [Boolean] true if the token is present and not expired.
|
90
|
+
def token_expired?(token)
|
91
|
+
token.respond_to?('expiry') && AuthHelper.token_expired?(token.expiry)
|
92
|
+
end
|
93
|
+
|
94
|
+
# Refreshes OAuth token.
|
95
|
+
# @param [Hash] additional_params Any additional form parameters.
|
96
|
+
# @return [OAuthToken] The oAuth token instance.
|
97
|
+
def refresh_token(additional_params: nil)
|
98
|
+
token = @_o_auth_api.refresh_token(
|
99
|
+
OAuth2.build_basic_auth_header,
|
100
|
+
@_o_auth_token.refresh_token,
|
101
|
+
scope: !@_o_auth_scopes.nil? ? Array(@_o_auth_scopes).compact.join(' ') : nil,
|
102
|
+
_field_parameters: additional_params
|
103
|
+
).data
|
104
|
+
if token.respond_to?('expires_in') && !token.expires_in.nil?
|
105
|
+
token.expiry = AuthHelper.get_token_expiry(token.expires_in, Time.now.utc.to_i)
|
106
|
+
end
|
107
|
+
token
|
108
|
+
end
|
109
|
+
end
|
110
|
+
|
111
|
+
# Data class for AuthorizationCodeAuthCredentials.
|
112
|
+
class AuthorizationCodeAuthCredentials
|
113
|
+
attr_reader :o_auth_client_id, :o_auth_client_secret, :o_auth_redirect_uri,
|
114
|
+
:o_auth_token, :o_auth_scopes
|
115
|
+
|
116
|
+
def initialize(o_auth_client_id:, o_auth_client_secret:,
|
117
|
+
o_auth_redirect_uri:, o_auth_token: nil, o_auth_scopes: nil)
|
118
|
+
raise ArgumentError, 'o_auth_client_id cannot be nil' if o_auth_client_id.nil?
|
119
|
+
raise ArgumentError, 'o_auth_client_secret cannot be nil' if o_auth_client_secret.nil?
|
120
|
+
raise ArgumentError, 'o_auth_redirect_uri cannot be nil' if o_auth_redirect_uri.nil?
|
121
|
+
|
122
|
+
@o_auth_client_id = o_auth_client_id
|
123
|
+
@o_auth_client_secret = o_auth_client_secret
|
124
|
+
@o_auth_redirect_uri = o_auth_redirect_uri
|
125
|
+
@o_auth_token = o_auth_token
|
126
|
+
@o_auth_scopes = o_auth_scopes
|
127
|
+
end
|
128
|
+
|
129
|
+
def clone_with(o_auth_client_id: nil, o_auth_client_secret: nil,
|
130
|
+
o_auth_redirect_uri: nil, o_auth_token: nil,
|
131
|
+
o_auth_scopes: nil)
|
132
|
+
o_auth_client_id ||= self.o_auth_client_id
|
133
|
+
o_auth_client_secret ||= self.o_auth_client_secret
|
134
|
+
o_auth_redirect_uri ||= self.o_auth_redirect_uri
|
135
|
+
o_auth_token ||= self.o_auth_token
|
136
|
+
o_auth_scopes ||= self.o_auth_scopes
|
137
|
+
|
138
|
+
AuthorizationCodeAuthCredentials.new(
|
139
|
+
o_auth_client_id: o_auth_client_id,
|
140
|
+
o_auth_client_secret: o_auth_client_secret,
|
141
|
+
o_auth_redirect_uri: o_auth_redirect_uri, o_auth_token: o_auth_token,
|
142
|
+
o_auth_scopes: o_auth_scopes
|
143
|
+
)
|
144
|
+
end
|
145
|
+
end
|
146
|
+
end
|
@@ -0,0 +1,10 @@
|
|
1
|
+
# spotify_web_api
|
2
|
+
#
|
3
|
+
# This file was automatically generated by APIMATIC v2.0
|
4
|
+
# ( https://apimatic.io ).
|
5
|
+
|
6
|
+
module SpotifyWebApi
|
7
|
+
# HttpCallBack allows defining callables for pre and post API calls.
|
8
|
+
class HttpCallBack < CoreLibrary::HttpCallback
|
9
|
+
end
|
10
|
+
end
|
@@ -0,0 +1,168 @@
|
|
1
|
+
# spotify_web_api
|
2
|
+
#
|
3
|
+
# This file was automatically generated by APIMATIC v2.0
|
4
|
+
# ( https://apimatic.io ).
|
5
|
+
|
6
|
+
module SpotifyWebApi
|
7
|
+
# AlbumBase Model.
|
8
|
+
class AlbumBase < BaseModel
|
9
|
+
SKIP = Object.new
|
10
|
+
private_constant :SKIP
|
11
|
+
|
12
|
+
# The type of the album.
|
13
|
+
# @return [AlbumTypeEnum]
|
14
|
+
attr_accessor :album_type
|
15
|
+
|
16
|
+
# The number of tracks in the album.
|
17
|
+
# @return [Integer]
|
18
|
+
attr_accessor :total_tracks
|
19
|
+
|
20
|
+
# The markets in which the album is available: [ISO 3166-1 alpha-2 country
|
21
|
+
# codes](http://en.wikipedia.org/wiki/ISO_3166-1_alpha-2). _**NOTE**: an
|
22
|
+
# album is considered available in a market when at least 1 of its tracks is
|
23
|
+
# available in that market._
|
24
|
+
# @return [Array[String]]
|
25
|
+
attr_accessor :available_markets
|
26
|
+
|
27
|
+
# Known external URLs for this album.
|
28
|
+
# @return [ExternalUrlObject]
|
29
|
+
attr_accessor :external_urls
|
30
|
+
|
31
|
+
# A link to the Web API endpoint providing full details of the album.
|
32
|
+
# @return [String]
|
33
|
+
attr_accessor :href
|
34
|
+
|
35
|
+
# The [Spotify ID](/documentation/web-api/concepts/spotify-uris-ids) for the
|
36
|
+
# album.
|
37
|
+
# @return [String]
|
38
|
+
attr_accessor :id
|
39
|
+
|
40
|
+
# The cover art for the album in various sizes, widest first.
|
41
|
+
# @return [Array[ImageObject]]
|
42
|
+
attr_accessor :images
|
43
|
+
|
44
|
+
# The name of the album. In case of an album takedown, the value may be an
|
45
|
+
# empty string.
|
46
|
+
# @return [String]
|
47
|
+
attr_accessor :name
|
48
|
+
|
49
|
+
# The date the album was first released.
|
50
|
+
# @return [String]
|
51
|
+
attr_accessor :release_date
|
52
|
+
|
53
|
+
# The precision with which `release_date` value is known.
|
54
|
+
# @return [ReleaseDatePrecisionEnum]
|
55
|
+
attr_accessor :release_date_precision
|
56
|
+
|
57
|
+
# Included in the response when a content restriction is applied.
|
58
|
+
# @return [AlbumRestrictionObject]
|
59
|
+
attr_accessor :restrictions
|
60
|
+
|
61
|
+
# The object type.
|
62
|
+
# @return [Type2Enum]
|
63
|
+
attr_accessor :type
|
64
|
+
|
65
|
+
# The [Spotify URI](/documentation/web-api/concepts/spotify-uris-ids) for
|
66
|
+
# the album.
|
67
|
+
# @return [String]
|
68
|
+
attr_accessor :uri
|
69
|
+
|
70
|
+
# A mapping from model property names to API property names.
|
71
|
+
def self.names
|
72
|
+
@_hash = {} if @_hash.nil?
|
73
|
+
@_hash['album_type'] = 'album_type'
|
74
|
+
@_hash['total_tracks'] = 'total_tracks'
|
75
|
+
@_hash['available_markets'] = 'available_markets'
|
76
|
+
@_hash['external_urls'] = 'external_urls'
|
77
|
+
@_hash['href'] = 'href'
|
78
|
+
@_hash['id'] = 'id'
|
79
|
+
@_hash['images'] = 'images'
|
80
|
+
@_hash['name'] = 'name'
|
81
|
+
@_hash['release_date'] = 'release_date'
|
82
|
+
@_hash['release_date_precision'] = 'release_date_precision'
|
83
|
+
@_hash['restrictions'] = 'restrictions'
|
84
|
+
@_hash['type'] = 'type'
|
85
|
+
@_hash['uri'] = 'uri'
|
86
|
+
@_hash
|
87
|
+
end
|
88
|
+
|
89
|
+
# An array for optional fields
|
90
|
+
def self.optionals
|
91
|
+
%w[
|
92
|
+
restrictions
|
93
|
+
]
|
94
|
+
end
|
95
|
+
|
96
|
+
# An array for nullable fields
|
97
|
+
def self.nullables
|
98
|
+
[]
|
99
|
+
end
|
100
|
+
|
101
|
+
def initialize(album_type = nil, total_tracks = nil,
|
102
|
+
available_markets = nil, external_urls = nil, href = nil,
|
103
|
+
id = nil, images = nil, name = nil, release_date = nil,
|
104
|
+
release_date_precision = nil, type = nil, uri = nil,
|
105
|
+
restrictions = SKIP)
|
106
|
+
@album_type = album_type
|
107
|
+
@total_tracks = total_tracks
|
108
|
+
@available_markets = available_markets
|
109
|
+
@external_urls = external_urls
|
110
|
+
@href = href
|
111
|
+
@id = id
|
112
|
+
@images = images
|
113
|
+
@name = name
|
114
|
+
@release_date = release_date
|
115
|
+
@release_date_precision = release_date_precision
|
116
|
+
@restrictions = restrictions unless restrictions == SKIP
|
117
|
+
@type = type
|
118
|
+
@uri = uri
|
119
|
+
end
|
120
|
+
|
121
|
+
# Creates an instance of the object from a hash.
|
122
|
+
def self.from_hash(hash)
|
123
|
+
return nil unless hash
|
124
|
+
|
125
|
+
# Extract variables from the hash.
|
126
|
+
album_type = hash.key?('album_type') ? hash['album_type'] : nil
|
127
|
+
total_tracks = hash.key?('total_tracks') ? hash['total_tracks'] : nil
|
128
|
+
available_markets =
|
129
|
+
hash.key?('available_markets') ? hash['available_markets'] : nil
|
130
|
+
external_urls = ExternalUrlObject.from_hash(hash['external_urls']) if hash['external_urls']
|
131
|
+
href = hash.key?('href') ? hash['href'] : nil
|
132
|
+
id = hash.key?('id') ? hash['id'] : nil
|
133
|
+
# Parameter is an array, so we need to iterate through it
|
134
|
+
images = nil
|
135
|
+
unless hash['images'].nil?
|
136
|
+
images = []
|
137
|
+
hash['images'].each do |structure|
|
138
|
+
images << (ImageObject.from_hash(structure) if structure)
|
139
|
+
end
|
140
|
+
end
|
141
|
+
|
142
|
+
images = nil unless hash.key?('images')
|
143
|
+
name = hash.key?('name') ? hash['name'] : nil
|
144
|
+
release_date = hash.key?('release_date') ? hash['release_date'] : nil
|
145
|
+
release_date_precision =
|
146
|
+
hash.key?('release_date_precision') ? hash['release_date_precision'] : nil
|
147
|
+
type = hash.key?('type') ? hash['type'] : nil
|
148
|
+
uri = hash.key?('uri') ? hash['uri'] : nil
|
149
|
+
restrictions = AlbumRestrictionObject.from_hash(hash['restrictions']) if
|
150
|
+
hash['restrictions']
|
151
|
+
|
152
|
+
# Create object from extracted values.
|
153
|
+
AlbumBase.new(album_type,
|
154
|
+
total_tracks,
|
155
|
+
available_markets,
|
156
|
+
external_urls,
|
157
|
+
href,
|
158
|
+
id,
|
159
|
+
images,
|
160
|
+
name,
|
161
|
+
release_date,
|
162
|
+
release_date_precision,
|
163
|
+
type,
|
164
|
+
uri,
|
165
|
+
restrictions)
|
166
|
+
end
|
167
|
+
end
|
168
|
+
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
# spotify_web_api
|
2
|
+
#
|
3
|
+
# This file was automatically generated by APIMATIC v2.0
|
4
|
+
# ( https://apimatic.io ).
|
5
|
+
|
6
|
+
module SpotifyWebApi
|
7
|
+
# This field describes the relationship between the artist and the album.
|
8
|
+
class AlbumGroupEnum
|
9
|
+
ALBUM_GROUP_ENUM = [
|
10
|
+
# TODO: Write general description for ALBUM
|
11
|
+
ALBUM = 'album'.freeze,
|
12
|
+
|
13
|
+
# TODO: Write general description for SINGLE
|
14
|
+
SINGLE = 'single'.freeze,
|
15
|
+
|
16
|
+
# TODO: Write general description for COMPILATION
|
17
|
+
COMPILATION = 'compilation'.freeze,
|
18
|
+
|
19
|
+
# TODO: Write general description for APPEARS_ON
|
20
|
+
APPEARS_ON = 'appears_on'.freeze
|
21
|
+
].freeze
|
22
|
+
|
23
|
+
def self.validate(value)
|
24
|
+
return false if value.nil?
|
25
|
+
|
26
|
+
ALBUM_GROUP_ENUM.include?(value)
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
@@ -0,0 +1,247 @@
|
|
1
|
+
# spotify_web_api
|
2
|
+
#
|
3
|
+
# This file was automatically generated by APIMATIC v2.0
|
4
|
+
# ( https://apimatic.io ).
|
5
|
+
|
6
|
+
module SpotifyWebApi
|
7
|
+
# AlbumObject Model.
|
8
|
+
class AlbumObject < BaseModel
|
9
|
+
SKIP = Object.new
|
10
|
+
private_constant :SKIP
|
11
|
+
|
12
|
+
# The type of the album.
|
13
|
+
# @return [AlbumTypeEnum]
|
14
|
+
attr_accessor :album_type
|
15
|
+
|
16
|
+
# The number of tracks in the album.
|
17
|
+
# @return [Integer]
|
18
|
+
attr_accessor :total_tracks
|
19
|
+
|
20
|
+
# The markets in which the album is available: [ISO 3166-1 alpha-2 country
|
21
|
+
# codes](http://en.wikipedia.org/wiki/ISO_3166-1_alpha-2). _**NOTE**: an
|
22
|
+
# album is considered available in a market when at least 1 of its tracks is
|
23
|
+
# available in that market._
|
24
|
+
# @return [Array[String]]
|
25
|
+
attr_accessor :available_markets
|
26
|
+
|
27
|
+
# Known external URLs for this album.
|
28
|
+
# @return [ExternalUrlObject]
|
29
|
+
attr_accessor :external_urls
|
30
|
+
|
31
|
+
# A link to the Web API endpoint providing full details of the album.
|
32
|
+
# @return [String]
|
33
|
+
attr_accessor :href
|
34
|
+
|
35
|
+
# The [Spotify ID](/documentation/web-api/concepts/spotify-uris-ids) for the
|
36
|
+
# album.
|
37
|
+
# @return [String]
|
38
|
+
attr_accessor :id
|
39
|
+
|
40
|
+
# The cover art for the album in various sizes, widest first.
|
41
|
+
# @return [Array[ImageObject]]
|
42
|
+
attr_accessor :images
|
43
|
+
|
44
|
+
# The name of the album. In case of an album takedown, the value may be an
|
45
|
+
# empty string.
|
46
|
+
# @return [String]
|
47
|
+
attr_accessor :name
|
48
|
+
|
49
|
+
# The date the album was first released.
|
50
|
+
# @return [String]
|
51
|
+
attr_accessor :release_date
|
52
|
+
|
53
|
+
# The precision with which `release_date` value is known.
|
54
|
+
# @return [ReleaseDatePrecisionEnum]
|
55
|
+
attr_accessor :release_date_precision
|
56
|
+
|
57
|
+
# Included in the response when a content restriction is applied.
|
58
|
+
# @return [AlbumRestrictionObject]
|
59
|
+
attr_accessor :restrictions
|
60
|
+
|
61
|
+
# The object type.
|
62
|
+
# @return [Type2Enum]
|
63
|
+
attr_accessor :type
|
64
|
+
|
65
|
+
# The [Spotify URI](/documentation/web-api/concepts/spotify-uris-ids) for
|
66
|
+
# the album.
|
67
|
+
# @return [String]
|
68
|
+
attr_accessor :uri
|
69
|
+
|
70
|
+
# The artists of the album. Each artist object includes a link in `href` to
|
71
|
+
# more detailed information about the artist.
|
72
|
+
# @return [Array[SimplifiedArtistObject]]
|
73
|
+
attr_accessor :artists
|
74
|
+
|
75
|
+
# The tracks of the album.
|
76
|
+
# @return [PagingSimplifiedTrackObject]
|
77
|
+
attr_accessor :tracks
|
78
|
+
|
79
|
+
# The copyright statements of the album.
|
80
|
+
# @return [Array[CopyrightObject]]
|
81
|
+
attr_accessor :copyrights
|
82
|
+
|
83
|
+
# Known external IDs for the album.
|
84
|
+
# @return [ExternalIdObject]
|
85
|
+
attr_accessor :external_ids
|
86
|
+
|
87
|
+
# A list of the genres the album is associated with. If not yet classified,
|
88
|
+
# the array is empty.
|
89
|
+
# @return [Array[String]]
|
90
|
+
attr_accessor :genres
|
91
|
+
|
92
|
+
# The label associated with the album.
|
93
|
+
# @return [String]
|
94
|
+
attr_accessor :label
|
95
|
+
|
96
|
+
# The popularity of the album. The value will be between 0 and 100, with 100
|
97
|
+
# being the most popular.
|
98
|
+
# @return [Integer]
|
99
|
+
attr_accessor :popularity
|
100
|
+
|
101
|
+
# A mapping from model property names to API property names.
|
102
|
+
def self.names
|
103
|
+
@_hash = {} if @_hash.nil?
|
104
|
+
@_hash['album_type'] = 'album_type'
|
105
|
+
@_hash['total_tracks'] = 'total_tracks'
|
106
|
+
@_hash['available_markets'] = 'available_markets'
|
107
|
+
@_hash['external_urls'] = 'external_urls'
|
108
|
+
@_hash['href'] = 'href'
|
109
|
+
@_hash['id'] = 'id'
|
110
|
+
@_hash['images'] = 'images'
|
111
|
+
@_hash['name'] = 'name'
|
112
|
+
@_hash['release_date'] = 'release_date'
|
113
|
+
@_hash['release_date_precision'] = 'release_date_precision'
|
114
|
+
@_hash['restrictions'] = 'restrictions'
|
115
|
+
@_hash['type'] = 'type'
|
116
|
+
@_hash['uri'] = 'uri'
|
117
|
+
@_hash['artists'] = 'artists'
|
118
|
+
@_hash['tracks'] = 'tracks'
|
119
|
+
@_hash['copyrights'] = 'copyrights'
|
120
|
+
@_hash['external_ids'] = 'external_ids'
|
121
|
+
@_hash['genres'] = 'genres'
|
122
|
+
@_hash['label'] = 'label'
|
123
|
+
@_hash['popularity'] = 'popularity'
|
124
|
+
@_hash
|
125
|
+
end
|
126
|
+
|
127
|
+
# An array for optional fields
|
128
|
+
def self.optionals
|
129
|
+
%w[
|
130
|
+
restrictions
|
131
|
+
]
|
132
|
+
end
|
133
|
+
|
134
|
+
# An array for nullable fields
|
135
|
+
def self.nullables
|
136
|
+
[]
|
137
|
+
end
|
138
|
+
|
139
|
+
def initialize(album_type = nil, total_tracks = nil,
|
140
|
+
available_markets = nil, external_urls = nil, href = nil,
|
141
|
+
id = nil, images = nil, name = nil, release_date = nil,
|
142
|
+
release_date_precision = nil, type = nil, uri = nil,
|
143
|
+
artists = nil, tracks = nil, copyrights = nil,
|
144
|
+
external_ids = nil, genres = nil, label = nil,
|
145
|
+
popularity = nil, restrictions = SKIP)
|
146
|
+
@album_type = album_type
|
147
|
+
@total_tracks = total_tracks
|
148
|
+
@available_markets = available_markets
|
149
|
+
@external_urls = external_urls
|
150
|
+
@href = href
|
151
|
+
@id = id
|
152
|
+
@images = images
|
153
|
+
@name = name
|
154
|
+
@release_date = release_date
|
155
|
+
@release_date_precision = release_date_precision
|
156
|
+
@restrictions = restrictions unless restrictions == SKIP
|
157
|
+
@type = type
|
158
|
+
@uri = uri
|
159
|
+
@artists = artists
|
160
|
+
@tracks = tracks
|
161
|
+
@copyrights = copyrights
|
162
|
+
@external_ids = external_ids
|
163
|
+
@genres = genres
|
164
|
+
@label = label
|
165
|
+
@popularity = popularity
|
166
|
+
end
|
167
|
+
|
168
|
+
# Creates an instance of the object from a hash.
|
169
|
+
def self.from_hash(hash)
|
170
|
+
return nil unless hash
|
171
|
+
|
172
|
+
# Extract variables from the hash.
|
173
|
+
album_type = hash.key?('album_type') ? hash['album_type'] : nil
|
174
|
+
total_tracks = hash.key?('total_tracks') ? hash['total_tracks'] : nil
|
175
|
+
available_markets =
|
176
|
+
hash.key?('available_markets') ? hash['available_markets'] : nil
|
177
|
+
external_urls = ExternalUrlObject.from_hash(hash['external_urls']) if hash['external_urls']
|
178
|
+
href = hash.key?('href') ? hash['href'] : nil
|
179
|
+
id = hash.key?('id') ? hash['id'] : nil
|
180
|
+
# Parameter is an array, so we need to iterate through it
|
181
|
+
images = nil
|
182
|
+
unless hash['images'].nil?
|
183
|
+
images = []
|
184
|
+
hash['images'].each do |structure|
|
185
|
+
images << (ImageObject.from_hash(structure) if structure)
|
186
|
+
end
|
187
|
+
end
|
188
|
+
|
189
|
+
images = nil unless hash.key?('images')
|
190
|
+
name = hash.key?('name') ? hash['name'] : nil
|
191
|
+
release_date = hash.key?('release_date') ? hash['release_date'] : nil
|
192
|
+
release_date_precision =
|
193
|
+
hash.key?('release_date_precision') ? hash['release_date_precision'] : nil
|
194
|
+
type = hash.key?('type') ? hash['type'] : nil
|
195
|
+
uri = hash.key?('uri') ? hash['uri'] : nil
|
196
|
+
# Parameter is an array, so we need to iterate through it
|
197
|
+
artists = nil
|
198
|
+
unless hash['artists'].nil?
|
199
|
+
artists = []
|
200
|
+
hash['artists'].each do |structure|
|
201
|
+
artists << (SimplifiedArtistObject.from_hash(structure) if structure)
|
202
|
+
end
|
203
|
+
end
|
204
|
+
|
205
|
+
artists = nil unless hash.key?('artists')
|
206
|
+
tracks = PagingSimplifiedTrackObject.from_hash(hash['tracks']) if hash['tracks']
|
207
|
+
# Parameter is an array, so we need to iterate through it
|
208
|
+
copyrights = nil
|
209
|
+
unless hash['copyrights'].nil?
|
210
|
+
copyrights = []
|
211
|
+
hash['copyrights'].each do |structure|
|
212
|
+
copyrights << (CopyrightObject.from_hash(structure) if structure)
|
213
|
+
end
|
214
|
+
end
|
215
|
+
|
216
|
+
copyrights = nil unless hash.key?('copyrights')
|
217
|
+
external_ids = ExternalIdObject.from_hash(hash['external_ids']) if hash['external_ids']
|
218
|
+
genres = hash.key?('genres') ? hash['genres'] : nil
|
219
|
+
label = hash.key?('label') ? hash['label'] : nil
|
220
|
+
popularity = hash.key?('popularity') ? hash['popularity'] : nil
|
221
|
+
restrictions = AlbumRestrictionObject.from_hash(hash['restrictions']) if
|
222
|
+
hash['restrictions']
|
223
|
+
|
224
|
+
# Create object from extracted values.
|
225
|
+
AlbumObject.new(album_type,
|
226
|
+
total_tracks,
|
227
|
+
available_markets,
|
228
|
+
external_urls,
|
229
|
+
href,
|
230
|
+
id,
|
231
|
+
images,
|
232
|
+
name,
|
233
|
+
release_date,
|
234
|
+
release_date_precision,
|
235
|
+
type,
|
236
|
+
uri,
|
237
|
+
artists,
|
238
|
+
tracks,
|
239
|
+
copyrights,
|
240
|
+
external_ids,
|
241
|
+
genres,
|
242
|
+
label,
|
243
|
+
popularity,
|
244
|
+
restrictions)
|
245
|
+
end
|
246
|
+
end
|
247
|
+
end
|
@@ -0,0 +1,53 @@
|
|
1
|
+
# spotify_web_api
|
2
|
+
#
|
3
|
+
# This file was automatically generated by APIMATIC v2.0
|
4
|
+
# ( https://apimatic.io ).
|
5
|
+
|
6
|
+
module SpotifyWebApi
|
7
|
+
# AlbumRestrictionObject Model.
|
8
|
+
class AlbumRestrictionObject < BaseModel
|
9
|
+
SKIP = Object.new
|
10
|
+
private_constant :SKIP
|
11
|
+
|
12
|
+
# The reason for the restriction. Albums may be restricted if the content is
|
13
|
+
# not available in a given market, to the user's subscription type, or when
|
14
|
+
# the user's account is set to not play explicit content.
|
15
|
+
# Additional reasons may be added in the future.
|
16
|
+
# @return [ReasonEnum]
|
17
|
+
attr_accessor :reason
|
18
|
+
|
19
|
+
# A mapping from model property names to API property names.
|
20
|
+
def self.names
|
21
|
+
@_hash = {} if @_hash.nil?
|
22
|
+
@_hash['reason'] = 'reason'
|
23
|
+
@_hash
|
24
|
+
end
|
25
|
+
|
26
|
+
# An array for optional fields
|
27
|
+
def self.optionals
|
28
|
+
%w[
|
29
|
+
reason
|
30
|
+
]
|
31
|
+
end
|
32
|
+
|
33
|
+
# An array for nullable fields
|
34
|
+
def self.nullables
|
35
|
+
[]
|
36
|
+
end
|
37
|
+
|
38
|
+
def initialize(reason = SKIP)
|
39
|
+
@reason = reason unless reason == SKIP
|
40
|
+
end
|
41
|
+
|
42
|
+
# Creates an instance of the object from a hash.
|
43
|
+
def self.from_hash(hash)
|
44
|
+
return nil unless hash
|
45
|
+
|
46
|
+
# Extract variables from the hash.
|
47
|
+
reason = hash.key?('reason') ? hash['reason'] : SKIP
|
48
|
+
|
49
|
+
# Create object from extracted values.
|
50
|
+
AlbumRestrictionObject.new(reason)
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|