spotifyrb 0.1.1 → 0.1.3

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 9f297da4352a87242f5d72b1cdc14165fb2a1172bfb2c96a7cc0e74973ab3a37
4
- data.tar.gz: 64536c5db2bc94fc14c515d7c36523590882f6933a059d32cc334737daa2a3f0
3
+ metadata.gz: bfe7ac44a72ddc642e2226b410a4f66e4a7961f8975bbff56ab28224db78d500
4
+ data.tar.gz: d804caa3e752de26554210d94790b537fb4dd18b6cf5086f88f55723940d9cf1
5
5
  SHA512:
6
- metadata.gz: 87672f073f278b959edf147ecb7ce0cd7ac2434c290c9f6be6e9a8ccaff8dc449dc2315492d1409b3e53045629aeb443782787fd1a0092f830eaa6c331da45a4
7
- data.tar.gz: b9cd9a4065b9daccc30e0e44822384c461a911181830f718df640b2dca25cd52b00baef1234797b5fae6114a2e42c512b5944d90a38c1d2d4879333801be9a46
6
+ metadata.gz: 8337c64f964cbb0555809a92a01494e22f74e9fa5d251155113a7a7d6bbbcdc4623da0b6c2c9f48ec36f51c6e05286583b1d4bb916cc59459902ac642ef6a2f3
7
+ data.tar.gz: 9bf218385a1f7aead53255a566d4d878de30ee03b069d952bf641737fc55622271eeea37c6ff8f8e76896fb0243b41bce0afb356ce74964d8b989993d0f30123
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- spotifyrb (0.1.1)
4
+ spotifyrb (0.1.3)
5
5
  faraday (~> 2.11)
6
6
  ostruct (~> 0.6.0)
7
7
 
data/README.md CHANGED
@@ -14,9 +14,7 @@ gem "spotifyrb"
14
14
 
15
15
  ### Set Client Details
16
16
 
17
- Firstly you'll need to set a Client ID and an Access Token.
18
-
19
- An access token is required because the Spotify API requires authentication.
17
+ Firstly you'll need to set an Access Token, because the Spotify API requires authentication.
20
18
 
21
19
  ```ruby
22
20
  @client = Spotify::Client.new(access_token: "xyz123")
@@ -26,542 +24,97 @@ An access token is required because the Spotify API requires authentication.
26
24
 
27
25
  The gem maps as closely as we can to the Spotify API so you can easily convert API examples to gem code.
28
26
 
29
- Responses are created as objects like `Spotify::Channel`. Having types like `Spotify::User` is handy for understanding what
27
+ Responses are created as objects like `Spotify::Track`. Having types like `Spotify::User` is handy for understanding what
30
28
  type of object you're working with. They're built using OpenStruct so you can easily access data in a Ruby-ish way.
31
29
 
32
- ### Pagination
33
-
34
- Some of the endpoints return pages of results. The result object will have a `data` key to access the results, as well as metadata like `cursor`
35
- for retrieving the next and previous pages. This can be used by using `before` and `after` parameters, on API endpoints that support it.
36
-
37
- An example of using collections, including pagination:
30
+ ### Me
38
31
 
39
32
  ```ruby
40
- results = @client.clips.list(broadcaster_id: 123)
41
- #=> Spotify::Collection
42
-
43
- results.total
44
- #=> 30
45
-
46
- results.data
47
- #=> [#<Spotify::Clip>, #<Spotify::Clip>]
48
-
49
- results.each do |result|
50
- puts result.id
51
- end
52
-
53
- results.first
54
- #=> #<Spotify::Clip>
55
-
56
- results.last
57
- #=> #<Spotify::Clip>
58
-
59
- results.cursor
60
- #=> "abc123"
61
-
62
- # Retrieve the next page
63
- @client.clips.list(broadcaster_id: 123, after: results.cursor)
64
- #=> Spotify::Collection
65
- ```
66
-
67
- ### OAuth
68
-
69
- This library includes the ability to create, refresh and revoke OAuth tokens.
70
-
71
- ```ruby
72
- # Firstly, set the client details
73
- @oauth = Spotify::OAuth.new(client_id: "", client_secret: "")
74
-
75
- # Create a Token
76
- # grant_type can be either "authorization_code" or "client_credentials"
77
- # scope is a space-delimited list of scopes. This is optional depending on the grant_type
78
- @oauth.create(grant_type: "", scope: "")
79
-
80
- # Refresh a Token
81
- @oauth.refresh(refresh_token: "")
82
-
83
- # Device Code Grant Flow
84
- # scopes is required and is a space-delimited list of scopes
85
- # https://dev.spotify.tv/docs/authentication/getting-tokens-oauth/#device-code-grant-flow
86
- @oauth.device(scopes: "bits:read channel:read:subscriptions")
87
-
88
- # Validate an Access Token
89
- # Returns false if the token is invalid
90
- @oauth.validate(token: "")
33
+ # Retrieves the currently authenticated user's details
34
+ @client.me.me
91
35
 
92
- # Revoke a Token
93
- @oauth.revoke(token: "")
36
+ # Retrieves the currently authenticated user's playlists
37
+ @client.me.playlists
38
+ @client.me.playlists(limit: 10)
94
39
  ```
95
40
 
96
41
  ### Users
97
42
 
98
43
  ```ruby
99
- # Retrieves a user by their ID
100
- @client.users.retrieve(id: 141981764)
101
-
102
- # Retrieves multiple users by their IDs
103
- # Requires an array of IDs
104
- @client.users.retrieve(ids: [141981764, 72938118])
105
-
106
- # Retrieves a user by their username
107
- @client.users.retrieve(username: "spotifydev")
108
-
109
- # Retrieves multiple users by their usernames
110
- # Requires an array of IDs
111
- @client.users.retrieve(usernames: ["spotifydev", "deanpcmad"])
112
-
113
- # Update the currently authenticated user's description
114
- # Required scope: user:edit
115
- @client.users.update(description: "New Description")
116
-
117
- # Returns Blocked users for a broadcaster
118
- # Required scope: user:read:blocked_users
119
- @client.users.blocks(broadcaster_id: 141981764)
120
-
121
- # Blocks a user
122
- # Required scope: user:manage:blocked_users
123
- @client.users.block_user(target_user_id: 141981764)
124
-
125
- # Unblocks a user
126
- # Required scope: user:manage:blocked_users
127
- @client.users.unblock_user(target_user_id: 141981764)
128
-
129
- # Get a User's Chat Color
130
- @client.users.get_color(user_id: 123)
131
-
132
- # Or get multiple users' chat colors
133
- # Returns a collection
134
- @client.users.get_color(user_ids: "123,321")
135
-
136
- # Update a User's Chat Color
137
- # Requires user:manage:chat_color
138
- # user_id must be the currently authenticated user
139
- # Current allowed colours: blue, blue_violet, cadet_blue, chocolate, coral, dodger_blue, firebrick, golden_rod, green, hot_pink, orange_red, red, sea_green, spring_green, yellow_green
140
- # For Turbo and Prime users, a hex colour code is allowed.
141
- @client.users.update_color(user_id: 123, color: "blue")
142
-
143
- # Get Emotes a User has
144
- # Required scope: user:read:emotes
145
- @client.users.emotes(user_id: 123)
146
- @client.users.emotes(user_id: 123, broadcaster_id: 321)
147
- @client.users.emotes(user_id: 123, after: "abc123")
148
- ```
149
-
150
- ### Channels
151
-
152
- ```ruby
153
- # Retrieve a channel by their ID
154
- @client.channels.retrieve(id: 141981764)
155
-
156
- # Retrieve a list of broadcasters a specified user follows
157
- # user_id must match the currently authenticated user
158
- # Required scope: user:read:follows
159
- @client.channels.followed user_id: 123123
160
-
161
- # Retrieve a list of users that follow a specified broadcaster
162
- # broadcaster_id must match the currently authenticated user or
163
- # a moderator of the specified broadcaster
164
- # Required scope: moderator:read:followers
165
- @client.channels.followers broadcaster_id: 123123
166
-
167
- # Retrieve the number of Followers a broadcaster has
168
- @client.channels.follows_count(broadcaster_id: 141981764)
169
-
170
- # Retrieve the number of Subscribers and Subscriber Points a broadcaster has
171
- # Required scope: channel:read:subscriptions
172
- @client.channels.subscribers_count(broadcaster_id: 141981764)
173
-
174
- # Update the currently authenticated channel details
175
- # Required scope: channel:manage:broadcast
176
- # Parameters which are allowed: game_id, title, broadcaster_language, delay
177
- attributes = {title: "My new title"}
178
- @client.channels.update(broadcaster_id: 141981764, attributes)
179
-
180
- # Retrieves editors for a channel
181
- @client.channels.editors(broadcaster_id: 141981764)
182
- ```
183
-
184
- ### Videos
185
-
186
- ```ruby
187
- # Retrieves a list of videos
188
- # Available parameters: user_id or game_id
189
- @client.videos.list(user_id: 12345)
190
- @client.videos.list(game_id: 12345)
191
-
192
- # Retrieves a video by its ID
193
- @client.videos.retrieve(id: 12345)
194
- ```
195
-
196
- ### Clips
44
+ # Get's a user's profile. ID would be their Spotify ID
45
+ @client.users.get(id: "username")
197
46
 
198
- ```ruby
199
- # Retrieves a list of clips
200
- # Available parameters: broadcaster_id or game_id
201
- @client.clips.list(user_id: 12345)
202
- @client.clips.list(game_id: 12345)
203
-
204
- # Retrieves a clip by its ID.
205
- # Clip IDs are alphanumeric. e.g. AwkwardHelplessSalamanderSwiftRage
206
- @client.clips.retrieve(id: "AwkwardHelplessSalamanderSwiftRage")
207
-
208
- # Create a clip of a given Channel
209
- # Required scope: clips:edit
210
- @client.clips.create(broadcaster_id: 1234)
47
+ # Gets a list of a user's playlists
48
+ @client.users.playlists(id: "username")
49
+ @client.users.playlists(id: "username", limit: 10)
211
50
  ```
212
51
 
213
- ### Emotes
52
+ ### Playlists
214
53
 
215
54
  ```ruby
216
- # Retrieve all global emotes
217
- @client.emotes.global
55
+ # Get a Playlist
56
+ @client.playlists.get(id: "abc123")
218
57
 
219
- # Retrieve emotes for a channel
220
- @client.emotes.channel(broadcaster_id: 141981764)
58
+ # Create a Playlist
59
+ @client.playlists.create(user: "userid", name: "My Playlist")
60
+ @client.playlists.create(user: "userid", name: "My Playlist", public: true)
61
+ @client.playlists.create(user: "userid", name: "My Playlist", description: "My Description")
221
62
 
222
- # Retrieve emotes for an emote set
223
- @client.emotes.sets(emote_set_id: 301590448)
224
- ```
63
+ # Update a Playlist
64
+ @client.playlists.update(id: "abc123", name: "A name change")
225
65
 
226
- ### Badges
66
+ # Get the tracks on a Playlist
67
+ @client.playlists.tracks(id: "abc123")
68
+ @client.playlists.tracks(id: "abc123", market: "GB")
227
69
 
228
- ```ruby
229
- # Retrieve all global badges
230
- @client.badges.global
70
+ # Add a track (or multiple tracks) to a Playlist
71
+ # uris should be in the following format: 'spotify:type:id' e.g. 'spotify:track:1k2pQc5i348DCHwbn5KTdc'
72
+ # to add multiple tracks, uris should be comma separated
73
+ # If successful, returns a Snapshot ID
74
+ @client.playlists.add_tracks(id: "abc123", uris: "spotify:track:1k2pQc5i348DCHwbn5KTdc")
75
+ @client.playlists.add_tracks(id: "abc123", uris: "spotify:track:1k2pQc5i348DCHwbn5KTdc", position: 0)
231
76
 
232
- # Retrieve badges for a channel
233
- @client.badges.channel(broadcaster_id: 141981764)
77
+ # Remove a track (or multiple tracks) from a Playlist
78
+ @client.playlists.remove_tracks(id: "abc123", uris: "spotify:track:1k2pQc5i348DCHwbn5KTdc")
79
+ @client.playlists.remove_tracks(id: "abc123", snapshot_id: "123abc")
234
80
  ```
235
81
 
236
- ### Games
82
+ ### Player
237
83
 
238
84
  ```ruby
239
- # Retrieves a game by ID
240
- @client.games.retrieve(id: 514974)
85
+ # Get the Player state
86
+ @client.player.state
87
+ @client.player.state(market: "GB")
241
88
 
242
- # Retrieves multiple games by IDs
243
- # Requires an array of IDs
244
- @client.games.retrieve(ids: [66402, 514974])
89
+ # Get the Player Devices
90
+ @client.player.devices
245
91
 
246
- # Retrieves a game by name
247
- @client.games.retrieve(name: "Battlefield 4")
92
+ # Get the current playing song
93
+ @client.player.playing
94
+ @client.player.playing(market: "GB")
248
95
 
249
- # Retrieves multiple games by names
250
- # Requires an array of IDs
251
- @client.games.retrieve(names: ["Battlefield 4", "Battlefield 2042"])
252
- ```
96
+ # Start/Resume Playback
97
+ @client.player.play
98
+ @client.player.play(device: "abc123")
253
99
 
254
- ### EventSub Subscriptions
100
+ # Pause Playback
101
+ @client.player.pause
102
+ @client.player.pause(device: "abc123")
255
103
 
256
- These require an application OAuth access token.
104
+ # Skip to next
105
+ @client.player.next
106
+ @client.player.next(device: "abc123")
257
107
 
258
- ```ruby
259
- # Retrieves a list of EventSub Subscriptions
260
- # Available parameters: status, type, after
261
- @client.eventsub_subscriptions.list
262
- @client.eventsub_subscriptions.list(status: "enabled")
263
- @client.eventsub_subscriptions.list(type: "channel.follow")
264
-
265
- # Create an EventSub Subscription
266
- @client.eventsub_subscriptions.create(
267
- type: "channel.follow",
268
- version: 1,
269
- condition: {broadcaster_user_id: 123},
270
- transport: {method: "webhook", callback: "webhook_url", secret: "secret"}
271
- )
272
-
273
- # Delete an EventSub Subscription
274
- # IDs are UUIDs
275
- @client.eventsub_subscriptions.delete(id: "abc12-abc12-abc12")
276
- ```
108
+ # Skip to previous
109
+ @client.player.previous
110
+ @client.player.previous(device: "abc123")
277
111
 
278
- ### Banned Events
112
+ # Get the player queue
113
+ @client.player.queue
279
114
 
280
- ```ruby
281
- # Retrieves all ban and un-ban events for a channel
282
- # Available parameters: user_id
283
- @client.banned_events.list(broadcaster_id: 123)
284
- ```
285
-
286
- ### Banned Users
287
-
288
- ```ruby
289
- # Retrieves all banned and timed-out users for a channel
290
- # Available parameters: user_id
291
- @client.banned_users.list(broadcaster_id: 123)
292
- ```
293
-
294
- ```ruby
295
- # Ban/Timeout a user from a broadcaster's channel
296
- # Required scope: moderator:manage:banned_users
297
- # A reason is required
298
- # To time a user out, a duration is required. If no duration is set, the user will be banned.
299
- @client.banned_users.create broadcaster_id: 123, moderator_id: 321, user_id: 112233, reason: "testing", duration: 60
300
- ```
301
-
302
- ```ruby
303
- # Unban/untimeout a user from a broadcaster's channel
304
- # Required scope: moderator:manage:banned_users
305
- @client.banned_users.delete broadcaster_id: 123, moderator_id: 321, user_id: 112233
306
- ```
307
-
308
- ### Send Chat Announcement
309
-
310
- ```ruby
311
- # Sends an announcement to the broadcaster's chat room
312
- # Requires moderator:manage:announcements
313
- # moderator_id can be either the currently authenticated moderator or the broadcaster
314
- # color can be either blue, green, orange, purple, primary. If left blank, primary is default
315
- @client.announcements.create broadcaster_id: 123, moderator_id: 123, message: "test message", color: "purple"
316
- ```
317
-
318
- ### Create a Shoutout
319
-
320
- ```ruby
321
- # Creates a Shoutout for a broadcaster
322
- # Requires moderator:manage:shoutouts
323
- # From: the ID of the Broadcaster creating the Shoutout
324
- # To: the ID of the Broadcaster the Shoutout will be for
325
- # moderator_id can be either the currently authenticated moderator or the broadcaster
326
- @client.shoutouts.create from: 123, to: 321, moderator_id: 123
327
- ```
328
-
329
- ### Moderators
330
-
331
- ```ruby
332
- # List all channels a user has moderator privileges on
333
- # Required scope: user:read:moderated_channels
334
- # user_id must be the currently authenticated user
335
- @client.moderators.channels user_id: 123
336
- ```
337
-
338
- ```ruby
339
- # List all moderators for a broadcaster
340
- # Required scope: moderation:read
341
- # broadcaster_id must be the currently authenticated user
342
- @client.moderators.list broadcaster_id: 123
343
- ```
344
-
345
- ```ruby
346
- # Add a Moderator
347
- # Required scope: channel:manage:moderators
348
- # broadcaster_id must be the currently authenticated user
349
- @client.moderators.create broadcaster_id: 123, user_id: 321
350
- ```
351
-
352
- ```ruby
353
- # Remove a Moderator
354
- # Required scope: channel:manage:moderators
355
- # broadcaster_id must be the currently authenticated user
356
- @client.moderators.delete broadcaster_id: 123, user_id: 321
357
- ```
358
-
359
- ### VIPs
360
-
361
- ```ruby
362
- # List all VIPs for a broadcaster
363
- # Required scope: channel:read:vips or channel:manage:vips
364
- # broadcaster_id must be the currently authenticated user
365
- @client.vips.list broadcaster_id: 123
366
- ```
367
-
368
- ```ruby
369
- # Add a VIP
370
- # Required scope: channel:manage:vips
371
- # broadcaster_id must be the currently authenticated user
372
- @client.vips.create broadcaster_id: 123, user_id: 321
373
- ```
374
-
375
- ```ruby
376
- # Remove a VIP
377
- # Required scope: channel:manage:vips
378
- # broadcaster_id must be the currently authenticated user
379
- @client.vips.delete broadcaster_id: 123, user_id: 321
380
- ```
381
-
382
- ### Raids
383
-
384
- ```ruby
385
- # Starts a raid
386
- # Requires channel:manage:raids
387
- # from_broadcaster_id must be the authenticated user
388
- @client.raids.create from_broadcaster_id: 123, to_broadcaster_id: 321
389
- ```
390
-
391
- ```ruby
392
- # Requires channel:manage:raids
393
- # broadcaster_id must be the authenticated user
394
- @client.raids.delete broadcaster_id: 123
395
- ```
396
-
397
- ### Chat Messages
398
-
399
- ```ruby
400
- # Send a chat message to a broadcaster's chat room
401
- # Requires an app or user access token that includes user:write:chat then either user:bot or channel:bot
402
- # sender_id must be the currently authenticated user
403
- # reply_to is optional and is the UUID of the message to reply to
404
- @client.chat_messages.create broadcaster_id: 123, sender_id: 321, message: "A test message", reply_to: "aabbcc"
405
-
406
- # Removes a single chat message from the broadcaster's chat room
407
- # Requires moderator:manage:chat_messages
408
- # moderator_id can be either the currently authenticated moderator or the broadcaster
409
- @client.chat_messages.delete broadcaster_id: 123, moderator_id: 123, message_id: "abc123-abc123"
410
- ```
411
-
412
- ### Whispers
413
-
414
- ```ruby
415
- # Send a Whisper
416
- # Required scope: user:manage:whispers
417
- # from_user_id must be the currently authenticated user's ID and have a verified phone number
418
- @client.whispers.create from_user_id: 123, to_user_id: 321, message: "this is a test"
419
- ```
420
-
421
- ### AutoMod
422
-
423
- ```ruby
424
- # Check if a message meets the channel's AutoMod requirements
425
- # Required scope: moderation:read
426
- # id is a developer-generated identifier for mapping messages to results.
427
- @client.automod.check_status_multiple broadcaster_id: 123, id: "abc123", text: "Is this message allowed?"
428
-
429
- #> #<Spotify::AutomodStatus msg_id="abc123", is_permitted=true>
430
- ```
431
-
432
- ```ruby
433
- # Check if multiple messages meet the channel's AutoMod requirements
434
- # messages must be an array of hashes and must include msg_id and msg_text
435
- # Returns a collection
436
- messages = [{msg_id: "abc1", msg_text: "is this allowed?"}, {msg_id: "abc2", msg_text: "What about this?"}]
437
- @client.automod.check_status_multiple broadcaster_id: 123, messages: messages
438
- ```
439
-
440
- ```ruby
441
- # Get AutoMod settings
442
- # Required scope: moderator:read:automod_settings
443
- # moderator_id can be either the currently authenticated moderator or the broadcaster
444
- @client.automod.settings broadcaster_id: 123, moderator_id: 321
445
- ```
446
-
447
- ```ruby
448
- # Update AutoMod settings
449
- # Required scope: moderator:manage:automod_settings
450
- # moderator_id can be either the currently authenticated moderator or the broadcaster
451
- # As this is a PUT method, it overwrites all options so all fields you want set should be supplied
452
- @client.automod.update_settings broadcaster_id: 123, moderator_id: 321, swearing: 1
453
- ```
454
-
455
- ### Creator Goals
456
-
457
- ```ruby
458
- # List all active creator goals
459
- # Required scope: channel:read:goals
460
- # broadcaster_id must match the currently authenticated user
461
- @client.goals.list broadcaster_id: 123
462
- ```
463
-
464
- ### Blocked Terms
465
-
466
- ```ruby
467
- # List all blocked terms
468
- # Required scope: moderator:read:blocked_terms
469
- # moderator_id can be either the currently authenticated moderator or the broadcaster
470
- @client.blocked_terms.list broadcaster_id: 123, moderator_id: 321
471
- ```
472
-
473
- ```ruby
474
- # Create a blocked term
475
- # Required scope: moderator:manage:blocked_terms
476
- # moderator_id can be either the currently authenticated moderator or the broadcaster
477
- @client.blocked_terms.create broadcaster_id: 123, moderator_id: 321, text: "term to block"
478
- ```
479
-
480
- ```ruby
481
- # Delete a blocked term
482
- # Required scope: moderator:manage:blocked_terms
483
- # moderator_id can be either the currently authenticated moderator or the broadcaster
484
- @client.blocked_terms.delete broadcaster_id: 123, moderator_id: 321, id: "abc12-12abc"
485
- ```
486
-
487
- ### Charity Campaigns
488
-
489
- ```ruby
490
- # Gets information about the charity campaign that a broadcaster is running
491
- # Required scope: channel:read:charity
492
- # broadcaster_id must match the currently authenticated user
493
- @client.charity_campaigns.list broadcaster_id: 123
494
- ```
495
-
496
- ### Chatters
497
-
498
- ```ruby
499
- # Gets the list of users that are connected to the specified broadcaster’s chat session
500
- # Required scope: moderator:read:chatters
501
- # broadcaster_id must match the currently authenticated user
502
- @client.chatters.list broadcaster_id: 123, moderator_id: 123
503
- ```
504
-
505
- ### Channel Points Custom Rewards
506
-
507
- ```ruby
508
- # Gets a list of custom rewards for a specific channel
509
- # Required scope: channel:read:redemptions
510
- # broadcaster_id must match the currently authenticated user
511
- @client.custom_rewards.list broadcaster_id: 123
512
-
513
- # Create a custom reward
514
- # Required scope: channel:manage:redemptions
515
- # broadcaster_id must match the currently authenticated user
516
- @client.custom_rewards.create broadcaster_id: 123, title: "New Reward", cost: 1000
517
-
518
- # Update a custom reward
519
- # Required scope: channel:manage:redemptions
520
- # broadcaster_id must match the currently authenticated user
521
- @client.custom_rewards.update broadcaster_id: 123, reward_id: 321, title: "Updated Reward"
522
-
523
- # Delete a custom reward
524
- # Required scope: channel:manage:redemptions
525
- # broadcaster_id must match the currently authenticated user
526
- @client.custom_rewards.delete broadcaster_id: 123, reward_id: 321
527
- ```
528
-
529
- ### Channel Points Custom Reward Redemptions
530
-
531
- ```ruby
532
- # Gets a list of custom reward redemptions for a specific channel
533
- # Required scope: channel:read:redemptions
534
- # broadcaster_id must match the currently authenticated user
535
- @client.custom_reward_redemptions.list broadcaster_id: 123, reward_id: 321, status: "UNFULFILLED"
536
-
537
- # Update a custom reward redemption status
538
- # Required scope: channel:manage:redemptions
539
- # broadcaster_id must match the currently authenticated user
540
- # Status can be FULFILLED or CANCELED
541
- @client.custom_reward_redemptions.update broadcaster_id: 123, reward_id: 321, redemption_id: 123, status: "FULFILLED"
542
- ```
543
-
544
- ### Unban Requests
545
-
546
- ```ruby
547
- # Retrieves a list of Unban Requests for a broadcaster
548
- # Required scope: moderator:read:unban_requests or moderator:manage:unban_requests
549
- # moderator_id must match the currently authenticated user
550
- @client.unban_requests.list broadcaster_id: 123, moderator_id: 123, status: "pending"
551
-
552
- # Resolve an Unban Request
553
- # Required scope: moderator:manage:unban_requests
554
- # moderator_id must match the currently authenticated user
555
- @client.unban_requests.resolve broadcaster_id: 123, moderator_id: 123, id: "abc123", status: "approved"
556
- ```
557
-
558
- ### Warnings
559
-
560
- ```ruby
561
- # Sends a warning to a user
562
- # Required scope: moderator:manage:warnings
563
- # moderator_id must match the currently authenticated user
564
- @client.warnings.create broadcaster_id: 123, moderator_id: 123, user_id: 321, reason: "dont do that"
115
+ # Add an item to the queue
116
+ @client.player.add_to_queue(uri: "spotify:track:1k2pQc5i348DCHwbn5KTdc")
117
+ @client.player.add_to_queue(uri: "spotify:track:1k2pQc5i348DCHwbn5KTdc", device: "abc123")
565
118
  ```
566
119
 
567
120
 
@@ -42,5 +42,15 @@ module Spotify
42
42
  response = post_request("me/player/previous", body: { device_id: device }.compact)
43
43
  response.success?
44
44
  end
45
+
46
+ def queue
47
+ response = get_request("me/player/queue")
48
+ Collection.from_response(response, type: Track, key: "queue")
49
+ end
50
+
51
+ def add_to_queue(uri:, device: nil)
52
+ response = post_request("me/player/queue?uri=#{uri}&device=#{device}", body: nil)
53
+ response.success?
54
+ end
45
55
  end
46
56
  end
@@ -6,7 +6,7 @@ module Spotify
6
6
  end
7
7
  def get(id:, **params)
8
8
  response = get_request("tracks/#{id}", params: params)
9
- Playlist.new response.body
9
+ Track.new response.body
10
10
  end
11
11
  end
12
12
  end
@@ -1,3 +1,3 @@
1
1
  module Spotify
2
- VERSION = "0.1.1"
2
+ VERSION = "0.1.3"
3
3
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: spotifyrb
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Dean Perry
8
8
  bindir: exe
9
9
  cert_chain: []
10
- date: 1980-01-02 00:00:00.000000000 Z
10
+ date: 2025-06-15 00:00:00.000000000 Z
11
11
  dependencies:
12
12
  - !ruby/object:Gem::Dependency
13
13
  name: faraday
@@ -61,7 +61,6 @@ files:
61
61
  - lib/spotify/collection.rb
62
62
  - lib/spotify/error.rb
63
63
  - lib/spotify/error_generator.rb
64
- - lib/spotify/oauth.rb
65
64
  - lib/spotify/object.rb
66
65
  - lib/spotify/objects/album.rb
67
66
  - lib/spotify/objects/artist.rb
@@ -106,7 +105,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
106
105
  - !ruby/object:Gem::Version
107
106
  version: '0'
108
107
  requirements: []
109
- rubygems_version: 3.6.9
108
+ rubygems_version: 3.6.2
110
109
  specification_version: 4
111
110
  summary: A Ruby library for interacting with the Spotify API
112
111
  test_files: []
data/lib/spotify/oauth.rb DELETED
@@ -1,61 +0,0 @@
1
- module Spotify
2
- class OAuth
3
- attr_reader :client_id, :client_secret
4
-
5
- def initialize(client_id:, client_secret:)
6
- @client_id = client_id
7
- @client_secret = client_secret
8
- end
9
-
10
- def create(grant_type:, scope: nil)
11
- send_request(url: "https://id.spotify.tv/oauth2/token", body: {
12
- client_id: client_id,
13
- client_secret: client_secret,
14
- grant_type: grant_type,
15
- scope: scope
16
- })
17
- end
18
-
19
- def refresh(refresh_token:)
20
- send_request(url: "https://id.spotify.tv/oauth2/token", body: {
21
- client_id: client_id,
22
- client_secret: client_secret,
23
- grant_type: "refresh_token",
24
- refresh_token: refresh_token
25
- })
26
- end
27
-
28
- def device(scopes:)
29
- send_request(url: "https://id.spotify.tv/oauth2/device", body: { client_id: client_id, scope: scopes })
30
- end
31
-
32
- def validate(token:)
33
- response = Faraday.get("https://id.spotify.tv/oauth2/validate", nil, { "Authorization" => "OAuth #{token}" })
34
-
35
- return false if response.status != 200
36
-
37
- JSON.parse(response.body, object_class: OpenStruct)
38
- end
39
-
40
- def revoke(token:)
41
- response = Faraday.post("https://id.spotify.tv/oauth2/revoke", {
42
- client_id: client_id,
43
- token: token
44
- })
45
-
46
- JSON.parse(response.body, object_class: OpenStruct) if response.status != 200
47
-
48
- true
49
- end
50
-
51
- private
52
-
53
- def send_request(url:, body:)
54
- response = Faraday.post(url, body)
55
-
56
- return false if response.status != 200
57
-
58
- JSON.parse(response.body, object_class: OpenStruct)
59
- end
60
- end
61
- end