spotifyrb 0.1.0 → 0.1.2
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 +4 -4
- data/.github/workflows/ci.yml +1 -1
- data/Gemfile.lock +58 -53
- data/README.md +60 -507
- data/lib/spotify/client.rb +4 -0
- data/lib/spotify/resources/player.rb +10 -0
- data/lib/spotify/resources/tracks.rb +12 -0
- data/lib/spotify/version.rb +1 -1
- data/lib/spotify.rb +1 -0
- metadata +4 -4
- data/lib/spotify/oauth.rb +0 -61
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: bdc175911b05f2c8df36242ceaed1f830b81daa422181f89ce3320fb67cbb572
|
|
4
|
+
data.tar.gz: d5a2a2e63e88069c8699db2e676cfb8381c2d62e93bf9bf9666e076021fb475f
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: db8b783bfd2e15994c690242ae4daae545eb1fe9b432353666a4b336ef5424319c03d0e7300c5313af4ed4b3ddf8dcc3afcfe9ac041d611438254d569a2864ff
|
|
7
|
+
data.tar.gz: cac9e7127f748a3c9749dd784f59c277651e683691e9052b82a03bc73f23a1d2df99f7ca48d642184aabec54204aa97325f4dde33a17107621516414bf7afd4b
|
data/.github/workflows/ci.yml
CHANGED
data/Gemfile.lock
CHANGED
|
@@ -1,112 +1,117 @@
|
|
|
1
1
|
PATH
|
|
2
2
|
remote: .
|
|
3
3
|
specs:
|
|
4
|
-
spotifyrb (0.1.
|
|
4
|
+
spotifyrb (0.1.2)
|
|
5
5
|
faraday (~> 2.11)
|
|
6
6
|
ostruct (~> 0.6.0)
|
|
7
7
|
|
|
8
8
|
GEM
|
|
9
9
|
remote: https://rubygems.org/
|
|
10
10
|
specs:
|
|
11
|
-
activesupport (
|
|
11
|
+
activesupport (8.0.2)
|
|
12
12
|
base64
|
|
13
|
+
benchmark (>= 0.3)
|
|
13
14
|
bigdecimal
|
|
14
|
-
concurrent-ruby (~> 1.0, >= 1.
|
|
15
|
+
concurrent-ruby (~> 1.0, >= 1.3.1)
|
|
15
16
|
connection_pool (>= 2.2.5)
|
|
16
17
|
drb
|
|
17
18
|
i18n (>= 1.6, < 2)
|
|
19
|
+
logger (>= 1.4.2)
|
|
18
20
|
minitest (>= 5.1)
|
|
19
|
-
|
|
20
|
-
tzinfo (~> 2.0)
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
21
|
+
securerandom (>= 0.3)
|
|
22
|
+
tzinfo (~> 2.0, >= 2.0.5)
|
|
23
|
+
uri (>= 0.13.1)
|
|
24
|
+
ast (2.4.3)
|
|
25
|
+
base64 (0.3.0)
|
|
26
|
+
benchmark (0.4.1)
|
|
27
|
+
bigdecimal (3.2.2)
|
|
28
|
+
concurrent-ruby (1.3.5)
|
|
29
|
+
connection_pool (2.5.3)
|
|
26
30
|
date (3.4.1)
|
|
27
|
-
dotenv (3.1.
|
|
28
|
-
drb (2.2.
|
|
31
|
+
dotenv (3.1.8)
|
|
32
|
+
drb (2.2.3)
|
|
29
33
|
erb (5.0.1)
|
|
30
34
|
faraday (2.13.1)
|
|
31
35
|
faraday-net_http (>= 2.0, < 3.5)
|
|
32
36
|
json
|
|
33
37
|
logger
|
|
34
|
-
faraday-net_http (3.
|
|
35
|
-
net-http
|
|
36
|
-
i18n (1.14.
|
|
38
|
+
faraday-net_http (3.4.0)
|
|
39
|
+
net-http (>= 0.5.0)
|
|
40
|
+
i18n (1.14.7)
|
|
37
41
|
concurrent-ruby (~> 1.0)
|
|
38
42
|
io-console (0.8.0)
|
|
39
43
|
irb (1.15.2)
|
|
40
44
|
pp (>= 0.6.0)
|
|
41
45
|
rdoc (>= 4.0.0)
|
|
42
46
|
reline (>= 0.4.2)
|
|
43
|
-
json (2.
|
|
44
|
-
language_server-protocol (3.17.0.
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
net-http (0.
|
|
47
|
+
json (2.12.2)
|
|
48
|
+
language_server-protocol (3.17.0.5)
|
|
49
|
+
lint_roller (1.1.0)
|
|
50
|
+
logger (1.7.0)
|
|
51
|
+
minitest (5.25.5)
|
|
52
|
+
net-http (0.6.0)
|
|
49
53
|
uri
|
|
50
54
|
ostruct (0.6.1)
|
|
51
|
-
parallel (1.
|
|
52
|
-
parser (3.3.
|
|
55
|
+
parallel (1.27.0)
|
|
56
|
+
parser (3.3.8.0)
|
|
53
57
|
ast (~> 2.4.1)
|
|
54
58
|
racc
|
|
55
59
|
pp (0.6.2)
|
|
56
60
|
prettyprint
|
|
57
61
|
prettyprint (0.2.0)
|
|
62
|
+
prism (1.4.0)
|
|
58
63
|
psych (5.2.6)
|
|
59
64
|
date
|
|
60
65
|
stringio
|
|
61
66
|
racc (1.8.1)
|
|
62
|
-
rack (3.1.
|
|
67
|
+
rack (3.1.16)
|
|
63
68
|
rainbow (3.1.1)
|
|
64
69
|
rake (12.3.3)
|
|
65
70
|
rdoc (6.14.0)
|
|
66
71
|
erb
|
|
67
72
|
psych (>= 4.0.0)
|
|
68
|
-
regexp_parser (2.
|
|
73
|
+
regexp_parser (2.10.0)
|
|
69
74
|
reline (0.6.1)
|
|
70
75
|
io-console (~> 0.5)
|
|
71
|
-
|
|
72
|
-
strscan
|
|
73
|
-
rubocop (1.65.1)
|
|
76
|
+
rubocop (1.76.1)
|
|
74
77
|
json (~> 2.3)
|
|
75
|
-
language_server-protocol (
|
|
78
|
+
language_server-protocol (~> 3.17.0.2)
|
|
79
|
+
lint_roller (~> 1.1.0)
|
|
76
80
|
parallel (~> 1.10)
|
|
77
81
|
parser (>= 3.3.0.2)
|
|
78
82
|
rainbow (>= 2.2.2, < 4.0)
|
|
79
|
-
regexp_parser (>= 2.
|
|
80
|
-
|
|
81
|
-
rubocop-ast (>= 1.31.1, < 2.0)
|
|
83
|
+
regexp_parser (>= 2.9.3, < 3.0)
|
|
84
|
+
rubocop-ast (>= 1.45.0, < 2.0)
|
|
82
85
|
ruby-progressbar (~> 1.7)
|
|
83
|
-
unicode-display_width (>= 2.4.0, <
|
|
84
|
-
rubocop-ast (1.
|
|
85
|
-
parser (>= 3.3.
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
rubocop (>= 1.
|
|
91
|
-
|
|
92
|
-
rubocop-rails (2.25.1)
|
|
86
|
+
unicode-display_width (>= 2.4.0, < 4.0)
|
|
87
|
+
rubocop-ast (1.45.1)
|
|
88
|
+
parser (>= 3.3.7.2)
|
|
89
|
+
prism (~> 1.4)
|
|
90
|
+
rubocop-performance (1.25.0)
|
|
91
|
+
lint_roller (~> 1.1)
|
|
92
|
+
rubocop (>= 1.75.0, < 2.0)
|
|
93
|
+
rubocop-ast (>= 1.38.0, < 2.0)
|
|
94
|
+
rubocop-rails (2.32.0)
|
|
93
95
|
activesupport (>= 4.2.0)
|
|
96
|
+
lint_roller (~> 1.1)
|
|
94
97
|
rack (>= 1.1)
|
|
95
|
-
rubocop (>= 1.
|
|
96
|
-
rubocop-ast (>= 1.
|
|
97
|
-
rubocop-rails-omakase (1.
|
|
98
|
-
rubocop
|
|
99
|
-
rubocop-
|
|
100
|
-
rubocop-
|
|
101
|
-
rubocop-rails
|
|
98
|
+
rubocop (>= 1.75.0, < 2.0)
|
|
99
|
+
rubocop-ast (>= 1.44.0, < 2.0)
|
|
100
|
+
rubocop-rails-omakase (1.1.0)
|
|
101
|
+
rubocop (>= 1.72)
|
|
102
|
+
rubocop-performance (>= 1.24)
|
|
103
|
+
rubocop-rails (>= 2.30)
|
|
102
104
|
ruby-progressbar (1.13.0)
|
|
105
|
+
securerandom (0.4.1)
|
|
103
106
|
stringio (3.1.7)
|
|
104
|
-
strscan (3.1.0)
|
|
105
107
|
tzinfo (2.0.6)
|
|
106
108
|
concurrent-ruby (~> 1.0)
|
|
107
|
-
unicode-display_width (
|
|
108
|
-
|
|
109
|
-
|
|
109
|
+
unicode-display_width (3.1.4)
|
|
110
|
+
unicode-emoji (~> 4.0, >= 4.0.4)
|
|
111
|
+
unicode-emoji (4.0.4)
|
|
112
|
+
uri (1.0.3)
|
|
113
|
+
vcr (6.3.1)
|
|
114
|
+
base64
|
|
110
115
|
|
|
111
116
|
PLATFORMS
|
|
112
117
|
ruby
|
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
|
|
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::
|
|
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
|
-
###
|
|
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
|
-
|
|
41
|
-
|
|
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
|
-
#
|
|
93
|
-
@
|
|
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
|
-
#
|
|
100
|
-
@client.users.
|
|
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
|
-
|
|
199
|
-
|
|
200
|
-
|
|
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
|
-
###
|
|
52
|
+
### Playlists
|
|
214
53
|
|
|
215
54
|
```ruby
|
|
216
|
-
#
|
|
217
|
-
@client.
|
|
55
|
+
# Get a Playlist
|
|
56
|
+
@client.playlists.get(id: "abc123")
|
|
218
57
|
|
|
219
|
-
#
|
|
220
|
-
@client.
|
|
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
|
-
#
|
|
223
|
-
@client.
|
|
224
|
-
```
|
|
63
|
+
# Update a Playlist
|
|
64
|
+
@client.playlists.update(id: "abc123", name: "A name change")
|
|
225
65
|
|
|
226
|
-
|
|
66
|
+
# Get the tracks on a Playlist
|
|
67
|
+
@client.playlists.tracks(id: "abc123")
|
|
68
|
+
@client.playlists.tracks(id: "abc123", market: "GB")
|
|
227
69
|
|
|
228
|
-
|
|
229
|
-
#
|
|
230
|
-
|
|
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
|
-
#
|
|
233
|
-
@client.
|
|
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
|
-
###
|
|
82
|
+
### Player
|
|
237
83
|
|
|
238
84
|
```ruby
|
|
239
|
-
#
|
|
240
|
-
@client.
|
|
85
|
+
# Get the Player state
|
|
86
|
+
@client.player.state
|
|
87
|
+
@client.player.state(market: "GB")
|
|
241
88
|
|
|
242
|
-
#
|
|
243
|
-
|
|
244
|
-
@client.games.retrieve(ids: [66402, 514974])
|
|
89
|
+
# Get the Player Devices
|
|
90
|
+
@client.player.devices
|
|
245
91
|
|
|
246
|
-
#
|
|
247
|
-
@client.
|
|
92
|
+
# Get the current playing song
|
|
93
|
+
@client.player.playing
|
|
94
|
+
@client.player.playing(market: "GB")
|
|
248
95
|
|
|
249
|
-
#
|
|
250
|
-
|
|
251
|
-
@client.
|
|
252
|
-
```
|
|
96
|
+
# Start/Resume Playback
|
|
97
|
+
@client.player.play
|
|
98
|
+
@client.player.play(device: "abc123")
|
|
253
99
|
|
|
254
|
-
|
|
100
|
+
# Pause Playback
|
|
101
|
+
@client.player.pause
|
|
102
|
+
@client.player.pause(device: "abc123")
|
|
255
103
|
|
|
256
|
-
|
|
104
|
+
# Skip to next
|
|
105
|
+
@client.player.next
|
|
106
|
+
@client.player.next(device: "abc123")
|
|
257
107
|
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
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
|
-
|
|
112
|
+
# Get the player queue
|
|
113
|
+
@client.player.queue
|
|
279
114
|
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
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
|
|
data/lib/spotify/client.rb
CHANGED
|
@@ -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
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
module Spotify
|
|
2
|
+
class TracksResource < Resource
|
|
3
|
+
def list(ids:, **params)
|
|
4
|
+
response = get_request("tracks", params: { ids: ids }.merge(params))
|
|
5
|
+
Collection.from_response(response, type: Track, key: "tracks")
|
|
6
|
+
end
|
|
7
|
+
def get(id:, **params)
|
|
8
|
+
response = get_request("tracks/#{id}", params: params)
|
|
9
|
+
Playlist.new response.body
|
|
10
|
+
end
|
|
11
|
+
end
|
|
12
|
+
end
|
data/lib/spotify/version.rb
CHANGED
data/lib/spotify.rb
CHANGED
|
@@ -21,6 +21,7 @@ module Spotify
|
|
|
21
21
|
autoload :AlbumsResource, "spotify/resources/albums"
|
|
22
22
|
autoload :ArtistsResource, "spotify/resources/artists"
|
|
23
23
|
autoload :PlaylistsResource, "spotify/resources/playlists"
|
|
24
|
+
autoload :TracksResource, "spotify/resources/tracks"
|
|
24
25
|
|
|
25
26
|
autoload :User, "spotify/objects/user"
|
|
26
27
|
autoload :Album, "spotify/objects/album"
|
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.
|
|
4
|
+
version: 0.1.2
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Dean Perry
|
|
8
8
|
bindir: exe
|
|
9
9
|
cert_chain: []
|
|
10
|
-
date:
|
|
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
|
|
@@ -81,6 +80,7 @@ files:
|
|
|
81
80
|
- lib/spotify/resources/player.rb
|
|
82
81
|
- lib/spotify/resources/playlists.rb
|
|
83
82
|
- lib/spotify/resources/search.rb
|
|
83
|
+
- lib/spotify/resources/tracks.rb
|
|
84
84
|
- lib/spotify/resources/users.rb
|
|
85
85
|
- lib/spotify/version.rb
|
|
86
86
|
- lib/spotifyrb.rb
|
|
@@ -105,7 +105,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
105
105
|
- !ruby/object:Gem::Version
|
|
106
106
|
version: '0'
|
|
107
107
|
requirements: []
|
|
108
|
-
rubygems_version: 3.6.
|
|
108
|
+
rubygems_version: 3.6.2
|
|
109
109
|
specification_version: 4
|
|
110
110
|
summary: A Ruby library for interacting with the Spotify API
|
|
111
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
|