streamelements 0.2.0 → 0.5.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +43 -33
- data/lib/stream_elements/client.rb +28 -55
- data/lib/stream_elements/collection.rb +12 -0
- data/lib/stream_elements/error_generator.rb +128 -0
- data/lib/stream_elements/objects/activity.rb +4 -0
- data/lib/stream_elements/objects/song_request.rb +4 -0
- data/lib/stream_elements/objects/tip.rb +4 -0
- data/lib/stream_elements/objects/top_tip.rb +4 -0
- data/lib/stream_elements/objects/user.rb +4 -0
- data/lib/stream_elements/resource.rb +47 -0
- data/lib/stream_elements/resources/activities.rb +17 -0
- data/lib/stream_elements/resources/channels.rb +10 -0
- data/lib/stream_elements/resources/song_requests.rb +52 -0
- data/lib/stream_elements/resources/tips.rb +20 -0
- data/lib/stream_elements/resources/users.rb +15 -0
- data/lib/stream_elements/version.rb +1 -1
- data/lib/stream_elements.rb +18 -19
- metadata +20 -13
- data/lib/stream_elements/configuration.rb +0 -13
- data/lib/stream_elements/models/activity.rb +0 -21
- data/lib/stream_elements/models/song_request.rb +0 -56
- data/lib/stream_elements/models/tip.rb +0 -23
- data/lib/stream_elements/models/user.rb +0 -19
- /data/lib/stream_elements/{models → objects}/channel.rb +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 83d2ea9888a42229e5016f02f1dc44bc4bbb6dcd8e2518f18f205665af4085d5
|
4
|
+
data.tar.gz: 693b8d5938293d15a82eada641f6f1f4de021eaad7a68457d9bc2e179d7bd3db
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f76b12a8c58996a31cfdc3849e237c6d4b1c4ded028cfe7bcba7a60379aa2e864d5dfd7191cb8677fbf06594c0a3284cfa0a5039a903579e717378d328ef04dc
|
7
|
+
data.tar.gz: b71d769c436f467bf3405df589f2ac8d8eb2fa44e06b1e3a040b69a2ab7e2582d3203e7f21730bae46b2deac81d43f863e05316851765a37339eb99d21f7ab83
|
data/README.md
CHANGED
@@ -12,27 +12,50 @@ gem "streamelements"
|
|
12
12
|
|
13
13
|
## Usage
|
14
14
|
|
15
|
-
###
|
15
|
+
### Set Client Details
|
16
16
|
|
17
|
-
Firstly you'll need to
|
17
|
+
Firstly you'll need to the access token, which can be an oAuth Token or JWT.
|
18
18
|
|
19
19
|
```ruby
|
20
|
-
StreamElements.
|
21
|
-
config.token = ENV["STREAMELEMENTS_JWT_TOKEN"]
|
22
|
-
config.channel = ENV["STREAMELEMENTS_CHANNEL_ID"]
|
23
|
-
end
|
20
|
+
@client = StreamElements::Client.new(access_token: "abc123")
|
24
21
|
```
|
25
22
|
|
23
|
+
### Resources
|
24
|
+
|
25
|
+
The gem maps as closely as we can to the StreamElements API so you can easily convert API examples to gem code.
|
26
|
+
|
27
|
+
Responses are created as objects like `StreamElements::Channel`. Having types like `StreamElements::User` is handy for understanding what
|
28
|
+
type of object you're working with. They're built using OpenStruct so you can easily access data in a Ruby-ish way.
|
29
|
+
|
30
|
+
### Channels
|
31
|
+
|
32
|
+
```ruby
|
33
|
+
# Get the current channel
|
34
|
+
@client.channels.me
|
35
|
+
```
|
36
|
+
|
37
|
+
|
38
|
+
### Users
|
39
|
+
|
40
|
+
```ruby
|
41
|
+
# Get the current user
|
42
|
+
@client.users.current
|
43
|
+
|
44
|
+
# Get the users Channels
|
45
|
+
@client.users.channels
|
46
|
+
```
|
47
|
+
|
48
|
+
|
26
49
|
### Activities
|
27
50
|
|
28
51
|
```ruby
|
29
52
|
# Retrieve a list of Activities
|
30
53
|
# https://dev.streamelements.com/docs/api-docs/861a5d5450bbb-channel
|
31
|
-
|
54
|
+
@client.activities.list(channel: "channel-id", after:, before:, limit:, types:)
|
32
55
|
|
33
56
|
# Retrieve the Top Activities
|
34
57
|
# https://dev.streamelements.com/docs/api-docs/2ce44d058b16b-channel-top
|
35
|
-
|
58
|
+
@client.activities.top(channel: "channel-id", period:, offset:, limit:, type:)
|
36
59
|
```
|
37
60
|
|
38
61
|
### Tips
|
@@ -40,61 +63,48 @@ StreamElements::Activity.top
|
|
40
63
|
```ruby
|
41
64
|
# Retrieve a list of Tips
|
42
65
|
# https://dev.streamelements.com/docs/api-docs/704e5580be2d9-channel
|
43
|
-
|
66
|
+
@client.tips.list(channel: "channel-id", after: "2024-01-01", sort: "createdAt", limit: 10)
|
44
67
|
|
45
68
|
# Retrieve a Tip
|
46
|
-
|
69
|
+
@client.tips.retrieve(channel: "channel-id", id: "tip-id")
|
47
70
|
|
48
71
|
# Retrieve the Tip Tips
|
49
72
|
# https://dev.streamelements.com/docs/api-docs/b404f906817c4-channel-top
|
50
|
-
|
73
|
+
@client.tips.top(channel: "channel-id")
|
51
74
|
```
|
52
75
|
|
53
76
|
### Song Requests
|
54
77
|
|
55
78
|
```ruby
|
56
79
|
# Retrieve the current playing song
|
57
|
-
|
80
|
+
@client.song_requests.playing(channel: "channel-id")
|
58
81
|
|
59
82
|
# Retrieve a list of songs in the queue
|
60
|
-
|
61
|
-
|
62
|
-
# Retrieve a list of previous songs
|
63
|
-
StreamElements::SongRequest.queue
|
83
|
+
@client.song_requests.queue(channel: "channel-id")
|
64
84
|
|
65
85
|
# Add a song to the queue
|
66
86
|
# video is the YouTube video ID or URL
|
67
|
-
|
87
|
+
@client.song_requests.add(channel: "channel-id", video: "video-id")
|
68
88
|
|
69
89
|
# Pause the player
|
70
|
-
|
90
|
+
@client.song_requests.pause(channel: "channel-id")
|
71
91
|
|
72
92
|
# Resume the player
|
73
|
-
|
93
|
+
@client.song_requests.play(channel: "channel-id")
|
74
94
|
|
75
95
|
# Set the volume of the player
|
76
96
|
# volume is a number between 0 and 100
|
77
|
-
|
97
|
+
@client.song_requests.volume(channel: "channel-id", volume: 50)
|
78
98
|
|
79
99
|
# Skip the current song
|
80
|
-
|
100
|
+
@client.song_requests.skip(channel: "channel-id")
|
81
101
|
|
82
102
|
# Get the current song request settings
|
83
|
-
|
103
|
+
@client.song_requests.settings(channel: "channel-id")
|
84
104
|
|
85
105
|
# Set the current song request settings
|
86
106
|
# settings is a hash of settings
|
87
|
-
|
88
|
-
```
|
89
|
-
|
90
|
-
### Users
|
91
|
-
|
92
|
-
```ruby
|
93
|
-
# Get the current user
|
94
|
-
StreamElements::User.current
|
95
|
-
|
96
|
-
# Get the users Channels
|
97
|
-
StreamElements::User.channels
|
107
|
+
@client.song_requests.update_settings(channel: "channel-id", settings: { max_requests: 5 })
|
98
108
|
```
|
99
109
|
|
100
110
|
## Contributing
|
@@ -1,74 +1,47 @@
|
|
1
1
|
module StreamElements
|
2
2
|
class Client
|
3
3
|
|
4
|
-
|
4
|
+
BASE_URL = "https://api.streamelements.com/kappa/v2"
|
5
5
|
|
6
|
-
|
7
|
-
@connection ||= Faraday.new("https://api.streamelements.com/kappa/v2") do |conn|
|
8
|
-
conn.request :authorization, :Bearer, StreamElements.config.token
|
6
|
+
attr_reader :access_token
|
9
7
|
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
conn.request :json
|
8
|
+
def initialize(access_token:)
|
9
|
+
@access_token = access_token
|
10
|
+
end
|
15
11
|
|
16
|
-
|
17
|
-
|
18
|
-
|
12
|
+
def channels
|
13
|
+
ChannelsResource.new(self)
|
14
|
+
end
|
19
15
|
|
16
|
+
def users
|
17
|
+
UsersResource.new(self)
|
18
|
+
end
|
20
19
|
|
21
|
-
|
22
|
-
|
23
|
-
|
20
|
+
def activities
|
21
|
+
ActivitiesResource.new(self)
|
22
|
+
end
|
24
23
|
|
25
|
-
|
26
|
-
|
27
|
-
|
24
|
+
def tips
|
25
|
+
TipsResource.new(self)
|
26
|
+
end
|
28
27
|
|
29
|
-
|
30
|
-
|
31
|
-
|
28
|
+
def song_requests
|
29
|
+
SongRequestsResource.new(self)
|
30
|
+
end
|
32
31
|
|
33
|
-
def patch_request(url, body:, headers: {})
|
34
|
-
handle_response connection.patch(replace_channel(url), body, headers)
|
35
|
-
end
|
36
32
|
|
37
|
-
|
38
|
-
|
39
|
-
|
33
|
+
def connection
|
34
|
+
@connection ||= Faraday.new(BASE_URL) do |conn|
|
35
|
+
conn.request :authorization, :Bearer, access_token
|
40
36
|
|
41
|
-
|
42
|
-
|
43
|
-
|
37
|
+
conn.headers = {
|
38
|
+
"User-Agent" => "streamelements/v#{VERSION} (github.com/deanpcmad/streamelements)"
|
39
|
+
}
|
44
40
|
|
45
|
-
|
46
|
-
case response.status
|
47
|
-
when 400
|
48
|
-
raise Error, "Error 400: Your request was malformed. '#{response.body["error"]}'"
|
49
|
-
when 401
|
50
|
-
raise Error, "Error 401: You did not supply valid authentication credentials. '#{response.body["error"]}'"
|
51
|
-
when 403
|
52
|
-
raise Error, "Error 403: You are not allowed to perform that action. '#{response.body["error"]}'"
|
53
|
-
when 404
|
54
|
-
raise Error, "Error 404: No results were found for your request. '#{response.body["error"]}'"
|
55
|
-
when 409
|
56
|
-
raise Error, "Error 409: Your request was a conflict. '#{response.body["error"]}'"
|
57
|
-
when 429
|
58
|
-
raise Error, "Error 429: Your request exceeded the API rate limit. '#{response.body["error"]}'"
|
59
|
-
when 500
|
60
|
-
raise Error, "Error 500: We were unable to perform the request due to server-side problems. '#{response.body["error"]}'"
|
61
|
-
when 503
|
62
|
-
raise Error, "Error 503: You have been rate limited for sending more than 20 requests per second. '#{response.body["error"]}'"
|
63
|
-
when 501
|
64
|
-
raise Error, "Error 501: This resource has not been implemented. '#{response.body["error"]}'"
|
65
|
-
when 204
|
66
|
-
return true
|
67
|
-
end
|
41
|
+
conn.request :json
|
68
42
|
|
69
|
-
response
|
43
|
+
conn.response :json, content_type: "application/json"
|
70
44
|
end
|
71
|
-
|
72
45
|
end
|
73
46
|
|
74
47
|
end
|
@@ -0,0 +1,128 @@
|
|
1
|
+
module StreamElements
|
2
|
+
class ErrorGenerator < StandardError
|
3
|
+
attr_reader :http_status_code
|
4
|
+
attr_reader :error_code
|
5
|
+
attr_reader :error_message
|
6
|
+
|
7
|
+
def initialize(response_body, http_status_code)
|
8
|
+
@response_body = response_body
|
9
|
+
@http_status_code = http_status_code
|
10
|
+
set_error_values
|
11
|
+
super(build_message)
|
12
|
+
end
|
13
|
+
|
14
|
+
private
|
15
|
+
|
16
|
+
def set_error_values
|
17
|
+
@error_code = @response_body.dig("error")
|
18
|
+
@error_message = @response_body.dig("message")
|
19
|
+
end
|
20
|
+
|
21
|
+
def error_message
|
22
|
+
@error_message || @response_body.dig("error")
|
23
|
+
rescue NoMethodError
|
24
|
+
"An unknown error occurred."
|
25
|
+
end
|
26
|
+
|
27
|
+
def build_message
|
28
|
+
if error_code.nil?
|
29
|
+
return "Error #{@http_status_code}: #{error_message}"
|
30
|
+
end
|
31
|
+
"Error #{@http_status_code}: #{error_message} '#{error_message}'"
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
module Errors
|
36
|
+
class BadRequestError < ErrorGenerator
|
37
|
+
private
|
38
|
+
|
39
|
+
def error_message
|
40
|
+
"Your request was malformed."
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
class AuthenticationMissingError < ErrorGenerator
|
45
|
+
private
|
46
|
+
|
47
|
+
def error_message
|
48
|
+
"You did not supply valid authentication credentials."
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
52
|
+
class ForbiddenError < ErrorGenerator
|
53
|
+
private
|
54
|
+
|
55
|
+
def error_message
|
56
|
+
"You are not allowed to perform that action."
|
57
|
+
end
|
58
|
+
end
|
59
|
+
|
60
|
+
class EntityNotFoundError < ErrorGenerator
|
61
|
+
private
|
62
|
+
|
63
|
+
def error_message
|
64
|
+
"No results were found for your request."
|
65
|
+
end
|
66
|
+
end
|
67
|
+
|
68
|
+
class ConflictError < ErrorGenerator
|
69
|
+
private
|
70
|
+
|
71
|
+
def error_message
|
72
|
+
"Your request was a conflict."
|
73
|
+
end
|
74
|
+
end
|
75
|
+
|
76
|
+
class TooManyRequestsError < ErrorGenerator
|
77
|
+
private
|
78
|
+
|
79
|
+
def error_message
|
80
|
+
"Your request exceeded the API rate limit."
|
81
|
+
end
|
82
|
+
end
|
83
|
+
|
84
|
+
class InternalError < ErrorGenerator
|
85
|
+
private
|
86
|
+
|
87
|
+
def error_message
|
88
|
+
"We were unable to perform the request due to server-side problems."
|
89
|
+
end
|
90
|
+
end
|
91
|
+
|
92
|
+
class ServiceUnavailableError < ErrorGenerator
|
93
|
+
private
|
94
|
+
|
95
|
+
def error_message
|
96
|
+
"You have been rate limited for sending more than 20 requests per second."
|
97
|
+
end
|
98
|
+
end
|
99
|
+
|
100
|
+
class NotImplementedError < ErrorGenerator
|
101
|
+
private
|
102
|
+
|
103
|
+
def error_message
|
104
|
+
"This resource has not been implemented."
|
105
|
+
end
|
106
|
+
end
|
107
|
+
end
|
108
|
+
|
109
|
+
class ErrorFactory
|
110
|
+
HTTP_ERROR_MAP = {
|
111
|
+
400 => Errors::BadRequestError,
|
112
|
+
401 => Errors::AuthenticationMissingError,
|
113
|
+
403 => Errors::ForbiddenError,
|
114
|
+
404 => Errors::EntityNotFoundError,
|
115
|
+
409 => Errors::ConflictError,
|
116
|
+
429 => Errors::TooManyRequestsError,
|
117
|
+
500 => Errors::InternalError,
|
118
|
+
503 => Errors::ServiceUnavailableError,
|
119
|
+
501 => Errors::NotImplementedError
|
120
|
+
}.freeze
|
121
|
+
|
122
|
+
def self.create(response_body, http_status_code)
|
123
|
+
status = http_status_code
|
124
|
+
error_class = HTTP_ERROR_MAP[status] || ErrorGenerator
|
125
|
+
error_class.new(response_body, http_status_code) if error_class
|
126
|
+
end
|
127
|
+
end
|
128
|
+
end
|
@@ -0,0 +1,47 @@
|
|
1
|
+
module StreamElements
|
2
|
+
class Resource
|
3
|
+
attr_reader :client
|
4
|
+
|
5
|
+
def initialize(client)
|
6
|
+
@client = client
|
7
|
+
end
|
8
|
+
|
9
|
+
private
|
10
|
+
|
11
|
+
def get_request(url, params: {}, headers: {})
|
12
|
+
handle_response client.connection.get(url, params, headers)
|
13
|
+
end
|
14
|
+
|
15
|
+
def post_request(url, body: {}, headers: {})
|
16
|
+
handle_response client.connection.post(url, body, headers)
|
17
|
+
end
|
18
|
+
|
19
|
+
def put_request(url, body: {}, headers: {})
|
20
|
+
handle_response client.connection.put(url, body, headers)
|
21
|
+
end
|
22
|
+
|
23
|
+
def patch_request(url, body:, headers: {})
|
24
|
+
handle_response client.connection.patch(url, body, headers)
|
25
|
+
end
|
26
|
+
|
27
|
+
def delete_request(url, headers: {})
|
28
|
+
handle_response client.connection.delete(url, headers)
|
29
|
+
end
|
30
|
+
|
31
|
+
def handle_response(response)
|
32
|
+
return true if response.status == 204
|
33
|
+
return response unless error?(response)
|
34
|
+
|
35
|
+
raise_error(response)
|
36
|
+
end
|
37
|
+
|
38
|
+
def error?(response)
|
39
|
+
[ 400, 401, 403, 404, 409, 429, 500, 501, 503 ].include?(response.status) #|| response.body&.key?("error")
|
40
|
+
end
|
41
|
+
|
42
|
+
def raise_error(response)
|
43
|
+
error = StreamElements::ErrorFactory.create(response.body, response.status)
|
44
|
+
raise error if error
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
module StreamElements
|
2
|
+
class ActivitiesResource < Resource
|
3
|
+
|
4
|
+
def list(channel:, after:, before:, limit:, types:, **params)
|
5
|
+
attrs = { after: after, before: before, limit: limit, types: types }.merge(params)
|
6
|
+
response = get_request("activities/#{channel}", params: attrs)
|
7
|
+
Collection.from_response(response, type: Activity)
|
8
|
+
end
|
9
|
+
|
10
|
+
def top(channel:, period:, offset:, limit:, type:)
|
11
|
+
attrs = { period: period, offset: offset, limit: limit, type: type }
|
12
|
+
response = get_request("activities/#{channel}/top", params: attrs)
|
13
|
+
# Collection.from_response(response, type: TopActivity)
|
14
|
+
end
|
15
|
+
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,52 @@
|
|
1
|
+
module StreamElements
|
2
|
+
class SongRequestsResource < Resource
|
3
|
+
|
4
|
+
def playing(channel:)
|
5
|
+
SongRequest.new get_request("songrequest/#{channel}/playing").body
|
6
|
+
end
|
7
|
+
|
8
|
+
def queue(channel:)
|
9
|
+
response = get_request("songrequest/#{channel}/queue")
|
10
|
+
Collection.from_response(response, type: SongRequest)
|
11
|
+
end
|
12
|
+
|
13
|
+
def history(channel:, **params)
|
14
|
+
response = get_request("songrequest/#{channel}/history", params: params)
|
15
|
+
Collection.from_response(response, type: SongRequest, name: "history")
|
16
|
+
end
|
17
|
+
|
18
|
+
def settings(channel:)
|
19
|
+
get_request("songrequest/#{channel}/settings").body
|
20
|
+
end
|
21
|
+
|
22
|
+
def update_settings(channel:, settings:)
|
23
|
+
response = put_request("songrequest/#{channel}/settings", body: settings)
|
24
|
+
response.success?
|
25
|
+
end
|
26
|
+
|
27
|
+
def add(channel:, video:)
|
28
|
+
SongRequest.new post_request("songrequest/#{channel}/queue", body: { video: video }).body
|
29
|
+
end
|
30
|
+
|
31
|
+
def pause(channel:)
|
32
|
+
response = post_request("songrequest/#{channel}/player/pause", body: {})
|
33
|
+
response.success?
|
34
|
+
end
|
35
|
+
|
36
|
+
def play(channel:)
|
37
|
+
response = post_request("songrequest/#{channel}/player/play", body: {})
|
38
|
+
response.success?
|
39
|
+
end
|
40
|
+
|
41
|
+
def volume(channel:, volume:)
|
42
|
+
response = post_request("songrequest/#{channel}/player/volume", body: {volume: volume})
|
43
|
+
response.success?
|
44
|
+
end
|
45
|
+
|
46
|
+
def skip(channel:)
|
47
|
+
response = post_request("songrequest/#{channel}/skip", body: {})
|
48
|
+
response.success?
|
49
|
+
end
|
50
|
+
|
51
|
+
end
|
52
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
module StreamElements
|
2
|
+
class TipsResource < Resource
|
3
|
+
|
4
|
+
def list(channel:, after:, sort:, limit:, **params)
|
5
|
+
attrs = { after: after, sort: sort, limit: limit }.merge(params)
|
6
|
+
response = get_request("tips/#{channel}", params: attrs)
|
7
|
+
Collection.from_response(response, type: Tip, name: "docs")
|
8
|
+
end
|
9
|
+
|
10
|
+
def retrieve(channel:, id:)
|
11
|
+
Tip.new get_request("tips/#{channel}/#{id}").body
|
12
|
+
end
|
13
|
+
|
14
|
+
def top(channel:)
|
15
|
+
response = get_request("tips/#{channel}/top")
|
16
|
+
Collection.from_response(response, type: TopTip)
|
17
|
+
end
|
18
|
+
|
19
|
+
end
|
20
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
module StreamElements
|
2
|
+
class UsersResource < Resource
|
3
|
+
|
4
|
+
def current
|
5
|
+
response = get_request("users/current")
|
6
|
+
User.new response.body
|
7
|
+
end
|
8
|
+
|
9
|
+
def channels
|
10
|
+
response = get_request("users/channels")
|
11
|
+
Collection.from_response(response, type: Channel)
|
12
|
+
end
|
13
|
+
|
14
|
+
end
|
15
|
+
end
|
data/lib/stream_elements.rb
CHANGED
@@ -6,28 +6,27 @@ require "stream_elements/version"
|
|
6
6
|
|
7
7
|
module StreamElements
|
8
8
|
|
9
|
-
autoload :
|
9
|
+
autoload :Error, "stream_elements/error"
|
10
|
+
autoload :Errors, "stream_elements/error_generator"
|
11
|
+
autoload :ErrorGenerator, "stream_elements/error_generator"
|
12
|
+
autoload :ErrorFactory, "stream_elements/error_generator"
|
13
|
+
|
10
14
|
autoload :Client, "stream_elements/client"
|
11
15
|
autoload :Collection, "stream_elements/collection"
|
12
|
-
autoload :
|
16
|
+
autoload :Resource, "stream_elements/resource"
|
13
17
|
autoload :Object, "stream_elements/object"
|
14
18
|
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
autoload :Activity, "stream_elements/models/activity"
|
28
|
-
autoload :Tip, "stream_elements/models/tip"
|
29
|
-
autoload :SongRequest, "stream_elements/models/song_request"
|
30
|
-
autoload :User, "stream_elements/models/user"
|
31
|
-
autoload :Channel, "stream_elements/models/channel"
|
19
|
+
autoload :ActivitiesResource, "stream_elements/resources/activitys"
|
20
|
+
autoload :TipsResource, "stream_elements/resources/tips"
|
21
|
+
autoload :SongRequestsResource, "stream_elements/resources/song_requests"
|
22
|
+
autoload :UsersResource, "stream_elements/resources/users"
|
23
|
+
autoload :ChannelsResource, "stream_elements/resources/channels"
|
24
|
+
|
25
|
+
autoload :Activity, "stream_elements/objects/activity"
|
26
|
+
autoload :Tip, "stream_elements/objects/tip"
|
27
|
+
autoload :SongRequest, "stream_elements/objects/song_request"
|
28
|
+
autoload :User, "stream_elements/objects/user"
|
29
|
+
autoload :Channel, "stream_elements/objects/channel"
|
30
|
+
autoload :TopTip, "stream_elements/objects/top_tip"
|
32
31
|
|
33
32
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: streamelements
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.5.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Dean Perry
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2024-09-01 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: faraday
|
@@ -24,7 +24,7 @@ dependencies:
|
|
24
24
|
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: '2'
|
27
|
-
description:
|
27
|
+
description:
|
28
28
|
email:
|
29
29
|
- deanperry@fastmail.com
|
30
30
|
executables: []
|
@@ -38,14 +38,21 @@ files:
|
|
38
38
|
- lib/stream_elements.rb
|
39
39
|
- lib/stream_elements/client.rb
|
40
40
|
- lib/stream_elements/collection.rb
|
41
|
-
- lib/stream_elements/configuration.rb
|
42
41
|
- lib/stream_elements/error.rb
|
43
|
-
- lib/stream_elements/
|
44
|
-
- lib/stream_elements/models/channel.rb
|
45
|
-
- lib/stream_elements/models/song_request.rb
|
46
|
-
- lib/stream_elements/models/tip.rb
|
47
|
-
- lib/stream_elements/models/user.rb
|
42
|
+
- lib/stream_elements/error_generator.rb
|
48
43
|
- lib/stream_elements/object.rb
|
44
|
+
- lib/stream_elements/objects/activity.rb
|
45
|
+
- lib/stream_elements/objects/channel.rb
|
46
|
+
- lib/stream_elements/objects/song_request.rb
|
47
|
+
- lib/stream_elements/objects/tip.rb
|
48
|
+
- lib/stream_elements/objects/top_tip.rb
|
49
|
+
- lib/stream_elements/objects/user.rb
|
50
|
+
- lib/stream_elements/resource.rb
|
51
|
+
- lib/stream_elements/resources/activities.rb
|
52
|
+
- lib/stream_elements/resources/channels.rb
|
53
|
+
- lib/stream_elements/resources/song_requests.rb
|
54
|
+
- lib/stream_elements/resources/tips.rb
|
55
|
+
- lib/stream_elements/resources/users.rb
|
49
56
|
- lib/stream_elements/version.rb
|
50
57
|
- lib/streamelements.rb
|
51
58
|
- sig/streamelements.rbs
|
@@ -53,7 +60,7 @@ homepage: https://github.com/deanpcmad/streamelements
|
|
53
60
|
licenses:
|
54
61
|
- MIT
|
55
62
|
metadata: {}
|
56
|
-
post_install_message:
|
63
|
+
post_install_message:
|
57
64
|
rdoc_options: []
|
58
65
|
require_paths:
|
59
66
|
- lib
|
@@ -68,8 +75,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
68
75
|
- !ruby/object:Gem::Version
|
69
76
|
version: '0'
|
70
77
|
requirements: []
|
71
|
-
rubygems_version: 3.5.
|
72
|
-
signing_key:
|
78
|
+
rubygems_version: 3.5.11
|
79
|
+
signing_key:
|
73
80
|
specification_version: 4
|
74
81
|
summary: Ruby library for the StreamElements API
|
75
82
|
test_files: []
|
@@ -1,21 +0,0 @@
|
|
1
|
-
module StreamElements
|
2
|
-
class Activity < Object
|
3
|
-
|
4
|
-
class << self
|
5
|
-
|
6
|
-
def list(after:, before:, limit:, types:, **params)
|
7
|
-
attrs = { after: after, before: before, limit: limit, types: types }.merge(params)
|
8
|
-
response = Client.get_request("activities/:channel", params: attrs)
|
9
|
-
Collection.from_response(response, type: Activity)
|
10
|
-
end
|
11
|
-
|
12
|
-
def top(period:, offset:, limit:, type:)
|
13
|
-
attrs = { period: period, offset: offset, limit: limit, type: type }
|
14
|
-
response = Client.get_request("activities/:channel/top", params: attrs)
|
15
|
-
# Collection.from_response(response, type: TopActivity)
|
16
|
-
end
|
17
|
-
|
18
|
-
end
|
19
|
-
|
20
|
-
end
|
21
|
-
end
|
@@ -1,56 +0,0 @@
|
|
1
|
-
module StreamElements
|
2
|
-
class SongRequest < Object
|
3
|
-
|
4
|
-
class << self
|
5
|
-
|
6
|
-
def playing
|
7
|
-
SongRequest.new Client.get_request("songrequest/:channel/playing").body
|
8
|
-
end
|
9
|
-
|
10
|
-
def queue
|
11
|
-
response = Client.get_request("songrequest/:channel/queue")
|
12
|
-
Collection.from_response(response, type: SongRequest)
|
13
|
-
end
|
14
|
-
|
15
|
-
def history(**params)
|
16
|
-
response = Client.get_request("songrequest/:channel/history", params: params)
|
17
|
-
Collection.from_response(response, type: SongRequest, name: "history")
|
18
|
-
end
|
19
|
-
|
20
|
-
def settings
|
21
|
-
Client.get_request("songrequest/:channel/settings").body
|
22
|
-
end
|
23
|
-
|
24
|
-
def update_settings(settings:)
|
25
|
-
response = Client.put_request("songrequest/:channel/settings", body: settings)
|
26
|
-
response.success?
|
27
|
-
end
|
28
|
-
|
29
|
-
def add(video:)
|
30
|
-
SongRequest.new Client.post_request("songrequest/:channel/queue", body: { video: video }).body
|
31
|
-
end
|
32
|
-
|
33
|
-
def pause
|
34
|
-
response = Client.post_request("songrequest/:channel/player/pause", body: {})
|
35
|
-
response.success?
|
36
|
-
end
|
37
|
-
|
38
|
-
def play
|
39
|
-
response = Client.post_request("songrequest/:channel/player/play", body: {})
|
40
|
-
response.success?
|
41
|
-
end
|
42
|
-
|
43
|
-
def volume(volume:)
|
44
|
-
response = Client.post_request("songrequest/:channel/player/volume", body: {volume: volume})
|
45
|
-
response.success?
|
46
|
-
end
|
47
|
-
|
48
|
-
def skip
|
49
|
-
response = Client.post_request("songrequest/:channel/skip", body: {})
|
50
|
-
response.success?
|
51
|
-
end
|
52
|
-
|
53
|
-
end
|
54
|
-
|
55
|
-
end
|
56
|
-
end
|
@@ -1,23 +0,0 @@
|
|
1
|
-
module StreamElements
|
2
|
-
class Tip < Object
|
3
|
-
|
4
|
-
class << self
|
5
|
-
|
6
|
-
def list(**params)
|
7
|
-
response = Client.get_request("tips/:channel", params: params)
|
8
|
-
Collection.from_response(response, type: Tip, name: "docs")
|
9
|
-
end
|
10
|
-
|
11
|
-
def retrieve(id:)
|
12
|
-
Tip.new Client.get_request("tips/:channel/#{id}").body
|
13
|
-
end
|
14
|
-
|
15
|
-
def top
|
16
|
-
response = Client.get_request("tips/:channel/top")
|
17
|
-
# Collection.from_response(response, type: TopTip)
|
18
|
-
end
|
19
|
-
|
20
|
-
end
|
21
|
-
|
22
|
-
end
|
23
|
-
end
|
@@ -1,19 +0,0 @@
|
|
1
|
-
module StreamElements
|
2
|
-
class User < Object
|
3
|
-
|
4
|
-
class << self
|
5
|
-
|
6
|
-
def current
|
7
|
-
response = Client.get_request("users/current")
|
8
|
-
User.new response.body
|
9
|
-
end
|
10
|
-
|
11
|
-
def channels
|
12
|
-
response = Client.get_request("users/channels")
|
13
|
-
Collection.from_response(response, type: Channel)
|
14
|
-
end
|
15
|
-
|
16
|
-
end
|
17
|
-
|
18
|
-
end
|
19
|
-
end
|
File without changes
|