Class: Twitch::Client
- Inherits:
-
Object
- Object
- Twitch::Client
- Defined in:
- lib/twitch/client.rb
Constant Summary collapse
- BASE_URL =
"https://api.twitch.tv/helix"
Instance Attribute Summary collapse
-
#access_token ⇒ Object
readonly
Returns the value of attribute access_token.
-
#adapter ⇒ Object
readonly
Returns the value of attribute adapter.
-
#auto_retry_rate_limit ⇒ Object
readonly
Returns the value of attribute auto_retry_rate_limit.
-
#client_id ⇒ Object
readonly
Returns the value of attribute client_id.
-
#logger ⇒ Object
readonly
Returns the value of attribute logger.
-
#rate_limit_threshold ⇒ Object
readonly
Returns the value of attribute rate_limit_threshold.
-
#rate_limiter ⇒ Object
readonly
Returns the value of attribute rate_limiter.
Instance Method Summary collapse
- #announcements ⇒ Object
- #automod ⇒ Object
- #badges ⇒ Object
- #banned_events ⇒ Object
- #banned_users ⇒ Object
- #blocked_terms ⇒ Object
- #channels ⇒ Object
- #charity_campaigns ⇒ Object
- #chat_messages ⇒ Object
- #chatters ⇒ Object
- #clips ⇒ Object
- #connection ⇒ Object
- #custom_reward_redemptions ⇒ Object
- #custom_rewards ⇒ Object
- #emotes ⇒ Object
- #eventsub_conduits ⇒ Object
- #eventsub_subscriptions ⇒ Object
- #games ⇒ Object
- #goals ⇒ Object
- #hype_train_events ⇒ Object
-
#initialize(client_id:, access_token:, adapter: Faraday.default_adapter, rate_limit_threshold: 10, auto_retry_rate_limit: true, logger: nil) ⇒ Client
constructor
A new instance of Client.
- #moderator_events ⇒ Object
- #moderators ⇒ Object
- #polls ⇒ Object
- #predictions ⇒ Object
- #raids ⇒ Object
- #search ⇒ Object
- #shoutouts ⇒ Object
- #stream_markers ⇒ Object
- #stream_schedule ⇒ Object
- #streams ⇒ Object
- #subscriptions ⇒ Object
- #tags ⇒ Object
- #unban_requests ⇒ Object
- #users ⇒ Object
- #videos ⇒ Object
- #vips ⇒ Object
- #warnings ⇒ Object
- #whispers ⇒ Object
Constructor Details
#initialize(client_id:, access_token:, adapter: Faraday.default_adapter, rate_limit_threshold: 10, auto_retry_rate_limit: true, logger: nil) ⇒ Client
Returns a new instance of Client.
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/twitch/client.rb', line 8 def initialize( client_id:, access_token:, adapter: Faraday.default_adapter, rate_limit_threshold: 10, auto_retry_rate_limit: true, logger: nil ) @client_id = client_id @access_token = access_token @adapter = adapter @rate_limit_threshold = rate_limit_threshold @auto_retry_rate_limit = auto_retry_rate_limit @logger = logger @rate_limiter = RateLimiter.new(logger: logger) end |
Instance Attribute Details
#access_token ⇒ Object (readonly)
Returns the value of attribute access_token.
5 6 7 |
# File 'lib/twitch/client.rb', line 5 def access_token @access_token end |
#adapter ⇒ Object (readonly)
Returns the value of attribute adapter.
5 6 7 |
# File 'lib/twitch/client.rb', line 5 def adapter @adapter end |
#auto_retry_rate_limit ⇒ Object (readonly)
Returns the value of attribute auto_retry_rate_limit.
6 7 8 |
# File 'lib/twitch/client.rb', line 6 def auto_retry_rate_limit @auto_retry_rate_limit end |
#client_id ⇒ Object (readonly)
Returns the value of attribute client_id.
5 6 7 |
# File 'lib/twitch/client.rb', line 5 def client_id @client_id end |
#logger ⇒ Object (readonly)
Returns the value of attribute logger.
6 7 8 |
# File 'lib/twitch/client.rb', line 6 def logger @logger end |
#rate_limit_threshold ⇒ Object (readonly)
Returns the value of attribute rate_limit_threshold.
6 7 8 |
# File 'lib/twitch/client.rb', line 6 def rate_limit_threshold @rate_limit_threshold end |
#rate_limiter ⇒ Object (readonly)
Returns the value of attribute rate_limiter.
5 6 7 |
# File 'lib/twitch/client.rb', line 5 def rate_limiter @rate_limiter end |
Instance Method Details
#announcements ⇒ Object
125 126 127 |
# File 'lib/twitch/client.rb', line 125 def announcements AnnouncementsResource.new(self) end |
#automod ⇒ Object
145 146 147 |
# File 'lib/twitch/client.rb', line 145 def automod AutomodResource.new(self) end |
#badges ⇒ Object
37 38 39 |
# File 'lib/twitch/client.rb', line 37 def badges BadgesResource.new(self) end |
#banned_events ⇒ Object
61 62 63 |
# File 'lib/twitch/client.rb', line 61 def banned_events BannedEventsResource.new(self) end |
#banned_users ⇒ Object
65 66 67 |
# File 'lib/twitch/client.rb', line 65 def banned_users BannedUsersResource.new(self) end |
#blocked_terms ⇒ Object
149 150 151 |
# File 'lib/twitch/client.rb', line 149 def blocked_terms BlockedTermsResource.new(self) end |
#channels ⇒ Object
29 30 31 |
# File 'lib/twitch/client.rb', line 29 def channels ChannelsResource.new(self) end |
#charity_campaigns ⇒ Object
153 154 155 |
# File 'lib/twitch/client.rb', line 153 def charity_campaigns CharityCampaignsResource.new(self) end |
#chat_messages ⇒ Object
133 134 135 |
# File 'lib/twitch/client.rb', line 133 def ChatMessagesResource.new(self) end |
#chatters ⇒ Object
157 158 159 |
# File 'lib/twitch/client.rb', line 157 def chatters ChattersResource.new(self) end |
#clips ⇒ Object
49 50 51 |
# File 'lib/twitch/client.rb', line 49 def clips ClipsResource.new(self) end |
#connection ⇒ Object
173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 |
# File 'lib/twitch/client.rb', line 173 def connection @connection ||= Faraday.new(BASE_URL) do |conn| conn.request :authorization, :Bearer, access_token conn.headers = { "User-Agent" => "twitchrb/v#{VERSION} (github.com/deanpcmad/twitchrb)", "Client-ID": client_id } conn.request :json conn.response :json, content_type: "application/json" conn.adapter adapter, @stubs end end |
#custom_reward_redemptions ⇒ Object
113 114 115 |
# File 'lib/twitch/client.rb', line 113 def custom_reward_redemptions CustomRewardRedemptionsResource.new(self) end |
#custom_rewards ⇒ Object
109 110 111 |
# File 'lib/twitch/client.rb', line 109 def custom_rewards CustomRewardsResource.new(self) end |
#emotes ⇒ Object
33 34 35 |
# File 'lib/twitch/client.rb', line 33 def emotes EmotesResource.new(self) end |
#eventsub_conduits ⇒ Object
57 58 59 |
# File 'lib/twitch/client.rb', line 57 def eventsub_conduits EventsubConduitsResource.new(self) end |
#eventsub_subscriptions ⇒ Object
53 54 55 |
# File 'lib/twitch/client.rb', line 53 def eventsub_subscriptions EventsubSubscriptionsResource.new(self) end |
#games ⇒ Object
41 42 43 |
# File 'lib/twitch/client.rb', line 41 def games GamesResource.new(self) end |
#goals ⇒ Object
117 118 119 |
# File 'lib/twitch/client.rb', line 117 def goals GoalsResource.new(self) end |
#hype_train_events ⇒ Object
121 122 123 |
# File 'lib/twitch/client.rb', line 121 def hype_train_events HypeTrainEventsResource.new(self) end |
#moderator_events ⇒ Object
73 74 75 |
# File 'lib/twitch/client.rb', line 73 def moderator_events ModeratorEventsResource.new(self) end |
#moderators ⇒ Object
69 70 71 |
# File 'lib/twitch/client.rb', line 69 def moderators ModeratorsResource.new(self) end |
#polls ⇒ Object
77 78 79 |
# File 'lib/twitch/client.rb', line 77 def polls PollsResource.new(self) end |
#predictions ⇒ Object
81 82 83 |
# File 'lib/twitch/client.rb', line 81 def predictions PredictionsResource.new(self) end |
#raids ⇒ Object
129 130 131 |
# File 'lib/twitch/client.rb', line 129 def raids RaidsResource.new(self) end |
#search ⇒ Object
89 90 91 |
# File 'lib/twitch/client.rb', line 89 def search SearchResource.new(self) end |
#shoutouts ⇒ Object
161 162 163 |
# File 'lib/twitch/client.rb', line 161 def shoutouts ShoutoutsResource.new(self) end |
#stream_markers ⇒ Object
97 98 99 |
# File 'lib/twitch/client.rb', line 97 def stream_markers StreamMarkersResource.new(self) end |
#stream_schedule ⇒ Object
85 86 87 |
# File 'lib/twitch/client.rb', line 85 def stream_schedule StreamScheduleResource.new(self) end |
#streams ⇒ Object
93 94 95 |
# File 'lib/twitch/client.rb', line 93 def streams StreamsResource.new(self) end |
#subscriptions ⇒ Object
101 102 103 |
# File 'lib/twitch/client.rb', line 101 def subscriptions SubscriptionsResource.new(self) end |
#tags ⇒ Object
105 106 107 |
# File 'lib/twitch/client.rb', line 105 def TagsResource.new(self) end |
#unban_requests ⇒ Object
165 166 167 |
# File 'lib/twitch/client.rb', line 165 def unban_requests UnbanRequestsResource.new(self) end |
#users ⇒ Object
25 26 27 |
# File 'lib/twitch/client.rb', line 25 def users UsersResource.new(self) end |
#videos ⇒ Object
45 46 47 |
# File 'lib/twitch/client.rb', line 45 def videos VideosResource.new(self) end |
#vips ⇒ Object
137 138 139 |
# File 'lib/twitch/client.rb', line 137 def vips VipsResource.new(self) end |
#warnings ⇒ Object
169 170 171 |
# File 'lib/twitch/client.rb', line 169 def warnings WarningsResource.new(self) end |
#whispers ⇒ Object
141 142 143 |
# File 'lib/twitch/client.rb', line 141 def whispers WhispersResource.new(self) end |