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,253 @@
1
+ # spotify_web_api
2
+ #
3
+ # This file was automatically generated by APIMATIC v2.0
4
+ # ( https://apimatic.io ).
5
+
6
+ module SpotifyWebApi
7
+ # AudiobookObject Model.
8
+ class AudiobookObject < BaseModel
9
+ SKIP = Object.new
10
+ private_constant :SKIP
11
+
12
+ # The author(s) for the audiobook.
13
+ # @return [Array[AuthorObject]]
14
+ attr_accessor :authors
15
+
16
+ # A list of the countries in which the audiobook can be played, identified
17
+ # by their [ISO 3166-1
18
+ # alpha-2](http://en.wikipedia.org/wiki/ISO_3166-1_alpha-2) code.
19
+ # @return [Array[String]]
20
+ attr_accessor :available_markets
21
+
22
+ # The copyright statements of the audiobook.
23
+ # @return [Array[CopyrightObject]]
24
+ attr_accessor :copyrights
25
+
26
+ # A description of the audiobook. HTML tags are stripped away from this
27
+ # field, use `html_description` field in case HTML tags are needed.
28
+ # @return [String]
29
+ attr_accessor :description
30
+
31
+ # A description of the audiobook. This field may contain HTML tags.
32
+ # @return [String]
33
+ attr_accessor :html_description
34
+
35
+ # The edition of the audiobook.
36
+ # @return [String]
37
+ attr_accessor :edition
38
+
39
+ # Whether or not the audiobook has explicit content (true = yes it does;
40
+ # false = no it does not OR unknown).
41
+ # @return [TrueClass | FalseClass]
42
+ attr_accessor :explicit
43
+
44
+ # External URLs for this audiobook.
45
+ # @return [ExternalUrlObject]
46
+ attr_accessor :external_urls
47
+
48
+ # A link to the Web API endpoint providing full details of the audiobook.
49
+ # @return [String]
50
+ attr_accessor :href
51
+
52
+ # The [Spotify ID](/documentation/web-api/concepts/spotify-uris-ids) for the
53
+ # audiobook.
54
+ # @return [String]
55
+ attr_accessor :id
56
+
57
+ # The cover art for the audiobook in various sizes, widest first.
58
+ # @return [Array[ImageObject]]
59
+ attr_accessor :images
60
+
61
+ # A list of the languages used in the audiobook, identified by their [ISO
62
+ # 639](https://en.wikipedia.org/wiki/ISO_639) code.
63
+ # @return [Array[String]]
64
+ attr_accessor :languages
65
+
66
+ # The media type of the audiobook.
67
+ # @return [String]
68
+ attr_accessor :media_type
69
+
70
+ # The name of the audiobook.
71
+ # @return [String]
72
+ attr_accessor :name
73
+
74
+ # The narrator(s) for the audiobook.
75
+ # @return [Array[NarratorObject]]
76
+ attr_accessor :narrators
77
+
78
+ # The publisher of the audiobook.
79
+ # @return [String]
80
+ attr_accessor :publisher
81
+
82
+ # The object type.
83
+ # @return [Type9Enum]
84
+ attr_accessor :type
85
+
86
+ # The [Spotify URI](/documentation/web-api/concepts/spotify-uris-ids) for
87
+ # the audiobook.
88
+ # @return [String]
89
+ attr_accessor :uri
90
+
91
+ # The number of chapters in this audiobook.
92
+ # @return [Integer]
93
+ attr_accessor :total_chapters
94
+
95
+ # The chapters of the audiobook.
96
+ # @return [PagingSimplifiedChapterObject]
97
+ attr_accessor :chapters
98
+
99
+ # A mapping from model property names to API property names.
100
+ def self.names
101
+ @_hash = {} if @_hash.nil?
102
+ @_hash['authors'] = 'authors'
103
+ @_hash['available_markets'] = 'available_markets'
104
+ @_hash['copyrights'] = 'copyrights'
105
+ @_hash['description'] = 'description'
106
+ @_hash['html_description'] = 'html_description'
107
+ @_hash['edition'] = 'edition'
108
+ @_hash['explicit'] = 'explicit'
109
+ @_hash['external_urls'] = 'external_urls'
110
+ @_hash['href'] = 'href'
111
+ @_hash['id'] = 'id'
112
+ @_hash['images'] = 'images'
113
+ @_hash['languages'] = 'languages'
114
+ @_hash['media_type'] = 'media_type'
115
+ @_hash['name'] = 'name'
116
+ @_hash['narrators'] = 'narrators'
117
+ @_hash['publisher'] = 'publisher'
118
+ @_hash['type'] = 'type'
119
+ @_hash['uri'] = 'uri'
120
+ @_hash['total_chapters'] = 'total_chapters'
121
+ @_hash['chapters'] = 'chapters'
122
+ @_hash
123
+ end
124
+
125
+ # An array for optional fields
126
+ def self.optionals
127
+ %w[
128
+ edition
129
+ ]
130
+ end
131
+
132
+ # An array for nullable fields
133
+ def self.nullables
134
+ []
135
+ end
136
+
137
+ def initialize(authors = nil, available_markets = nil, copyrights = nil,
138
+ description = nil, html_description = nil, explicit = nil,
139
+ external_urls = nil, href = nil, id = nil, images = nil,
140
+ languages = nil, media_type = nil, name = nil,
141
+ narrators = nil, publisher = nil, type = nil, uri = nil,
142
+ total_chapters = nil, chapters = nil, edition = SKIP)
143
+ @authors = authors
144
+ @available_markets = available_markets
145
+ @copyrights = copyrights
146
+ @description = description
147
+ @html_description = html_description
148
+ @edition = edition unless edition == SKIP
149
+ @explicit = explicit
150
+ @external_urls = external_urls
151
+ @href = href
152
+ @id = id
153
+ @images = images
154
+ @languages = languages
155
+ @media_type = media_type
156
+ @name = name
157
+ @narrators = narrators
158
+ @publisher = publisher
159
+ @type = type
160
+ @uri = uri
161
+ @total_chapters = total_chapters
162
+ @chapters = chapters
163
+ end
164
+
165
+ # Creates an instance of the object from a hash.
166
+ def self.from_hash(hash)
167
+ return nil unless hash
168
+
169
+ # Extract variables from the hash.
170
+ # Parameter is an array, so we need to iterate through it
171
+ authors = nil
172
+ unless hash['authors'].nil?
173
+ authors = []
174
+ hash['authors'].each do |structure|
175
+ authors << (AuthorObject.from_hash(structure) if structure)
176
+ end
177
+ end
178
+
179
+ authors = nil unless hash.key?('authors')
180
+ available_markets =
181
+ hash.key?('available_markets') ? hash['available_markets'] : nil
182
+ # Parameter is an array, so we need to iterate through it
183
+ copyrights = nil
184
+ unless hash['copyrights'].nil?
185
+ copyrights = []
186
+ hash['copyrights'].each do |structure|
187
+ copyrights << (CopyrightObject.from_hash(structure) if structure)
188
+ end
189
+ end
190
+
191
+ copyrights = nil unless hash.key?('copyrights')
192
+ description = hash.key?('description') ? hash['description'] : nil
193
+ html_description =
194
+ hash.key?('html_description') ? hash['html_description'] : nil
195
+ explicit = hash.key?('explicit') ? hash['explicit'] : nil
196
+ external_urls = ExternalUrlObject.from_hash(hash['external_urls']) if hash['external_urls']
197
+ href = hash.key?('href') ? hash['href'] : nil
198
+ id = hash.key?('id') ? hash['id'] : nil
199
+ # Parameter is an array, so we need to iterate through it
200
+ images = nil
201
+ unless hash['images'].nil?
202
+ images = []
203
+ hash['images'].each do |structure|
204
+ images << (ImageObject.from_hash(structure) if structure)
205
+ end
206
+ end
207
+
208
+ images = nil unless hash.key?('images')
209
+ languages = hash.key?('languages') ? hash['languages'] : nil
210
+ media_type = hash.key?('media_type') ? hash['media_type'] : nil
211
+ name = hash.key?('name') ? hash['name'] : nil
212
+ # Parameter is an array, so we need to iterate through it
213
+ narrators = nil
214
+ unless hash['narrators'].nil?
215
+ narrators = []
216
+ hash['narrators'].each do |structure|
217
+ narrators << (NarratorObject.from_hash(structure) if structure)
218
+ end
219
+ end
220
+
221
+ narrators = nil unless hash.key?('narrators')
222
+ publisher = hash.key?('publisher') ? hash['publisher'] : nil
223
+ type = hash.key?('type') ? hash['type'] : nil
224
+ uri = hash.key?('uri') ? hash['uri'] : nil
225
+ total_chapters =
226
+ hash.key?('total_chapters') ? hash['total_chapters'] : nil
227
+ chapters = PagingSimplifiedChapterObject.from_hash(hash['chapters']) if hash['chapters']
228
+ edition = hash.key?('edition') ? hash['edition'] : SKIP
229
+
230
+ # Create object from extracted values.
231
+ AudiobookObject.new(authors,
232
+ available_markets,
233
+ copyrights,
234
+ description,
235
+ html_description,
236
+ explicit,
237
+ external_urls,
238
+ href,
239
+ id,
240
+ images,
241
+ languages,
242
+ media_type,
243
+ name,
244
+ narrators,
245
+ publisher,
246
+ type,
247
+ uri,
248
+ total_chapters,
249
+ chapters,
250
+ edition)
251
+ end
252
+ end
253
+ end
@@ -0,0 +1,50 @@
1
+ # spotify_web_api
2
+ #
3
+ # This file was automatically generated by APIMATIC v2.0
4
+ # ( https://apimatic.io ).
5
+
6
+ module SpotifyWebApi
7
+ # AuthorObject Model.
8
+ class AuthorObject < BaseModel
9
+ SKIP = Object.new
10
+ private_constant :SKIP
11
+
12
+ # The name of the author.
13
+ # @return [String]
14
+ attr_accessor :name
15
+
16
+ # A mapping from model property names to API property names.
17
+ def self.names
18
+ @_hash = {} if @_hash.nil?
19
+ @_hash['name'] = 'name'
20
+ @_hash
21
+ end
22
+
23
+ # An array for optional fields
24
+ def self.optionals
25
+ %w[
26
+ name
27
+ ]
28
+ end
29
+
30
+ # An array for nullable fields
31
+ def self.nullables
32
+ []
33
+ end
34
+
35
+ def initialize(name = SKIP)
36
+ @name = name unless name == SKIP
37
+ end
38
+
39
+ # Creates an instance of the object from a hash.
40
+ def self.from_hash(hash)
41
+ return nil unless hash
42
+
43
+ # Extract variables from the hash.
44
+ name = hash.key?('name') ? hash['name'] : SKIP
45
+
46
+ # Create object from extracted values.
47
+ AuthorObject.new(name)
48
+ end
49
+ end
50
+ end
@@ -0,0 +1,62 @@
1
+ # spotify_web_api
2
+ #
3
+ # This file was automatically generated by APIMATIC v2.0
4
+ # ( https://apimatic.io ).
5
+
6
+ module SpotifyWebApi
7
+ # Base model.
8
+ class BaseModel < CoreLibrary::BaseModel
9
+ # Returns a Hash representation of the current object.
10
+ def to_hash
11
+ # validating the model being serialized
12
+ self.class.validate(self) if self.class.respond_to?(:validate)
13
+
14
+ hash = {}
15
+ instance_variables.each do |name|
16
+ value = instance_variable_get(name)
17
+ name = name[1..]
18
+ key = self.class.names.key?(name) ? self.class.names[name] : name
19
+ optional_fields = self.class.optionals
20
+ nullable_fields = self.class.nullables
21
+ if value.nil?
22
+ next unless nullable_fields.include?(name)
23
+
24
+ if !optional_fields.include?(name) && !nullable_fields.include?(name)
25
+ raise ArgumentError,
26
+ "`#{name}` cannot be nil in `#{self.class}`. Please specify a valid value."
27
+ end
28
+ end
29
+
30
+ hash[key] = nil
31
+ unless value.nil?
32
+ if respond_to?("to_custom_#{name}")
33
+ if (value.instance_of? Array) || (value.instance_of? Hash)
34
+ params = [hash, key]
35
+ hash[key] = send("to_custom_#{name}", *params)
36
+ else
37
+ hash[key] = send("to_custom_#{name}")
38
+ end
39
+ elsif respond_to?("to_union_type_#{name}")
40
+ hash[key] = send("to_union_type_#{name}")
41
+ elsif value.instance_of? Array
42
+ hash[key] = value.map { |v| v.is_a?(BaseModel) ? v.to_hash : v }
43
+ elsif value.instance_of? Hash
44
+ hash[key] = {}
45
+ value.each do |k, v|
46
+ hash[key][k] = v.is_a?(BaseModel) ? v.to_hash : v
47
+ end
48
+ else
49
+ hash[key] = value.is_a?(BaseModel) ? value.to_hash : value
50
+ end
51
+ end
52
+ end
53
+ hash
54
+ end
55
+
56
+ # Returns a JSON representation of the curent object.
57
+ def to_json(options = {})
58
+ hash = to_hash
59
+ hash.to_json(options)
60
+ end
61
+ end
62
+ end
@@ -0,0 +1,110 @@
1
+ # spotify_web_api
2
+ #
3
+ # This file was automatically generated by APIMATIC v2.0
4
+ # ( https://apimatic.io ).
5
+
6
+ module SpotifyWebApi
7
+ # Categories Model.
8
+ class Categories < BaseModel
9
+ SKIP = Object.new
10
+ private_constant :SKIP
11
+
12
+ # A link to the Web API endpoint returning the full result of the request
13
+ # @return [String]
14
+ attr_accessor :href
15
+
16
+ # The maximum number of items in the response (as set in the query or by
17
+ # default).
18
+ # @return [Integer]
19
+ attr_accessor :limit
20
+
21
+ # URL to the next page of items. ( `null` if none)
22
+ # @return [String]
23
+ attr_accessor :mnext
24
+
25
+ # The offset of the items returned (as set in the query or by default)
26
+ # @return [Integer]
27
+ attr_accessor :offset
28
+
29
+ # URL to the previous page of items. ( `null` if none)
30
+ # @return [String]
31
+ attr_accessor :previous
32
+
33
+ # The total number of items available to return.
34
+ # @return [Integer]
35
+ attr_accessor :total
36
+
37
+ # The total number of items available to return.
38
+ # @return [Array[CategoryObject]]
39
+ attr_accessor :items
40
+
41
+ # A mapping from model property names to API property names.
42
+ def self.names
43
+ @_hash = {} if @_hash.nil?
44
+ @_hash['href'] = 'href'
45
+ @_hash['limit'] = 'limit'
46
+ @_hash['mnext'] = 'next'
47
+ @_hash['offset'] = 'offset'
48
+ @_hash['previous'] = 'previous'
49
+ @_hash['total'] = 'total'
50
+ @_hash['items'] = 'items'
51
+ @_hash
52
+ end
53
+
54
+ # An array for optional fields
55
+ def self.optionals
56
+ []
57
+ end
58
+
59
+ # An array for nullable fields
60
+ def self.nullables
61
+ %w[
62
+ mnext
63
+ previous
64
+ ]
65
+ end
66
+
67
+ def initialize(href = nil, limit = nil, mnext = nil, offset = nil,
68
+ previous = nil, total = nil, items = nil)
69
+ @href = href
70
+ @limit = limit
71
+ @mnext = mnext
72
+ @offset = offset
73
+ @previous = previous
74
+ @total = total
75
+ @items = items
76
+ end
77
+
78
+ # Creates an instance of the object from a hash.
79
+ def self.from_hash(hash)
80
+ return nil unless hash
81
+
82
+ # Extract variables from the hash.
83
+ href = hash.key?('href') ? hash['href'] : nil
84
+ limit = hash.key?('limit') ? hash['limit'] : nil
85
+ mnext = hash.key?('next') ? hash['next'] : nil
86
+ offset = hash.key?('offset') ? hash['offset'] : nil
87
+ previous = hash.key?('previous') ? hash['previous'] : nil
88
+ total = hash.key?('total') ? hash['total'] : nil
89
+ # Parameter is an array, so we need to iterate through it
90
+ items = nil
91
+ unless hash['items'].nil?
92
+ items = []
93
+ hash['items'].each do |structure|
94
+ items << (CategoryObject.from_hash(structure) if structure)
95
+ end
96
+ end
97
+
98
+ items = nil unless hash.key?('items')
99
+
100
+ # Create object from extracted values.
101
+ Categories.new(href,
102
+ limit,
103
+ mnext,
104
+ offset,
105
+ previous,
106
+ total,
107
+ items)
108
+ end
109
+ end
110
+ end
@@ -0,0 +1,82 @@
1
+ # spotify_web_api
2
+ #
3
+ # This file was automatically generated by APIMATIC v2.0
4
+ # ( https://apimatic.io ).
5
+
6
+ module SpotifyWebApi
7
+ # CategoryObject Model.
8
+ class CategoryObject < BaseModel
9
+ SKIP = Object.new
10
+ private_constant :SKIP
11
+
12
+ # A link to the Web API endpoint returning full details of the category.
13
+ # @return [String]
14
+ attr_accessor :href
15
+
16
+ # The category icon, in various sizes.
17
+ # @return [Array[ImageObject]]
18
+ attr_accessor :icons
19
+
20
+ # The [Spotify category
21
+ # ID](/documentation/web-api/concepts/spotify-uris-ids) of the category.
22
+ # @return [String]
23
+ attr_accessor :id
24
+
25
+ # The name of the category.
26
+ # @return [String]
27
+ attr_accessor :name
28
+
29
+ # A mapping from model property names to API property names.
30
+ def self.names
31
+ @_hash = {} if @_hash.nil?
32
+ @_hash['href'] = 'href'
33
+ @_hash['icons'] = 'icons'
34
+ @_hash['id'] = 'id'
35
+ @_hash['name'] = 'name'
36
+ @_hash
37
+ end
38
+
39
+ # An array for optional fields
40
+ def self.optionals
41
+ []
42
+ end
43
+
44
+ # An array for nullable fields
45
+ def self.nullables
46
+ []
47
+ end
48
+
49
+ def initialize(href = nil, icons = nil, id = nil, name = nil)
50
+ @href = href
51
+ @icons = icons
52
+ @id = id
53
+ @name = name
54
+ end
55
+
56
+ # Creates an instance of the object from a hash.
57
+ def self.from_hash(hash)
58
+ return nil unless hash
59
+
60
+ # Extract variables from the hash.
61
+ href = hash.key?('href') ? hash['href'] : nil
62
+ # Parameter is an array, so we need to iterate through it
63
+ icons = nil
64
+ unless hash['icons'].nil?
65
+ icons = []
66
+ hash['icons'].each do |structure|
67
+ icons << (ImageObject.from_hash(structure) if structure)
68
+ end
69
+ end
70
+
71
+ icons = nil unless hash.key?('icons')
72
+ id = hash.key?('id') ? hash['id'] : nil
73
+ name = hash.key?('name') ? hash['name'] : nil
74
+
75
+ # Create object from extracted values.
76
+ CategoryObject.new(href,
77
+ icons,
78
+ id,
79
+ name)
80
+ end
81
+ end
82
+ end