spotify-api-sdk 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (178) hide show
  1. checksums.yaml +7 -0
  2. data/LICENSE +30 -0
  3. data/README.md +107 -0
  4. data/lib/spotify_web_api/api_helper.rb +10 -0
  5. data/lib/spotify_web_api/client.rb +154 -0
  6. data/lib/spotify_web_api/configuration.rb +180 -0
  7. data/lib/spotify_web_api/controllers/albums_controller.rb +295 -0
  8. data/lib/spotify_web_api/controllers/artists_controller.rb +187 -0
  9. data/lib/spotify_web_api/controllers/audiobooks_controller.rb +258 -0
  10. data/lib/spotify_web_api/controllers/base_controller.rb +66 -0
  11. data/lib/spotify_web_api/controllers/categories_controller.rb +83 -0
  12. data/lib/spotify_web_api/controllers/chapters_controller.rb +82 -0
  13. data/lib/spotify_web_api/controllers/episodes_controller.rb +239 -0
  14. data/lib/spotify_web_api/controllers/genres_controller.rb +39 -0
  15. data/lib/spotify_web_api/controllers/markets_controller.rb +38 -0
  16. data/lib/spotify_web_api/controllers/o_auth_authorization_controller.rb +82 -0
  17. data/lib/spotify_web_api/controllers/player_controller.rb +509 -0
  18. data/lib/spotify_web_api/controllers/playlists_controller.rb +521 -0
  19. data/lib/spotify_web_api/controllers/search_controller.rb +60 -0
  20. data/lib/spotify_web_api/controllers/shows_controller.rb +261 -0
  21. data/lib/spotify_web_api/controllers/tracks_controller.rb +491 -0
  22. data/lib/spotify_web_api/controllers/users_controller.rb +396 -0
  23. data/lib/spotify_web_api/exceptions/api_exception.rb +10 -0
  24. data/lib/spotify_web_api/exceptions/bad_request_exception.rb +32 -0
  25. data/lib/spotify_web_api/exceptions/forbidden_exception.rb +32 -0
  26. data/lib/spotify_web_api/exceptions/not_found_exception.rb +32 -0
  27. data/lib/spotify_web_api/exceptions/o_auth_provider_exception.rb +48 -0
  28. data/lib/spotify_web_api/exceptions/too_many_requests_exception.rb +32 -0
  29. data/lib/spotify_web_api/exceptions/unauthorized_exception.rb +32 -0
  30. data/lib/spotify_web_api/http/api_response.rb +21 -0
  31. data/lib/spotify_web_api/http/auth/o_auth2.rb +146 -0
  32. data/lib/spotify_web_api/http/http_call_back.rb +10 -0
  33. data/lib/spotify_web_api/http/http_method_enum.rb +10 -0
  34. data/lib/spotify_web_api/http/http_request.rb +10 -0
  35. data/lib/spotify_web_api/http/http_response.rb +10 -0
  36. data/lib/spotify_web_api/models/album_base.rb +168 -0
  37. data/lib/spotify_web_api/models/album_group_enum.rb +29 -0
  38. data/lib/spotify_web_api/models/album_object.rb +247 -0
  39. data/lib/spotify_web_api/models/album_restriction_object.rb +53 -0
  40. data/lib/spotify_web_api/models/album_type_enum.rb +26 -0
  41. data/lib/spotify_web_api/models/artist_discography_album_object.rb +194 -0
  42. data/lib/spotify_web_api/models/artist_object.rb +147 -0
  43. data/lib/spotify_web_api/models/audio_analysis_object.rb +156 -0
  44. data/lib/spotify_web_api/models/audio_features_object.rb +249 -0
  45. data/lib/spotify_web_api/models/audiobook_base.rb +245 -0
  46. data/lib/spotify_web_api/models/audiobook_object.rb +253 -0
  47. data/lib/spotify_web_api/models/author_object.rb +50 -0
  48. data/lib/spotify_web_api/models/base_model.rb +62 -0
  49. data/lib/spotify_web_api/models/categories.rb +110 -0
  50. data/lib/spotify_web_api/models/category_object.rb +82 -0
  51. data/lib/spotify_web_api/models/chapter_base.rb +237 -0
  52. data/lib/spotify_web_api/models/chapter_object.rb +245 -0
  53. data/lib/spotify_web_api/models/chapter_restriction_object.rb +59 -0
  54. data/lib/spotify_web_api/models/context_object.rb +78 -0
  55. data/lib/spotify_web_api/models/copyright_object.rb +60 -0
  56. data/lib/spotify_web_api/models/currently_playing_context_object.rb +137 -0
  57. data/lib/spotify_web_api/models/currently_playing_object.rb +109 -0
  58. data/lib/spotify_web_api/models/cursor_object.rb +59 -0
  59. data/lib/spotify_web_api/models/cursor_paged_artists.rb +48 -0
  60. data/lib/spotify_web_api/models/cursor_paging_object.rb +88 -0
  61. data/lib/spotify_web_api/models/cursor_paging_play_history_object.rb +106 -0
  62. data/lib/spotify_web_api/models/cursor_paging_simplified_artist_object.rb +106 -0
  63. data/lib/spotify_web_api/models/device_object.rb +126 -0
  64. data/lib/spotify_web_api/models/disallows_object.rb +140 -0
  65. data/lib/spotify_web_api/models/episode_base.rb +237 -0
  66. data/lib/spotify_web_api/models/episode_object.rb +246 -0
  67. data/lib/spotify_web_api/models/episode_restriction_object.rb +58 -0
  68. data/lib/spotify_web_api/models/error_object.rb +59 -0
  69. data/lib/spotify_web_api/models/explicit_content_settings_object.rb +61 -0
  70. data/lib/spotify_web_api/models/external_id_object.rb +72 -0
  71. data/lib/spotify_web_api/models/external_url_object.rb +51 -0
  72. data/lib/spotify_web_api/models/followers_object.rb +62 -0
  73. data/lib/spotify_web_api/models/image_object.rb +67 -0
  74. data/lib/spotify_web_api/models/include_external_enum.rb +23 -0
  75. data/lib/spotify_web_api/models/item_type1_enum.rb +20 -0
  76. data/lib/spotify_web_api/models/item_type2_enum.rb +23 -0
  77. data/lib/spotify_web_api/models/item_type3_enum.rb +23 -0
  78. data/lib/spotify_web_api/models/item_type_enum.rb +38 -0
  79. data/lib/spotify_web_api/models/linked_track_object.rb +89 -0
  80. data/lib/spotify_web_api/models/many_albums.rb +57 -0
  81. data/lib/spotify_web_api/models/many_artists.rb +57 -0
  82. data/lib/spotify_web_api/models/many_audio_features.rb +57 -0
  83. data/lib/spotify_web_api/models/many_audiobooks.rb +57 -0
  84. data/lib/spotify_web_api/models/many_chapters.rb +57 -0
  85. data/lib/spotify_web_api/models/many_devices.rb +57 -0
  86. data/lib/spotify_web_api/models/many_episodes.rb +57 -0
  87. data/lib/spotify_web_api/models/many_genres.rb +48 -0
  88. data/lib/spotify_web_api/models/many_simplified_shows.rb +57 -0
  89. data/lib/spotify_web_api/models/many_tracks.rb +57 -0
  90. data/lib/spotify_web_api/models/markets.rb +50 -0
  91. data/lib/spotify_web_api/models/me_albums_request.rb +55 -0
  92. data/lib/spotify_web_api/models/me_episodes_request.rb +52 -0
  93. data/lib/spotify_web_api/models/me_episodes_request1.rb +54 -0
  94. data/lib/spotify_web_api/models/me_following_request.rb +53 -0
  95. data/lib/spotify_web_api/models/me_following_request1.rb +55 -0
  96. data/lib/spotify_web_api/models/me_player_play_request.rb +89 -0
  97. data/lib/spotify_web_api/models/me_player_request.rb +63 -0
  98. data/lib/spotify_web_api/models/me_shows_request.rb +55 -0
  99. data/lib/spotify_web_api/models/me_tracks_request.rb +53 -0
  100. data/lib/spotify_web_api/models/me_tracks_request1.rb +55 -0
  101. data/lib/spotify_web_api/models/meta.rb +110 -0
  102. data/lib/spotify_web_api/models/mode_enum.rb +30 -0
  103. data/lib/spotify_web_api/models/narrator_object.rb +50 -0
  104. data/lib/spotify_web_api/models/o_auth_provider_error_enum.rb +45 -0
  105. data/lib/spotify_web_api/models/o_auth_scope_enum.rb +94 -0
  106. data/lib/spotify_web_api/models/o_auth_token.rb +96 -0
  107. data/lib/spotify_web_api/models/paged_albums.rb +48 -0
  108. data/lib/spotify_web_api/models/paged_categories.rb +48 -0
  109. data/lib/spotify_web_api/models/paging_artist_discography_album_object.rb +110 -0
  110. data/lib/spotify_web_api/models/paging_artist_object.rb +110 -0
  111. data/lib/spotify_web_api/models/paging_featured_playlist_object.rb +59 -0
  112. data/lib/spotify_web_api/models/paging_object.rb +93 -0
  113. data/lib/spotify_web_api/models/paging_playlist_object.rb +110 -0
  114. data/lib/spotify_web_api/models/paging_playlist_track_object.rb +110 -0
  115. data/lib/spotify_web_api/models/paging_saved_album_object.rb +110 -0
  116. data/lib/spotify_web_api/models/paging_saved_audiobook_object.rb +110 -0
  117. data/lib/spotify_web_api/models/paging_saved_episode_object.rb +110 -0
  118. data/lib/spotify_web_api/models/paging_saved_show_object.rb +110 -0
  119. data/lib/spotify_web_api/models/paging_saved_track_object.rb +110 -0
  120. data/lib/spotify_web_api/models/paging_simplified_album_object.rb +110 -0
  121. data/lib/spotify_web_api/models/paging_simplified_audiobook_object.rb +110 -0
  122. data/lib/spotify_web_api/models/paging_simplified_chapter_object.rb +110 -0
  123. data/lib/spotify_web_api/models/paging_simplified_episode_object.rb +110 -0
  124. data/lib/spotify_web_api/models/paging_simplified_show_object.rb +110 -0
  125. data/lib/spotify_web_api/models/paging_simplified_track_object.rb +110 -0
  126. data/lib/spotify_web_api/models/paging_track_object.rb +110 -0
  127. data/lib/spotify_web_api/models/play_history_object.rb +77 -0
  128. data/lib/spotify_web_api/models/playlist_object.rb +193 -0
  129. data/lib/spotify_web_api/models/playlist_owner_object.rb +109 -0
  130. data/lib/spotify_web_api/models/playlist_snapshot_id.rb +50 -0
  131. data/lib/spotify_web_api/models/playlist_track_object.rb +90 -0
  132. data/lib/spotify_web_api/models/playlist_tracks_ref_object.rb +60 -0
  133. data/lib/spotify_web_api/models/playlist_user_object.rb +98 -0
  134. data/lib/spotify_web_api/models/playlists_followers_request.rb +51 -0
  135. data/lib/spotify_web_api/models/playlists_request.rb +82 -0
  136. data/lib/spotify_web_api/models/playlists_tracks_request.rb +72 -0
  137. data/lib/spotify_web_api/models/playlists_tracks_request1.rb +97 -0
  138. data/lib/spotify_web_api/models/playlists_tracks_request2.rb +75 -0
  139. data/lib/spotify_web_api/models/private_user_object.rb +181 -0
  140. data/lib/spotify_web_api/models/public_user_object.rb +128 -0
  141. data/lib/spotify_web_api/models/queue_object.rb +60 -0
  142. data/lib/spotify_web_api/models/reason_enum.rb +29 -0
  143. data/lib/spotify_web_api/models/recommendation_seed_object.rb +104 -0
  144. data/lib/spotify_web_api/models/recommendations_object.rb +74 -0
  145. data/lib/spotify_web_api/models/release_date_precision_enum.rb +26 -0
  146. data/lib/spotify_web_api/models/resume_point_object.rb +60 -0
  147. data/lib/spotify_web_api/models/saved_album_object.rb +73 -0
  148. data/lib/spotify_web_api/models/saved_audiobook_object.rb +73 -0
  149. data/lib/spotify_web_api/models/saved_episode_object.rb +70 -0
  150. data/lib/spotify_web_api/models/saved_show_object.rb +73 -0
  151. data/lib/spotify_web_api/models/saved_track_object.rb +73 -0
  152. data/lib/spotify_web_api/models/search_items.rb +107 -0
  153. data/lib/spotify_web_api/models/section_object.rb +180 -0
  154. data/lib/spotify_web_api/models/segment_object.rb +166 -0
  155. data/lib/spotify_web_api/models/show_base.rb +211 -0
  156. data/lib/spotify_web_api/models/show_object.rb +219 -0
  157. data/lib/spotify_web_api/models/simplified_album_object.rb +186 -0
  158. data/lib/spotify_web_api/models/simplified_artist_object.rb +98 -0
  159. data/lib/spotify_web_api/models/simplified_playlist_object.rb +184 -0
  160. data/lib/spotify_web_api/models/simplified_track_object.rb +227 -0
  161. data/lib/spotify_web_api/models/time_interval_object.rb +68 -0
  162. data/lib/spotify_web_api/models/track.rb +331 -0
  163. data/lib/spotify_web_api/models/track1.rb +50 -0
  164. data/lib/spotify_web_api/models/track_object.rb +265 -0
  165. data/lib/spotify_web_api/models/track_restriction_object.rb +58 -0
  166. data/lib/spotify_web_api/models/type2_enum.rb +20 -0
  167. data/lib/spotify_web_api/models/type3_enum.rb +20 -0
  168. data/lib/spotify_web_api/models/type4_enum.rb +20 -0
  169. data/lib/spotify_web_api/models/type6_enum.rb +20 -0
  170. data/lib/spotify_web_api/models/type7_enum.rb +20 -0
  171. data/lib/spotify_web_api/models/type8_enum.rb +20 -0
  172. data/lib/spotify_web_api/models/type9_enum.rb +20 -0
  173. data/lib/spotify_web_api/models/type_enum.rb +20 -0
  174. data/lib/spotify_web_api/models/users_playlists_request.rb +87 -0
  175. data/lib/spotify_web_api/utilities/date_time_helper.rb +11 -0
  176. data/lib/spotify_web_api/utilities/file_wrapper.rb +16 -0
  177. data/lib/spotify_web_api.rb +198 -0
  178. metadata +264 -0
@@ -0,0 +1,26 @@
1
+ # spotify_web_api
2
+ #
3
+ # This file was automatically generated by APIMATIC v2.0
4
+ # ( https://apimatic.io ).
5
+
6
+ module SpotifyWebApi
7
+ # The type of the album.
8
+ class AlbumTypeEnum
9
+ ALBUM_TYPE_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
+ ].freeze
19
+
20
+ def self.validate(value)
21
+ return false if value.nil?
22
+
23
+ ALBUM_TYPE_ENUM.include?(value)
24
+ end
25
+ end
26
+ end
@@ -0,0 +1,194 @@
1
+ # spotify_web_api
2
+ #
3
+ # This file was automatically generated by APIMATIC v2.0
4
+ # ( https://apimatic.io ).
5
+
6
+ module SpotifyWebApi
7
+ # ArtistDiscographyAlbumObject Model.
8
+ class ArtistDiscographyAlbumObject < 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
+ # This field describes the relationship between the artist and the album.
76
+ # @return [AlbumGroupEnum]
77
+ attr_accessor :album_group
78
+
79
+ # A mapping from model property names to API property names.
80
+ def self.names
81
+ @_hash = {} if @_hash.nil?
82
+ @_hash['album_type'] = 'album_type'
83
+ @_hash['total_tracks'] = 'total_tracks'
84
+ @_hash['available_markets'] = 'available_markets'
85
+ @_hash['external_urls'] = 'external_urls'
86
+ @_hash['href'] = 'href'
87
+ @_hash['id'] = 'id'
88
+ @_hash['images'] = 'images'
89
+ @_hash['name'] = 'name'
90
+ @_hash['release_date'] = 'release_date'
91
+ @_hash['release_date_precision'] = 'release_date_precision'
92
+ @_hash['restrictions'] = 'restrictions'
93
+ @_hash['type'] = 'type'
94
+ @_hash['uri'] = 'uri'
95
+ @_hash['artists'] = 'artists'
96
+ @_hash['album_group'] = 'album_group'
97
+ @_hash
98
+ end
99
+
100
+ # An array for optional fields
101
+ def self.optionals
102
+ %w[
103
+ restrictions
104
+ ]
105
+ end
106
+
107
+ # An array for nullable fields
108
+ def self.nullables
109
+ []
110
+ end
111
+
112
+ def initialize(album_type = nil, total_tracks = nil,
113
+ available_markets = nil, external_urls = nil, href = nil,
114
+ id = nil, images = nil, name = nil, release_date = nil,
115
+ release_date_precision = nil, type = nil, uri = nil,
116
+ artists = nil, album_group = nil, restrictions = SKIP)
117
+ @album_type = album_type
118
+ @total_tracks = total_tracks
119
+ @available_markets = available_markets
120
+ @external_urls = external_urls
121
+ @href = href
122
+ @id = id
123
+ @images = images
124
+ @name = name
125
+ @release_date = release_date
126
+ @release_date_precision = release_date_precision
127
+ @restrictions = restrictions unless restrictions == SKIP
128
+ @type = type
129
+ @uri = uri
130
+ @artists = artists
131
+ @album_group = album_group
132
+ end
133
+
134
+ # Creates an instance of the object from a hash.
135
+ def self.from_hash(hash)
136
+ return nil unless hash
137
+
138
+ # Extract variables from the hash.
139
+ album_type = hash.key?('album_type') ? hash['album_type'] : nil
140
+ total_tracks = hash.key?('total_tracks') ? hash['total_tracks'] : nil
141
+ available_markets =
142
+ hash.key?('available_markets') ? hash['available_markets'] : nil
143
+ external_urls = ExternalUrlObject.from_hash(hash['external_urls']) if hash['external_urls']
144
+ href = hash.key?('href') ? hash['href'] : nil
145
+ id = hash.key?('id') ? hash['id'] : nil
146
+ # Parameter is an array, so we need to iterate through it
147
+ images = nil
148
+ unless hash['images'].nil?
149
+ images = []
150
+ hash['images'].each do |structure|
151
+ images << (ImageObject.from_hash(structure) if structure)
152
+ end
153
+ end
154
+
155
+ images = nil unless hash.key?('images')
156
+ name = hash.key?('name') ? hash['name'] : nil
157
+ release_date = hash.key?('release_date') ? hash['release_date'] : nil
158
+ release_date_precision =
159
+ hash.key?('release_date_precision') ? hash['release_date_precision'] : nil
160
+ type = hash.key?('type') ? hash['type'] : nil
161
+ uri = hash.key?('uri') ? hash['uri'] : nil
162
+ # Parameter is an array, so we need to iterate through it
163
+ artists = nil
164
+ unless hash['artists'].nil?
165
+ artists = []
166
+ hash['artists'].each do |structure|
167
+ artists << (SimplifiedArtistObject.from_hash(structure) if structure)
168
+ end
169
+ end
170
+
171
+ artists = nil unless hash.key?('artists')
172
+ album_group = hash.key?('album_group') ? hash['album_group'] : nil
173
+ restrictions = AlbumRestrictionObject.from_hash(hash['restrictions']) if
174
+ hash['restrictions']
175
+
176
+ # Create object from extracted values.
177
+ ArtistDiscographyAlbumObject.new(album_type,
178
+ total_tracks,
179
+ available_markets,
180
+ external_urls,
181
+ href,
182
+ id,
183
+ images,
184
+ name,
185
+ release_date,
186
+ release_date_precision,
187
+ type,
188
+ uri,
189
+ artists,
190
+ album_group,
191
+ restrictions)
192
+ end
193
+ end
194
+ end
@@ -0,0 +1,147 @@
1
+ # spotify_web_api
2
+ #
3
+ # This file was automatically generated by APIMATIC v2.0
4
+ # ( https://apimatic.io ).
5
+
6
+ module SpotifyWebApi
7
+ # ArtistObject Model.
8
+ class ArtistObject < BaseModel
9
+ SKIP = Object.new
10
+ private_constant :SKIP
11
+
12
+ # Known external URLs for this artist.
13
+ # @return [ExternalUrlObject]
14
+ attr_accessor :external_urls
15
+
16
+ # Information about the followers of the artist.
17
+ # @return [FollowersObject]
18
+ attr_accessor :followers
19
+
20
+ # A list of the genres the artist is associated with. If not yet classified,
21
+ # the array is empty.
22
+ # @return [Array[String]]
23
+ attr_accessor :genres
24
+
25
+ # A link to the Web API endpoint providing full details of the artist.
26
+ # @return [String]
27
+ attr_accessor :href
28
+
29
+ # The [Spotify ID](/documentation/web-api/concepts/spotify-uris-ids) for the
30
+ # artist.
31
+ # @return [String]
32
+ attr_accessor :id
33
+
34
+ # Images of the artist in various sizes, widest first.
35
+ # @return [Array[ImageObject]]
36
+ attr_accessor :images
37
+
38
+ # The name of the artist.
39
+ # @return [String]
40
+ attr_accessor :name
41
+
42
+ # The popularity of the artist. The value will be between 0 and 100, with
43
+ # 100 being the most popular. The artist's popularity is calculated from the
44
+ # popularity of all the artist's tracks.
45
+ # @return [Integer]
46
+ attr_accessor :popularity
47
+
48
+ # The object type.
49
+ # @return [TypeEnum]
50
+ attr_accessor :type
51
+
52
+ # The [Spotify URI](/documentation/web-api/concepts/spotify-uris-ids) for
53
+ # the artist.
54
+ # @return [String]
55
+ attr_accessor :uri
56
+
57
+ # A mapping from model property names to API property names.
58
+ def self.names
59
+ @_hash = {} if @_hash.nil?
60
+ @_hash['external_urls'] = 'external_urls'
61
+ @_hash['followers'] = 'followers'
62
+ @_hash['genres'] = 'genres'
63
+ @_hash['href'] = 'href'
64
+ @_hash['id'] = 'id'
65
+ @_hash['images'] = 'images'
66
+ @_hash['name'] = 'name'
67
+ @_hash['popularity'] = 'popularity'
68
+ @_hash['type'] = 'type'
69
+ @_hash['uri'] = 'uri'
70
+ @_hash
71
+ end
72
+
73
+ # An array for optional fields
74
+ def self.optionals
75
+ %w[
76
+ external_urls
77
+ followers
78
+ genres
79
+ href
80
+ id
81
+ images
82
+ name
83
+ popularity
84
+ type
85
+ uri
86
+ ]
87
+ end
88
+
89
+ # An array for nullable fields
90
+ def self.nullables
91
+ []
92
+ end
93
+
94
+ def initialize(external_urls = SKIP, followers = SKIP, genres = SKIP,
95
+ href = SKIP, id = SKIP, images = SKIP, name = SKIP,
96
+ popularity = SKIP, type = SKIP, uri = SKIP)
97
+ @external_urls = external_urls unless external_urls == SKIP
98
+ @followers = followers unless followers == SKIP
99
+ @genres = genres unless genres == SKIP
100
+ @href = href unless href == SKIP
101
+ @id = id unless id == SKIP
102
+ @images = images unless images == SKIP
103
+ @name = name unless name == SKIP
104
+ @popularity = popularity unless popularity == SKIP
105
+ @type = type unless type == SKIP
106
+ @uri = uri unless uri == SKIP
107
+ end
108
+
109
+ # Creates an instance of the object from a hash.
110
+ def self.from_hash(hash)
111
+ return nil unless hash
112
+
113
+ # Extract variables from the hash.
114
+ external_urls = ExternalUrlObject.from_hash(hash['external_urls']) if hash['external_urls']
115
+ followers = FollowersObject.from_hash(hash['followers']) if hash['followers']
116
+ genres = hash.key?('genres') ? hash['genres'] : SKIP
117
+ href = hash.key?('href') ? hash['href'] : SKIP
118
+ id = hash.key?('id') ? hash['id'] : SKIP
119
+ # Parameter is an array, so we need to iterate through it
120
+ images = nil
121
+ unless hash['images'].nil?
122
+ images = []
123
+ hash['images'].each do |structure|
124
+ images << (ImageObject.from_hash(structure) if structure)
125
+ end
126
+ end
127
+
128
+ images = SKIP unless hash.key?('images')
129
+ name = hash.key?('name') ? hash['name'] : SKIP
130
+ popularity = hash.key?('popularity') ? hash['popularity'] : SKIP
131
+ type = hash.key?('type') ? hash['type'] : SKIP
132
+ uri = hash.key?('uri') ? hash['uri'] : SKIP
133
+
134
+ # Create object from extracted values.
135
+ ArtistObject.new(external_urls,
136
+ followers,
137
+ genres,
138
+ href,
139
+ id,
140
+ images,
141
+ name,
142
+ popularity,
143
+ type,
144
+ uri)
145
+ end
146
+ end
147
+ end
@@ -0,0 +1,156 @@
1
+ # spotify_web_api
2
+ #
3
+ # This file was automatically generated by APIMATIC v2.0
4
+ # ( https://apimatic.io ).
5
+
6
+ module SpotifyWebApi
7
+ # AudioAnalysisObject Model.
8
+ class AudioAnalysisObject < BaseModel
9
+ SKIP = Object.new
10
+ private_constant :SKIP
11
+
12
+ # TODO: Write general description for this method
13
+ # @return [Meta]
14
+ attr_accessor :meta
15
+
16
+ # TODO: Write general description for this method
17
+ # @return [Track]
18
+ attr_accessor :track
19
+
20
+ # The time intervals of the bars throughout the track. A bar (or measure) is
21
+ # a segment of time defined as a given number of beats.
22
+ # @return [Array[TimeIntervalObject]]
23
+ attr_accessor :bars
24
+
25
+ # The time intervals of beats throughout the track. A beat is the basic time
26
+ # unit of a piece of music; for example, each tick of a metronome. Beats are
27
+ # typically multiples of tatums.
28
+ # @return [Array[TimeIntervalObject]]
29
+ attr_accessor :beats
30
+
31
+ # Sections are defined by large variations in rhythm or timbre, e.g. chorus,
32
+ # verse, bridge, guitar solo, etc. Each section contains its own
33
+ # descriptions of tempo, key, mode, time_signature, and loudness.
34
+ # @return [Array[SectionObject]]
35
+ attr_accessor :sections
36
+
37
+ # Each segment contains a roughly conisistent sound throughout its duration.
38
+ # @return [Array[SegmentObject]]
39
+ attr_accessor :segments
40
+
41
+ # A tatum represents the lowest regular pulse train that a listener
42
+ # intuitively infers from the timing of perceived musical events (segments).
43
+ # @return [Array[TimeIntervalObject]]
44
+ attr_accessor :tatums
45
+
46
+ # A mapping from model property names to API property names.
47
+ def self.names
48
+ @_hash = {} if @_hash.nil?
49
+ @_hash['meta'] = 'meta'
50
+ @_hash['track'] = 'track'
51
+ @_hash['bars'] = 'bars'
52
+ @_hash['beats'] = 'beats'
53
+ @_hash['sections'] = 'sections'
54
+ @_hash['segments'] = 'segments'
55
+ @_hash['tatums'] = 'tatums'
56
+ @_hash
57
+ end
58
+
59
+ # An array for optional fields
60
+ def self.optionals
61
+ %w[
62
+ meta
63
+ track
64
+ bars
65
+ beats
66
+ sections
67
+ segments
68
+ tatums
69
+ ]
70
+ end
71
+
72
+ # An array for nullable fields
73
+ def self.nullables
74
+ []
75
+ end
76
+
77
+ def initialize(meta = SKIP, track = SKIP, bars = SKIP, beats = SKIP,
78
+ sections = SKIP, segments = SKIP, tatums = SKIP)
79
+ @meta = meta unless meta == SKIP
80
+ @track = track unless track == SKIP
81
+ @bars = bars unless bars == SKIP
82
+ @beats = beats unless beats == SKIP
83
+ @sections = sections unless sections == SKIP
84
+ @segments = segments unless segments == SKIP
85
+ @tatums = tatums unless tatums == SKIP
86
+ end
87
+
88
+ # Creates an instance of the object from a hash.
89
+ def self.from_hash(hash)
90
+ return nil unless hash
91
+
92
+ # Extract variables from the hash.
93
+ meta = Meta.from_hash(hash['meta']) if hash['meta']
94
+ track = Track.from_hash(hash['track']) if hash['track']
95
+ # Parameter is an array, so we need to iterate through it
96
+ bars = nil
97
+ unless hash['bars'].nil?
98
+ bars = []
99
+ hash['bars'].each do |structure|
100
+ bars << (TimeIntervalObject.from_hash(structure) if structure)
101
+ end
102
+ end
103
+
104
+ bars = SKIP unless hash.key?('bars')
105
+ # Parameter is an array, so we need to iterate through it
106
+ beats = nil
107
+ unless hash['beats'].nil?
108
+ beats = []
109
+ hash['beats'].each do |structure|
110
+ beats << (TimeIntervalObject.from_hash(structure) if structure)
111
+ end
112
+ end
113
+
114
+ beats = SKIP unless hash.key?('beats')
115
+ # Parameter is an array, so we need to iterate through it
116
+ sections = nil
117
+ unless hash['sections'].nil?
118
+ sections = []
119
+ hash['sections'].each do |structure|
120
+ sections << (SectionObject.from_hash(structure) if structure)
121
+ end
122
+ end
123
+
124
+ sections = SKIP unless hash.key?('sections')
125
+ # Parameter is an array, so we need to iterate through it
126
+ segments = nil
127
+ unless hash['segments'].nil?
128
+ segments = []
129
+ hash['segments'].each do |structure|
130
+ segments << (SegmentObject.from_hash(structure) if structure)
131
+ end
132
+ end
133
+
134
+ segments = SKIP unless hash.key?('segments')
135
+ # Parameter is an array, so we need to iterate through it
136
+ tatums = nil
137
+ unless hash['tatums'].nil?
138
+ tatums = []
139
+ hash['tatums'].each do |structure|
140
+ tatums << (TimeIntervalObject.from_hash(structure) if structure)
141
+ end
142
+ end
143
+
144
+ tatums = SKIP unless hash.key?('tatums')
145
+
146
+ # Create object from extracted values.
147
+ AudioAnalysisObject.new(meta,
148
+ track,
149
+ bars,
150
+ beats,
151
+ sections,
152
+ segments,
153
+ tatums)
154
+ end
155
+ end
156
+ end