twitch-api 0.4.0 → 1.0.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 +130 -26
- data/lib/twitch/api_error.rb +5 -4
- data/lib/twitch/automod_message_status.rb +17 -0
- data/lib/twitch/bits_leader.rb +3 -1
- data/lib/twitch/category.rb +27 -0
- data/lib/twitch/channel.rb +46 -0
- data/lib/twitch/cheermote.rb +53 -0
- data/lib/twitch/cheermote_tier.rb +55 -0
- data/lib/twitch/cheermote_tier_image.rb +18 -0
- data/lib/twitch/cheermote_tier_images.rb +21 -0
- data/lib/twitch/client/custom_rewards.rb +35 -0
- data/lib/twitch/client/extensions.rb +20 -0
- data/lib/twitch/client/games.rb +20 -0
- data/lib/twitch/client/moderation.rb +28 -0
- data/lib/twitch/client/streams.rb +29 -0
- data/lib/twitch/client/subscriptions.rb +12 -0
- data/lib/twitch/client/users.rb +20 -0
- data/lib/twitch/client.rb +127 -100
- data/lib/twitch/clip.rb +5 -11
- data/lib/twitch/custom_reward.rb +91 -0
- data/lib/twitch/editor.rb +21 -0
- data/lib/twitch/entitlement_grant_url.rb +3 -2
- data/lib/twitch/extension.rb +37 -0
- data/lib/twitch/extensions_by_types.rb +32 -0
- data/lib/twitch/game.rb +4 -2
- data/lib/twitch/game_analytic.rb +4 -2
- data/lib/twitch/moderation_event.rb +33 -0
- data/lib/twitch/moderator.rb +20 -0
- data/lib/twitch/redemption.rb +35 -0
- data/lib/twitch/response.rb +42 -19
- data/lib/twitch/stream.rb +9 -11
- data/lib/twitch/stream_marker.rb +7 -8
- data/lib/twitch/stream_metadata.rb +27 -16
- data/lib/twitch/subscription.rb +28 -0
- data/lib/twitch/user.rb +8 -3
- data/lib/twitch/user_ban.rb +26 -0
- data/lib/twitch/user_follow.rb +4 -2
- data/lib/twitch/version.rb +3 -1
- data/lib/twitch/video.rb +7 -13
- data/lib/twitch-api.rb +3 -4
- metadata +57 -75
- data/.gitignore +0 -17
- data/.rspec +0 -3
- data/.travis.yml +0 -9
- data/Gemfile +0 -6
- data/Rakefile +0 -6
- data/bin/console +0 -14
- data/bin/setup +0 -8
- data/twitch-api.gemspec +0 -32
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: bda514f18997d369233835dd22a840f0c0ba884af5371d10ce553381a672aa97
|
4
|
+
data.tar.gz: 87efa1511f0e9346e87190570e6cd0745b89daffbaef04359d7e7fb283523b67
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 638a7c88c04b0aaef5e6b17e0005ca75c312bac9a5140eaaee09e3e522d6df6ceba93c79d226ae2a255ebf7c1602b6cb3ea2335cf7bd6f7491c8ac134b9f3064
|
7
|
+
data.tar.gz: 9305290bf8b6103a0ed2497c0bc39616d919b0939763cea47e3d08c8941d44638e59a0ab93f1ff95b008f1dd32a0ffaa032d487270ddf0624ae1d25952f7d587
|
data/README.md
CHANGED
@@ -1,28 +1,32 @@
|
|
1
1
|
[![Gem](https://img.shields.io/gem/v/twitch-api.svg)](https://rubygems.org/gems/twitch-api)
|
2
2
|
[![Downloads](https://img.shields.io/gem/dt/twitch-api.svg)](https://rubygems.org/gems/twitch-api)
|
3
|
-
[![
|
4
|
-
[![License](https://img.shields.io/github/license/mauricew/ruby-twitch-api.svg)]()
|
3
|
+
[![Cirrus CI - Base Branch Build Status](https://img.shields.io/cirrus/github/mauricew/ruby-twitch-api)](https://cirrus-ci.com/github/mauricew/ruby-twitch-api)
|
4
|
+
[![License](https://img.shields.io/github/license/mauricew/ruby-twitch-api.svg)](LICENSE.txt)
|
5
|
+
|
5
6
|
# Ruby Twitch API
|
6
7
|
|
7
8
|
This library is a Ruby implementation of the [Twitch Helix API](https://dev.twitch.tv/docs/api).
|
8
9
|
|
9
|
-
The goal is to provide access for the newest supported APIs provided by Twitch,
|
10
|
+
The goal is to provide access for the newest supported APIs provided by Twitch,
|
11
|
+
while keeping extensibility for their future expansion.
|
12
|
+
These are still in development, as is this library which should remain in pace with changes made.
|
10
13
|
|
11
14
|
Guaranteed supported APIs include:
|
12
|
-
|
13
|
-
*
|
15
|
+
|
16
|
+
* Helix REST (full rolling support)
|
17
|
+
* Helix Webhooks (coming soon)
|
14
18
|
|
15
19
|
The future may bring:
|
16
|
-
|
17
|
-
*
|
18
|
-
* TMI/chat
|
20
|
+
|
21
|
+
* PubSub
|
19
22
|
|
20
23
|
These will not be considered:
|
21
|
-
|
22
|
-
*
|
24
|
+
|
25
|
+
* [Twitch Kraken API](https://github.com/dustinlakin/twitch-rb)
|
26
|
+
* [Twitch GraphQL API](https://github.com/mauricew/twitch-graphql-api)
|
27
|
+
* [Twitch Chat (IRC/TMI)](https://github.com/EnotPoloskun/twitch-chat)
|
23
28
|
|
24
29
|
## Installation
|
25
|
-
Ruby 2.1 or later compatibility is guaranteed, however the target is 2.0 and above.
|
26
30
|
|
27
31
|
Add to your application's Gemfile:
|
28
32
|
|
@@ -35,27 +39,124 @@ gem 'twitch-api', :git => 'https://github.com/mauricew/ruby-twitch-api'
|
|
35
39
|
|
36
40
|
And then execute:
|
37
41
|
|
38
|
-
|
42
|
+
```sh
|
43
|
+
$ bundle
|
44
|
+
```
|
39
45
|
|
40
46
|
Or install it yourself as:
|
41
47
|
|
42
|
-
|
48
|
+
```sh
|
49
|
+
$ gem install twitch-api
|
50
|
+
```
|
43
51
|
|
44
52
|
## Usage
|
45
|
-
|
53
|
+
|
54
|
+
### Authentication
|
55
|
+
|
56
|
+
[Twitch documentation](https://dev.twitch.tv/docs/authentication).
|
57
|
+
|
58
|
+
This gem uses [`twitch_oauth2` gem](https://github.com/AlexWayfer/twitch_oauth2)
|
59
|
+
for authorization and authentication, you can read more detailed documentation there
|
60
|
+
(but it's pretty simple).
|
61
|
+
|
62
|
+
The goal is in an object with credentials and re-using it between different gems,
|
63
|
+
for example for API and for chat, or for the old API and the new one.
|
64
|
+
Also a logic for tokens validation and refreshing is encapsulated in it.
|
65
|
+
|
66
|
+
One of references is [this JavaScript set of libraries](https://github.com/d-fischer/twitch).
|
67
|
+
|
68
|
+
#### Client (application) flow
|
69
|
+
|
70
|
+
This is easier flow with limited (non-personal) access.
|
71
|
+
|
72
|
+
```ruby
|
73
|
+
tokens = TwitchOAuth2::Tokens.new(
|
74
|
+
client: {
|
75
|
+
client_id: client_id,
|
76
|
+
client_secret: client_secret
|
77
|
+
},
|
78
|
+
|
79
|
+
## this is default
|
80
|
+
# token_type: :application,
|
81
|
+
|
82
|
+
## this can be required by some Twitch end-points
|
83
|
+
# scopes: scopes,
|
84
|
+
|
85
|
+
## if you already have ones
|
86
|
+
# access_token: access_token
|
87
|
+
)
|
88
|
+
|
89
|
+
twitch_client = Twitch::Client.new(tokens: tokens)
|
46
90
|
```
|
47
|
-
|
48
|
-
|
49
|
-
|
91
|
+
|
92
|
+
#### Authorization (user) flow
|
93
|
+
|
94
|
+
This is flow required for user-specific actions.
|
95
|
+
|
96
|
+
If there are no `access_token` and `refresh_token` in `:tokens`,
|
97
|
+
`TwitchOAuth2::AuthorizeError` will be raised with `#link`.
|
98
|
+
|
99
|
+
If you have a web-application with N users, you can redirect them to this link
|
100
|
+
and use `redirect_uri` to your application for callbacks.
|
101
|
+
|
102
|
+
Otherwise, if you have something like CLI tool, you can print instructions with a link for user.
|
103
|
+
|
104
|
+
Then you can use `tokens.code = 'a code from params in redirect uri'`
|
105
|
+
and it'll store new `:access_token` and `:refresh_token`.
|
106
|
+
|
107
|
+
```ruby
|
108
|
+
tokens = TwitchOAuth2::Tokens.new(
|
109
|
+
client: {
|
110
|
+
client_id: client_id,
|
111
|
+
client_secret: client_secret,
|
112
|
+
|
113
|
+
## `localhost` by default, can be your application end-point
|
114
|
+
# redirect_uri: redirect_uri
|
115
|
+
},
|
116
|
+
|
117
|
+
token_type: :user,
|
118
|
+
|
119
|
+
## this can be required by some Twitch end-points
|
120
|
+
# scopes: scopes,
|
121
|
+
|
122
|
+
## if you already have these
|
123
|
+
# access_token: access_token,
|
124
|
+
# refresh_token: refresh_token
|
125
|
+
)
|
126
|
+
|
127
|
+
twitch_client = Twitch::Client.new(tokens: tokens)
|
50
128
|
```
|
51
|
-
Because data may change for certain endpoints, there is also a keyword parameter called `with_raw` that returns the raw response for any request called.
|
52
129
|
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
130
|
+
#### After initialization
|
131
|
+
|
132
|
+
If you've passed `refresh_token` to initialization and your `access_token` is invalid,
|
133
|
+
requests that require `access_token` will automatically refresh it.
|
134
|
+
|
135
|
+
You can access tokens:
|
136
|
+
|
137
|
+
```ruby
|
138
|
+
twitch_client.tokens # => `TwitchOAuth2::Tokens` instance
|
139
|
+
twitch_client.tokens.access_token # => 'abcdef'
|
140
|
+
twitch_client.tokens.refresh_token # => 'ghijkl'
|
58
141
|
```
|
142
|
+
|
143
|
+
### Calls
|
144
|
+
|
145
|
+
Because data may change for certain endpoints, there is also the raw response
|
146
|
+
for any request called.
|
147
|
+
|
148
|
+
Retrieval methods take in a hash equal to the parameters of the API endpoint,
|
149
|
+
and return a response object containing the data and other associated request information:
|
150
|
+
|
151
|
+
* **data** is the data you would get back. Even if it's an array of one object,
|
152
|
+
it remains the same as what comes from the API.
|
153
|
+
* **rate_limit** and associated fields contain API request limit information.
|
154
|
+
Clip creation counts for a second limit (duration currently unknown).
|
155
|
+
* **pagination** is a hash that appears when data can be traversed,
|
156
|
+
and contains one member (*cursor*) which lets you paginate through certain requests.
|
157
|
+
* **raw** is the raw HTTP response data.
|
158
|
+
|
159
|
+
```ruby
|
59
160
|
# Get top live streams
|
60
161
|
client.get_streams.data
|
61
162
|
# Get a single user
|
@@ -66,12 +167,15 @@ client.get_games({name: ["Heroes of the Storm", "Super Mario Odyssey"]}).data
|
|
66
167
|
```
|
67
168
|
|
68
169
|
### Error handling
|
69
|
-
|
170
|
+
|
171
|
+
An `APIError` is raised whenever an HTTP error response is returned.
|
70
172
|
Rescue it to access the body of the response, which should include an error message.
|
71
173
|
|
72
174
|
## Development
|
73
175
|
|
74
|
-
After checking out the repo, run `bin/setup` to install dependencies.
|
176
|
+
After checking out the repo, run `bin/setup` to install dependencies.
|
177
|
+
Then, run `rake spec` to run the tests.
|
178
|
+
(Tests require a Twitch Client ID; since cassettes exist you can use any value.)
|
75
179
|
|
76
180
|
You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
77
181
|
|
@@ -79,4 +183,4 @@ To install this gem onto your local machine, run `bundle exec rake install`.
|
|
79
183
|
|
80
184
|
## Contributing
|
81
185
|
|
82
|
-
Bug reports and pull requests are welcome on GitHub
|
186
|
+
Bug reports and pull requests are welcome on [GitHub](https://github.com/mauricew/ruby-twitch-api).
|
data/lib/twitch/api_error.rb
CHANGED
@@ -1,6 +1,8 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module Twitch
|
2
4
|
# An error returned by the API.
|
3
|
-
class
|
5
|
+
class APIError < StandardError
|
4
6
|
# HTTP status code of the response.
|
5
7
|
attr_reader :status_code
|
6
8
|
# Body content of the response.
|
@@ -10,8 +12,7 @@ module Twitch
|
|
10
12
|
@status_code = status_code
|
11
13
|
@body = body
|
12
14
|
|
13
|
-
|
14
|
-
super(msg)
|
15
|
+
super self.body['message']
|
15
16
|
end
|
16
17
|
end
|
17
|
-
end
|
18
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Twitch
|
4
|
+
# A determination if AutoMod would allow a message in a particular channel's chat.
|
5
|
+
class AutomodMessageStatus
|
6
|
+
# ID of the message. Matches the field of the same name passed in the request.
|
7
|
+
attr_reader :msg_id
|
8
|
+
# Whether the message would meet AutoMod requirements for the channel.
|
9
|
+
attr_reader :is_permitted
|
10
|
+
|
11
|
+
def initialize(attributes = {})
|
12
|
+
attributes.each do |key, value|
|
13
|
+
instance_variable_set "@#{key}", value
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
data/lib/twitch/bits_leader.rb
CHANGED
@@ -0,0 +1,27 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Twitch
|
4
|
+
## Data class for categories
|
5
|
+
class Category
|
6
|
+
## A URL to an image of the game’s box art or streaming category.
|
7
|
+
attr_reader :box_art_url
|
8
|
+
|
9
|
+
## The name of the game or category.
|
10
|
+
attr_reader :name
|
11
|
+
|
12
|
+
## An ID that uniquely identifies the game or category.
|
13
|
+
attr_reader :id
|
14
|
+
|
15
|
+
## Not always available:
|
16
|
+
|
17
|
+
## The ID that IGDB uses to identify this game.
|
18
|
+
## If the IGDB ID is not available to Twitch, this field is set to an empty string.
|
19
|
+
attr_reader :igdb_id
|
20
|
+
|
21
|
+
def initialize(attributes = {})
|
22
|
+
attributes.each do |key, value|
|
23
|
+
instance_variable_set "@#{key}", value
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
@@ -0,0 +1,46 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Twitch
|
4
|
+
# Data object for Twitch channels
|
5
|
+
# https://dev.twitch.tv/docs/api/reference#get-channel-information
|
6
|
+
class Channel
|
7
|
+
# Twitch User ID of this channel owner.
|
8
|
+
attr_reader :broadcaster_id
|
9
|
+
# Broadcaster's user login name.
|
10
|
+
attr_reader :broadcaster_login
|
11
|
+
# Twitch user display name of this channel owner.
|
12
|
+
attr_reader :broadcaster_name
|
13
|
+
# Language of the channel.
|
14
|
+
# A language value is either the ISO 639-1 two-letter code for a supported stream language
|
15
|
+
# or "other".
|
16
|
+
attr_reader :broadcaster_language
|
17
|
+
# Current game ID being played on the channel .
|
18
|
+
attr_reader :game_id
|
19
|
+
# Name of the game being played on the channel.
|
20
|
+
attr_reader :game_name
|
21
|
+
# Title of the stream.
|
22
|
+
attr_reader :title
|
23
|
+
# Stream delay in seconds.
|
24
|
+
attr_reader :delay
|
25
|
+
|
26
|
+
# Some endpoints, like "Search Channels", can return different fields
|
27
|
+
attr_reader :id
|
28
|
+
attr_reader :display_name
|
29
|
+
# A Boolean value that determines whether the broadcaster is streaming live.
|
30
|
+
# Is true if the broadcaster is streaming live; otherwise, false.
|
31
|
+
attr_reader :is_live
|
32
|
+
# The tags applied to the channel.
|
33
|
+
attr_reader :tags
|
34
|
+
# A URL to a thumbnail of the broadcaster’s profile image.
|
35
|
+
attr_reader :thumbnail_url
|
36
|
+
# The UTC date and time (in RFC3339 format) of when the broadcaster started streaming.
|
37
|
+
# The string is empty if the broadcaster is not streaming live.
|
38
|
+
attr_reader :started_at
|
39
|
+
|
40
|
+
def initialize(attributes = {})
|
41
|
+
attributes.each do |key, value|
|
42
|
+
instance_variable_set "@#{key}", value
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
@@ -0,0 +1,53 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative 'cheermote_tier'
|
4
|
+
|
5
|
+
module Twitch
|
6
|
+
## Data class for Cheermotes, animated emotes that viewers can assign Bits to.
|
7
|
+
class Cheermote
|
8
|
+
## The name portion of the Cheermote string that you use in chat to cheer Bits.
|
9
|
+
## The full Cheermote string is the concatenation of {prefix} + {number of Bits}.
|
10
|
+
## For example, if the prefix is “Cheer” and you want to cheer 100 Bits,
|
11
|
+
## the full Cheermote string is Cheer100.
|
12
|
+
## When the Cheermote string is entered in chat,
|
13
|
+
## Twitch converts it to the image associated with the Bits tier that was cheered.
|
14
|
+
attr_reader :prefix
|
15
|
+
|
16
|
+
## A list of tier levels that the Cheermote supports.
|
17
|
+
## Each tier identifies the range of Bits that you can cheer at that tier level
|
18
|
+
## and an image that graphically identifies the tier level.
|
19
|
+
attr_reader :tiers
|
20
|
+
|
21
|
+
## The type of Cheermote. Possible values are:
|
22
|
+
## * global_first_party — A Twitch-defined Cheermote that is shown in the Bits card.
|
23
|
+
## * global_third_party — A Twitch-defined Cheermote that is not shown in the Bits card.
|
24
|
+
## * channel_custom — A broadcaster-defined Cheermote.
|
25
|
+
## * display_only — Do not use; for internal use only.
|
26
|
+
## * sponsored — A sponsor-defined Cheermote.
|
27
|
+
## When used, the sponsor adds additional Bits to the amount that the user cheered.
|
28
|
+
## For example, if the user cheered Terminator100, the broadcaster might receive 110 Bits,
|
29
|
+
## which includes the sponsor's 10 Bits contribution.
|
30
|
+
attr_reader :type
|
31
|
+
|
32
|
+
## The order that the Cheermotes are shown in the Bits card.
|
33
|
+
## The numbers may not be consecutive. For example, the numbers may jump from 1 to 7 to 13.
|
34
|
+
## The order numbers are unique within a Cheermote type (for example, global_first_party)
|
35
|
+
## but may not be unique amongst all Cheermotes in the response.
|
36
|
+
attr_reader :order
|
37
|
+
|
38
|
+
## The date and time when this Cheermote was last updated.
|
39
|
+
attr_reader :last_updated
|
40
|
+
|
41
|
+
## A Boolean value that indicates whether this Cheermote provides
|
42
|
+
## a charitable contribution match during charity campaigns.
|
43
|
+
attr_reader :is_charitable
|
44
|
+
|
45
|
+
def initialize(attributes = {})
|
46
|
+
attributes.each do |key, value|
|
47
|
+
value = value.map { |tier| CheermoteTier.new(tier) } if key == 'tiers'
|
48
|
+
|
49
|
+
instance_variable_set "@#{key}", value
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
@@ -0,0 +1,55 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative 'cheermote_tier_images'
|
4
|
+
|
5
|
+
module Twitch
|
6
|
+
## Data class for Cheermote Tier.
|
7
|
+
## Each tier identifies the range of Bits that you can cheer at that tier level
|
8
|
+
## and an image that graphically identifies the tier level.
|
9
|
+
class CheermoteTier
|
10
|
+
## The minimum number of Bits that you must cheer at this tier level.
|
11
|
+
## The maximum number of Bits that you can cheer at this level
|
12
|
+
## is determined by the required minimum Bits of the next tier level minus 1.
|
13
|
+
## For example, if `min_bits` is 1 and `min_bits` for the next tier is 100,
|
14
|
+
## the Bits range for this tier level is 1 through 99.
|
15
|
+
## The minimum Bits value of the last tier is the maximum number of Bits you can cheer
|
16
|
+
## using this Cheermote. For example, 10000.
|
17
|
+
attr_reader :min_bits
|
18
|
+
|
19
|
+
## The tier level. Possible tiers are:
|
20
|
+
## * 1
|
21
|
+
## * 100
|
22
|
+
## * 500
|
23
|
+
## * 1000
|
24
|
+
## * 5000
|
25
|
+
## * 10000
|
26
|
+
## * 100000
|
27
|
+
attr_reader :id
|
28
|
+
|
29
|
+
## The hex code of the color associated with this tier level (for example, `#979797`).
|
30
|
+
attr_reader :color
|
31
|
+
|
32
|
+
## The animated and static image sets for the Cheermote.
|
33
|
+
## The dictionary of images is organized by theme, format, and size.
|
34
|
+
## The theme keys are `dark` and `light`.
|
35
|
+
## Each theme is a dictionary of formats: `animated` and `static`.
|
36
|
+
## Each format is a dictionary of sizes: `1`, `1.5`, `2`, `3`, and `4`.
|
37
|
+
## The value of each size contains the URL to the image.
|
38
|
+
attr_reader :images
|
39
|
+
|
40
|
+
## A Boolean value that determines whether users can cheer at this tier level.
|
41
|
+
attr_reader :can_cheer
|
42
|
+
|
43
|
+
## A Boolean value that determines whether this tier level is shown in the Bits card.
|
44
|
+
## Is `true` if this tier level is shown in the Bits card.
|
45
|
+
attr_reader :show_in_bits_card
|
46
|
+
|
47
|
+
def initialize(attributes = {})
|
48
|
+
attributes.each do |key, value|
|
49
|
+
value = CheermoteTierImages.new(value) if key == 'images'
|
50
|
+
|
51
|
+
instance_variable_set "@#{key}", value
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Twitch
|
4
|
+
## Data class for Cheermote Tier image, static and animated
|
5
|
+
class CheermoteTierImage
|
6
|
+
## Each theme is a dictionary of formats: `animated` and `static`.
|
7
|
+
## Each format is a dictionary of sizes: `1`, `1.5`, `2`, `3`, and `4`.
|
8
|
+
## The value of each size contains the URL to the image.
|
9
|
+
attr_reader :animated
|
10
|
+
attr_reader :static
|
11
|
+
|
12
|
+
def initialize(attributes = {})
|
13
|
+
attributes.each do |key, value|
|
14
|
+
instance_variable_set "@#{key}", value
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative 'cheermote_tier_image'
|
4
|
+
|
5
|
+
module Twitch
|
6
|
+
## Data class for Cheermote Tier images by themes
|
7
|
+
class CheermoteTierImages
|
8
|
+
## The theme keys are `dark` and `light`.
|
9
|
+
## Each theme is a dictionary of formats: `animated` and `static`.
|
10
|
+
## Each format is a dictionary of sizes: `1`, `1.5`, `2`, `3`, and `4`.
|
11
|
+
## The value of each size contains the URL to the image.
|
12
|
+
attr_reader :dark
|
13
|
+
attr_reader :light
|
14
|
+
|
15
|
+
def initialize(attributes = {})
|
16
|
+
attributes.each do |key, value|
|
17
|
+
instance_variable_set "@#{key}", CheermoteTierImage.new(value)
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,35 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Twitch
|
4
|
+
class Client
|
5
|
+
## API methods for custom rewards
|
6
|
+
module CustomRewards
|
7
|
+
def create_custom_reward(options = {})
|
8
|
+
initialize_response CustomReward, post('channel_points/custom_rewards', options)
|
9
|
+
end
|
10
|
+
|
11
|
+
def get_custom_reward(options = {})
|
12
|
+
initialize_response CustomReward, get('channel_points/custom_rewards', options)
|
13
|
+
end
|
14
|
+
|
15
|
+
def delete_custom_reward(options = {})
|
16
|
+
initialize_response CustomReward, delete('channel_points/custom_rewards', options)
|
17
|
+
end
|
18
|
+
|
19
|
+
def get_custom_reward_redemption(options = {})
|
20
|
+
initialize_response CustomReward, get('channel_points/custom_rewards/redemptions', options)
|
21
|
+
end
|
22
|
+
|
23
|
+
def update_custom_reward(options = {})
|
24
|
+
initialize_response CustomReward, patch('channel_points/custom_rewards', options)
|
25
|
+
end
|
26
|
+
|
27
|
+
def update_redemption_status(options = {})
|
28
|
+
initialize_response(
|
29
|
+
CustomReward,
|
30
|
+
patch('channel_points/custom_rewards/redemptions', options)
|
31
|
+
)
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Twitch
|
4
|
+
class Client
|
5
|
+
# API methods for extensions
|
6
|
+
module Extensions
|
7
|
+
def get_user_extensions(options = {})
|
8
|
+
initialize_response Extension, get('users/extensions/list', options)
|
9
|
+
end
|
10
|
+
|
11
|
+
def get_user_active_extensions(options = {})
|
12
|
+
initialize_response ExtensionsByTypes, get('users/extensions', options)
|
13
|
+
end
|
14
|
+
|
15
|
+
def update_user_extensions(options = {})
|
16
|
+
initialize_response ExtensionsByTypes, put('users/extensions', options)
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Twitch
|
4
|
+
class Client
|
5
|
+
## API method for games
|
6
|
+
module Games
|
7
|
+
def get_games(options = {})
|
8
|
+
initialize_response Game, get('games', options)
|
9
|
+
end
|
10
|
+
|
11
|
+
def get_top_games(options = {})
|
12
|
+
initialize_response Game, get('games/top', options)
|
13
|
+
end
|
14
|
+
|
15
|
+
def get_game_analytics(options = {})
|
16
|
+
initialize_response GameAnalytic, get('analytics/games', options)
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Twitch
|
4
|
+
class Client
|
5
|
+
# API methods for stream moderation
|
6
|
+
module Moderation
|
7
|
+
def check_automod_status(options = {})
|
8
|
+
initialize_response AutomodMessageStatus, post('moderation/enforcements/status', options)
|
9
|
+
end
|
10
|
+
|
11
|
+
def get_banned_events(options = {})
|
12
|
+
initialize_response ModerationEvent, get('moderation/banned/events', options)
|
13
|
+
end
|
14
|
+
|
15
|
+
def get_banned_users(options = {})
|
16
|
+
initialize_response UserBan, get('moderation/banned', options)
|
17
|
+
end
|
18
|
+
|
19
|
+
def get_moderators(options = {})
|
20
|
+
initialize_response Moderator, get('moderation/moderators', options)
|
21
|
+
end
|
22
|
+
|
23
|
+
def get_moderator_events(options = {})
|
24
|
+
initialize_response ModerationEvent, get('moderation/moderators/events', options)
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Twitch
|
4
|
+
class Client
|
5
|
+
## API method for streams
|
6
|
+
module Streams
|
7
|
+
def create_stream_marker(options = {})
|
8
|
+
initialize_response StreamMarker, post('streams/markers', options)
|
9
|
+
end
|
10
|
+
|
11
|
+
def get_stream_markers(options = {})
|
12
|
+
initialize_response StreamMarkerResponse, get('streams/markers', options)
|
13
|
+
end
|
14
|
+
|
15
|
+
def get_streams(options = {})
|
16
|
+
initialize_response Stream, get('streams', options)
|
17
|
+
end
|
18
|
+
|
19
|
+
## TODO: Can't find this method in documentation, test it
|
20
|
+
def get_streams_metadata(options = {})
|
21
|
+
initialize_response StreamMetadata, get('streams/metadata', options)
|
22
|
+
end
|
23
|
+
|
24
|
+
def get_stream_key(options = {})
|
25
|
+
initialize_response nil, get('streams/key', options)
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
@@ -0,0 +1,12 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Twitch
|
4
|
+
class Client
|
5
|
+
# API methods for subscriptions
|
6
|
+
module Subscriptions
|
7
|
+
def get_broadcaster_subscription(options = {})
|
8
|
+
initialize_response Subscription, post('subscriptions', options)
|
9
|
+
end
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Twitch
|
4
|
+
class Client
|
5
|
+
## API method for users
|
6
|
+
module Users
|
7
|
+
def get_users_follows(options = {})
|
8
|
+
initialize_response UserFollow, get('users/follows', options)
|
9
|
+
end
|
10
|
+
|
11
|
+
def get_users(options = {})
|
12
|
+
initialize_response User, get('users', options)
|
13
|
+
end
|
14
|
+
|
15
|
+
def update_user(options = {})
|
16
|
+
initialize_response User, put('users', options)
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|