twitchrb 0.1.0 → 0.2.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.
Files changed (75) hide show
  1. checksums.yaml +4 -4
  2. data/.env.example +3 -0
  3. data/.github/FUNDING.yml +4 -0
  4. data/.gitignore +1 -0
  5. data/Gemfile +1 -0
  6. data/Gemfile.lock +28 -9
  7. data/README.md +46 -6
  8. data/bin/console +5 -0
  9. data/lib/twitch/client.rb +103 -65
  10. data/lib/twitch/collection.rb +21 -0
  11. data/lib/twitch/error.rb +4 -0
  12. data/lib/twitch/object.rb +19 -0
  13. data/lib/twitch/objects/badge.rb +4 -0
  14. data/lib/twitch/objects/banned_event.rb +4 -0
  15. data/lib/twitch/objects/banned_user.rb +4 -0
  16. data/lib/twitch/objects/blocked_user.rb +4 -0
  17. data/lib/twitch/objects/channel.rb +4 -0
  18. data/lib/twitch/objects/channel_editor.rb +4 -0
  19. data/lib/twitch/objects/clip.rb +4 -0
  20. data/lib/twitch/objects/custom_reward.rb +4 -0
  21. data/lib/twitch/objects/custom_reward_redemption.rb +4 -0
  22. data/lib/twitch/objects/emote.rb +4 -0
  23. data/lib/twitch/objects/event_sub_subscription.rb +4 -0
  24. data/lib/twitch/objects/followed_user.rb +4 -0
  25. data/lib/twitch/objects/game.rb +4 -0
  26. data/lib/twitch/objects/goal.rb +4 -0
  27. data/lib/twitch/objects/hype_train_event.rb +4 -0
  28. data/lib/twitch/objects/moderator.rb +4 -0
  29. data/lib/twitch/objects/moderator_event.rb +4 -0
  30. data/lib/twitch/objects/poll.rb +4 -0
  31. data/lib/twitch/objects/prediction.rb +4 -0
  32. data/lib/twitch/objects/search_result.rb +4 -0
  33. data/lib/twitch/objects/stream.rb +4 -0
  34. data/lib/twitch/objects/stream_marker.rb +4 -0
  35. data/lib/twitch/objects/stream_schedule.rb +4 -0
  36. data/lib/twitch/objects/subscription.rb +4 -0
  37. data/lib/twitch/objects/subscription_count.rb +4 -0
  38. data/lib/twitch/objects/tag.rb +4 -0
  39. data/lib/twitch/objects/user.rb +4 -0
  40. data/lib/twitch/objects/video.rb +4 -0
  41. data/lib/twitch/resource.rb +57 -0
  42. data/lib/twitch/resources/badges.rb +15 -0
  43. data/lib/twitch/resources/banned_events.rb +10 -0
  44. data/lib/twitch/resources/banned_users.rb +11 -0
  45. data/lib/twitch/resources/channels.rb +20 -0
  46. data/lib/twitch/resources/clips.rb +23 -0
  47. data/lib/twitch/resources/custom_reward_redemptions.rb +22 -0
  48. data/lib/twitch/resources/custom_rewards.rb +30 -0
  49. data/lib/twitch/resources/emotes.rb +20 -0
  50. data/lib/twitch/resources/event_sub_subscriptions.rb +21 -0
  51. data/lib/twitch/resources/games.rb +20 -0
  52. data/lib/twitch/resources/goals.rb +12 -0
  53. data/lib/twitch/resources/hype_train_events.rb +12 -0
  54. data/lib/twitch/resources/moderator_events.rb +11 -0
  55. data/lib/twitch/resources/moderators.rb +11 -0
  56. data/lib/twitch/resources/polls.rb +27 -0
  57. data/lib/twitch/resources/predictions.rb +32 -0
  58. data/lib/twitch/resources/search.rb +17 -0
  59. data/lib/twitch/resources/stream_markers.rb +19 -0
  60. data/lib/twitch/resources/stream_schedule.rb +47 -0
  61. data/lib/twitch/resources/streams.rb +19 -0
  62. data/lib/twitch/resources/subscriptions.rb +32 -0
  63. data/lib/twitch/resources/tags.rb +20 -0
  64. data/lib/twitch/resources/users.rb +54 -0
  65. data/lib/twitch/resources/videos.rb +17 -0
  66. data/lib/twitch/version.rb +1 -1
  67. data/lib/twitch.rb +63 -29
  68. data/twitchrb.gemspec +3 -2
  69. metadata +79 -13
  70. data/.travis.yml +0 -6
  71. data/lib/twitch/initializable.rb +0 -16
  72. data/lib/twitch/kraken/channels.rb +0 -22
  73. data/lib/twitch/kraken/clips.rb +0 -22
  74. data/lib/twitch/kraken/user.rb +0 -23
  75. data/lib/twitch/kraken/users.rb +0 -33
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: e6d24ae98033340c3a32007d15326393e2eb630d9bf617a22dcd86c3bd96205b
4
- data.tar.gz: 4099ce7790604f9d77dfb4e7e5c22252573ef6adcfde1806b99ea8b966d984cf
3
+ metadata.gz: 30b0eac63e649a017a1c4938b034886f1934da667145ca984f7d2898220d9c91
4
+ data.tar.gz: 97883516313836adc1a003649904b532c66ce5f14568981d5f82b21b807f489b
5
5
  SHA512:
6
- metadata.gz: 63a0c047cd6803daf0e094bdf88e0fb6ac73fa1959beb84f43c38634190bb5a53ce2e2242993ead65b8361ca4673a601a608a7769eac4026c320b83f9e57a3cc
7
- data.tar.gz: c04701b41259897d3a871df91037b801fb6c36f3e15f8bb764863dc96435b1da5671a97611570e11f5244d94dc851275f1f7cf0b4a69dcd929822548d2061157
6
+ metadata.gz: 5337a58e97212f82d77208f41a0af2b2b0f5b36c3652b7905c51af117e67767affe6a1388e647ed8e4f8ed307488084ee91989cc1a21494265dd5abba9055eea
7
+ data.tar.gz: 4a95c514a5d1addd4eebd265ba04ba79ae945913042ee4245d07a563e69bf37d365a49d31078130c425a5b545128886058211db96cc3444ff32bd56ebaa31490
data/.env.example ADDED
@@ -0,0 +1,3 @@
1
+ TWITCH_CLIENT_ID=
2
+ TWITCH_CLIENT_SECRET=
3
+ TWITCH_ACCESS_TOKEN=
@@ -0,0 +1,4 @@
1
+ # These are supported funding model platforms
2
+
3
+ github: deanpcmad
4
+ custom: https://www.buymeacoffee.com/deanpcmad
data/.gitignore CHANGED
@@ -6,3 +6,4 @@
6
6
  /pkg/
7
7
  /spec/reports/
8
8
  /tmp/
9
+ .env
data/Gemfile CHANGED
@@ -5,3 +5,4 @@ gemspec
5
5
 
6
6
  gem "rake", "~> 12.0"
7
7
  gem "minitest", "~> 5.0"
8
+ gem "dotenv"
data/Gemfile.lock CHANGED
@@ -1,26 +1,45 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- twitchrb (0.1.0)
5
- httparty (~> 0.18.1)
4
+ twitchrb (0.2.2)
5
+ faraday (~> 1.7)
6
+ faraday_middleware (~> 1.1)
6
7
 
7
8
  GEM
8
9
  remote: https://rubygems.org/
9
10
  specs:
10
- httparty (0.18.1)
11
- mime-types (~> 3.0)
12
- multi_xml (>= 0.5.2)
13
- mime-types (3.3.1)
14
- mime-types-data (~> 3.2015)
15
- mime-types-data (3.2020.0512)
11
+ dotenv (2.7.6)
12
+ faraday (1.8.0)
13
+ faraday-em_http (~> 1.0)
14
+ faraday-em_synchrony (~> 1.0)
15
+ faraday-excon (~> 1.1)
16
+ faraday-httpclient (~> 1.0.1)
17
+ faraday-net_http (~> 1.0)
18
+ faraday-net_http_persistent (~> 1.1)
19
+ faraday-patron (~> 1.0)
20
+ faraday-rack (~> 1.0)
21
+ multipart-post (>= 1.2, < 3)
22
+ ruby2_keywords (>= 0.0.4)
23
+ faraday-em_http (1.0.0)
24
+ faraday-em_synchrony (1.0.0)
25
+ faraday-excon (1.1.0)
26
+ faraday-httpclient (1.0.1)
27
+ faraday-net_http (1.0.1)
28
+ faraday-net_http_persistent (1.2.0)
29
+ faraday-patron (1.0.0)
30
+ faraday-rack (1.0.0)
31
+ faraday_middleware (1.2.0)
32
+ faraday (~> 1.0)
16
33
  minitest (5.14.1)
17
- multi_xml (0.6.0)
34
+ multipart-post (2.1.1)
18
35
  rake (12.3.3)
36
+ ruby2_keywords (0.0.5)
19
37
 
20
38
  PLATFORMS
21
39
  ruby
22
40
 
23
41
  DEPENDENCIES
42
+ dotenv
24
43
  minitest (~> 5.0)
25
44
  rake (~> 12.0)
26
45
  twitchrb!
data/README.md CHANGED
@@ -2,9 +2,9 @@
2
2
 
3
3
  **This library is a work in progress**
4
4
 
5
- This RubyGem is a library for intereacting with the Twitch API.
5
+ TwitchRB is a Ruby library for intereacting with the Twitch API.
6
6
 
7
- It will allow you to easily interact with both the Kraken and Helix APIs.
7
+ It only supports the Helix API as v5 is deprecated.
8
8
 
9
9
  ## Installation
10
10
 
@@ -14,15 +14,55 @@ Add this line to your application's Gemfile:
14
14
  gem "twitchrb", require: "twitch"
15
15
  ```
16
16
 
17
- And then execute:
17
+ ## Usage
18
18
 
19
- $ bundle install
19
+ ### Set Client Details
20
20
 
21
+ Firstly you'll need to set a Client ID, Secret Key and an Access Token.
21
22
 
22
- ## Contributing
23
+ An access token is required because the Helix API requires authentication.
24
+
25
+ ```ruby
26
+ @client = Twitch::Client.new(client_id: "", secret_key: "", access_token: "")
27
+ ```
28
+
29
+ ### Users
30
+
31
+ ```ruby
32
+ @client.users.get_by_id(user_id: 141981764)
33
+ @client.users.get_by_username(username: "twitchdev")
34
+ ```
35
+
36
+ ### Channels
37
+
38
+ ```ruby
39
+ @client.channels.get(broadcaster_id: 141981764)
40
+ ```
41
+
42
+ ### Videos
23
43
 
24
- Bug reports and pull requests are welcome on GitHub at https://github.com/deanpcmad/twitchrb.
44
+ ```ruby
45
+ @client.videos.get(user_id: 141981764)
46
+ ```
47
+
48
+ ### Emotes
49
+
50
+ ```ruby
51
+ @client.emotes.global
52
+ @client.emotes.channel(broadcaster_id: 141981764)
53
+ @client.emotes.sets(emote_set_id: 301590448)
54
+ ```
55
+
56
+ ### Badges
57
+
58
+ ```ruby
59
+ @client.badges.global
60
+ @client.badges.channel(broadcaster_id: 141981764)
61
+ ```
62
+
63
+ ## Contributing
25
64
 
65
+ Bug reports and pull requests are welcome on GitHub at https://github.com/twitchrb/twitchrb.
26
66
 
27
67
  ## License
28
68
 
data/bin/console CHANGED
@@ -3,6 +3,9 @@
3
3
  require "bundler/setup"
4
4
  require "twitch"
5
5
 
6
+ # Load environment variables from .env file
7
+ require 'dotenv/load'
8
+
6
9
  # You can add fixtures and/or initialization code here to make experimenting
7
10
  # with your gem easier. You can also use a different console, if you like.
8
11
 
@@ -10,5 +13,7 @@ require "twitch"
10
13
  # require "pry"
11
14
  # Pry.start
12
15
 
16
+ @client = Twitch::Client.new(client_id: ENV["TWITCH_CLIENT_ID"], client_secret: ENV["TWITCH_CLIENT_SECRET"], access_token: ENV["TWITCH_ACCESS_TOKEN"])
17
+
13
18
  require "irb"
14
19
  IRB.start(__FILE__)
data/lib/twitch/client.rb CHANGED
@@ -1,89 +1,127 @@
1
- require "httparty"
2
-
3
1
  module Twitch
4
2
  class Client
3
+ BASE_URL = "https://api.twitch.tv/helix"
5
4
 
6
- # def initialize(client_id, client_secret, access_token=nil)
7
- def initialize(client_id)
8
- puts "initialize"
5
+ attr_reader :client_id, :client_secret, :access_token, :adapter
9
6
 
7
+ def initialize(client_id:, client_secret:, access_token:, adapter: Faraday.default_adapter, stubs: nil)
10
8
  @client_id = client_id
9
+ @client_secret = client_secret
10
+ @access_token = access_token
11
+ @adapter = adapter
11
12
 
12
- # if client_id && client_secret
13
- # @client_id = client_id
14
- # @client_secret = client_secret
15
- # @access_token = access_token
16
- # else
17
- # raise Twitch::ClientError.new('Client ID or Client Secret not set')
18
- # end
19
-
20
- end
21
-
22
-
23
- def get(kind, url, params={})
24
- # puts url
25
- # puts params
26
- # puts @client_id
27
- response = HTTParty.get("https://api.twitch.tv/#{kind}/#{url}", {
28
- headers: {
29
- "Client-ID" => @client_id,
30
- "Accept" => "application/vnd.twitchtv.v5+json",
31
- # "Authorization" => "OAuth #{@access_token}"
32
- }
33
- })
34
- # puts response
35
-
36
- # JSON.parse(response.body)
37
-
38
- success = case response.code
39
- when 200
40
- JSON.parse(response.body)
41
- when 400
42
- json = JSON.parse(response.body)
43
- raise Twitch::Errors::NotFound, json['error']
44
- when 503
45
- raise Twitch::Errors::ServiceUnavailable
46
- when 401, 403
47
- puts response.body.inspect
48
- raise Twitch::Errors::AccessDenied, "Access Denied for '#{@client_id}'"
49
- when 400
50
- json = JSON.parse(response.body)
51
- raise Twitch::Errors::ValidationError, json['errors'].to_s
52
- else
53
- raise Twitch::Errors::CommunicationError, response.body
54
- end
13
+ # Test stubs for requests
14
+ @stubs = stubs
15
+ end
16
+
17
+ def users
18
+ UsersResource.new(self)
19
+ end
20
+
21
+ def channels
22
+ ChannelsResource.new(self)
23
+ end
24
+
25
+ def emotes
26
+ EmotesResource.new(self)
27
+ end
28
+
29
+ def badges
30
+ BadgesResource.new(self)
31
+ end
32
+
33
+ def games
34
+ GamesResource.new(self)
35
+ end
36
+
37
+ def videos
38
+ VideosResource.new(self)
39
+ end
40
+
41
+ def clips
42
+ ClipsResource.new(self)
43
+ end
44
+
45
+ def eventsub_subscriptions
46
+ EventSubSubscriptionsResource.new(self)
47
+ end
48
+
49
+ def banned_events
50
+ BannedEventsResource.new(self)
51
+ end
55
52
 
53
+ def banned_users
54
+ BannedUsersResource.new(self)
55
+ end
56
+
57
+ def moderators
58
+ ModeratorsResource.new(self)
59
+ end
60
+
61
+ def moderator_events
62
+ ModeratorEventsResource.new(self)
63
+ end
56
64
 
57
- # if response.code == 200
58
- # JSON.parse(response.body)
59
- # elsif response.code == 404
60
- # Twitch::NotFoundError.new(response.body)
61
- # elsif response.code == 500
62
- # Twitch::ServerError.new(response.body)
63
- # end
65
+ def polls
66
+ PollsResource.new(self)
67
+ end
68
+
69
+ def predictions
70
+ PredictionsResource.new(self)
71
+ end
72
+
73
+ def stream_schedule
74
+ StreamScheduleResource.new(self)
75
+ end
64
76
 
77
+ def search
78
+ SearchResource.new(self)
79
+ end
65
80
 
81
+ def streams
82
+ StreamsResource.new(self)
83
+ end
66
84
 
67
- # when Net::HTTPClientError
68
- # json = JSON.parse(http_result.body)
69
- # raise Twitch::Errors::ValidationError, json['errors'].to_s
70
- # else
71
- # raise Twitch::Errors::CommunicationError, http_result.body
72
- # end
85
+ def stream_markers
86
+ StreamMarkersResource.new(self)
87
+ end
73
88
 
89
+ def subscriptions
90
+ SubscriptionsResource.new(self)
91
+ end
74
92
 
93
+ def tags
94
+ TagsResource.new(self)
75
95
  end
76
96
 
97
+ def custom_rewards
98
+ CustomRewardsResource.new(self)
99
+ end
77
100
 
78
- # private
101
+ def custom_reward_redemptions
102
+ CustomRewardRedemptionsResource.new(self)
103
+ end
79
104
 
80
- # def request(method, path, options={})
81
- # # if @access_token
105
+ def goals
106
+ GoalsResource.new(self)
107
+ end
82
108
 
109
+ def hype_train_events
110
+ HypeTrainEventsResource.new(self)
111
+ end
83
112
 
113
+ def connection
114
+ @connection ||= Faraday.new(BASE_URL) do |conn|
115
+ conn.request :authorization, :Bearer, access_token
116
+ conn.headers = { "Client-ID": client_id }
117
+ conn.request :json
84
118
 
85
- # end
119
+ conn.response :dates
120
+ conn.response :json, content_type: "application/json"
86
121
 
122
+ conn.adapter adapter, @stubs
123
+ end
124
+ end
87
125
 
88
126
  end
89
127
  end
@@ -0,0 +1,21 @@
1
+ module Twitch
2
+ class Collection
3
+ attr_reader :data, :total, :cursor
4
+
5
+ def self.from_response(response, type:)
6
+ body = response.body
7
+
8
+ new(
9
+ data: body["data"].map { |attrs| type.new(attrs) },
10
+ total: body["data"].count,
11
+ cursor: body.dig("pagination", "cursor")
12
+ )
13
+ end
14
+
15
+ def initialize(data:, total:, cursor:)
16
+ @data = data
17
+ @total = total
18
+ @cursor = cursor.nil? ? nil : cursor
19
+ end
20
+ end
21
+ end
@@ -0,0 +1,4 @@
1
+ module Twitch
2
+ class Error < StandardError
3
+ end
4
+ end
@@ -0,0 +1,19 @@
1
+ require "ostruct"
2
+
3
+ module Twitch
4
+ class Object < OpenStruct
5
+ def initialize(attributes)
6
+ super to_ostruct(attributes)
7
+ end
8
+
9
+ def to_ostruct(obj)
10
+ if obj.is_a?(Hash)
11
+ OpenStruct.new(obj.map { |key, val| [key, to_ostruct(val)] }.to_h)
12
+ elsif obj.is_a?(Array)
13
+ obj.map { |o| to_ostruct(o) }
14
+ else # Assumed to be a primitive value
15
+ obj
16
+ end
17
+ end
18
+ end
19
+ end
@@ -0,0 +1,4 @@
1
+ module Twitch
2
+ class Badge < Object
3
+ end
4
+ end
@@ -0,0 +1,4 @@
1
+ module Twitch
2
+ class BannedEvent < Object
3
+ end
4
+ end
@@ -0,0 +1,4 @@
1
+ module Twitch
2
+ class BannedUser < Object
3
+ end
4
+ end
@@ -0,0 +1,4 @@
1
+ module Twitch
2
+ class BlockedUser < Object
3
+ end
4
+ end
@@ -0,0 +1,4 @@
1
+ module Twitch
2
+ class Channel < Object
3
+ end
4
+ end
@@ -0,0 +1,4 @@
1
+ module Twitch
2
+ class ChannelEditor < Object
3
+ end
4
+ end
@@ -0,0 +1,4 @@
1
+ module Twitch
2
+ class Clip < Object
3
+ end
4
+ end
@@ -0,0 +1,4 @@
1
+ module Twitch
2
+ class CustomReward < Object
3
+ end
4
+ end
@@ -0,0 +1,4 @@
1
+ module Twitch
2
+ class CustomRewardRedemption < Object
3
+ end
4
+ end
@@ -0,0 +1,4 @@
1
+ module Twitch
2
+ class Emote < Object
3
+ end
4
+ end
@@ -0,0 +1,4 @@
1
+ module Twitch
2
+ class EventSubSubscription < Object
3
+ end
4
+ end
@@ -0,0 +1,4 @@
1
+ module Twitch
2
+ class FollowedUser < Object
3
+ end
4
+ end
@@ -0,0 +1,4 @@
1
+ module Twitch
2
+ class Game < Object
3
+ end
4
+ end
@@ -0,0 +1,4 @@
1
+ module Twitch
2
+ class Goal < Object
3
+ end
4
+ end
@@ -0,0 +1,4 @@
1
+ module Twitch
2
+ class HypeTrainEvent < Object
3
+ end
4
+ end
@@ -0,0 +1,4 @@
1
+ module Twitch
2
+ class Moderator < Object
3
+ end
4
+ end
@@ -0,0 +1,4 @@
1
+ module Twitch
2
+ class ModeratorEvent < Object
3
+ end
4
+ end
@@ -0,0 +1,4 @@
1
+ module Twitch
2
+ class Poll < Object
3
+ end
4
+ end
@@ -0,0 +1,4 @@
1
+ module Twitch
2
+ class Prediction < Object
3
+ end
4
+ end
@@ -0,0 +1,4 @@
1
+ module Twitch
2
+ class SearchResult < Object
3
+ end
4
+ end
@@ -0,0 +1,4 @@
1
+ module Twitch
2
+ class Stream < Object
3
+ end
4
+ end
@@ -0,0 +1,4 @@
1
+ module Twitch
2
+ class StreamMarker < Object
3
+ end
4
+ end
@@ -0,0 +1,4 @@
1
+ module Twitch
2
+ class StreamSchedule < Object
3
+ end
4
+ end
@@ -0,0 +1,4 @@
1
+ module Twitch
2
+ class Subscription < Object
3
+ end
4
+ end
@@ -0,0 +1,4 @@
1
+ module Twitch
2
+ class SubscriptionCount < Object
3
+ end
4
+ end
@@ -0,0 +1,4 @@
1
+ module Twitch
2
+ class Tag < Object
3
+ end
4
+ end
@@ -0,0 +1,4 @@
1
+ module Twitch
2
+ class User < Object
3
+ end
4
+ end
@@ -0,0 +1,4 @@
1
+ module Twitch
2
+ class Video < Object
3
+ end
4
+ end
@@ -0,0 +1,57 @@
1
+ module Twitch
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 patch_request(url, body:, headers: {})
20
+ handle_response client.connection.patch(url, body, headers)
21
+ end
22
+
23
+ def put_request(url, body:, headers: {})
24
+ handle_response client.connection.put(url, body, headers)
25
+ end
26
+
27
+ def delete_request(url, params: {}, headers: {})
28
+ handle_response client.connection.delete(url, params, headers)
29
+ end
30
+
31
+ def handle_response(response)
32
+ case response.status
33
+ when 400
34
+ raise Error, "Error 400: Your request was malformed. '#{response.body["message"]}'"
35
+ when 401
36
+ raise Error, "Error 401: You did not supply valid authentication credentials. '#{response.body["error"]}'"
37
+ when 403
38
+ raise Error, "Error 403: You are not allowed to perform that action. '#{response.body["error"]}'"
39
+ when 404
40
+ raise Error, "Error 404: No results were found for your request. '#{response.body["error"]}'"
41
+ when 409
42
+ raise Error, "Error 409: Your request was a conflict. '#{response.body["message"]}'"
43
+ when 429
44
+ raise Error, "Error 429: Your request exceeded the API rate limit. '#{response.body["error"]}'"
45
+ when 500
46
+ raise Error, "Error 500: We were unable to perform the request due to server-side problems. '#{response.body["error"]}'"
47
+ when 503
48
+ raise Error, "Error 503: You have been rate limited for sending more than 20 requests per second. '#{response.body["error"]}'"
49
+ when 204
50
+ # 204 is a response for success on Twitch's API
51
+ return true
52
+ end
53
+
54
+ response
55
+ end
56
+ end
57
+ end
@@ -0,0 +1,15 @@
1
+ module Twitch
2
+ class BadgesResource < Resource
3
+
4
+ def channel(broadcaster_id:)
5
+ response = get_request("chat/badges?broadcaster_id=#{broadcaster_id}")
6
+ Collection.from_response(response, type: Badge)
7
+ end
8
+
9
+ def global
10
+ response = get_request("chat/badges/global")
11
+ Collection.from_response(response, type: Badge)
12
+ end
13
+
14
+ end
15
+ end