Class: Twitch::Client
- Inherits:
-
Object
- Object
- Twitch::Client
- Includes:
- CustomRewards, Extensions, Games, Moderation, Streams, Subscriptions, Users
- Defined in:
- lib/twitch/client.rb,
lib/twitch/client/games.rb,
lib/twitch/client/users.rb,
lib/twitch/client/streams.rb,
lib/twitch/client/extensions.rb,
lib/twitch/client/moderation.rb,
lib/twitch/client/subscriptions.rb,
lib/twitch/client/custom_rewards.rb
Overview
Core class for requests
Defined Under Namespace
Modules: CustomRewards, Extensions, Games, Moderation, Streams, Subscriptions, Users
Constant Summary collapse
- CONNECTION =
Base connection to Helix API.
Faraday.new( 'https://api.twitch.tv/helix', { headers: { 'User-Agent': "twitch-api ruby client #{Twitch::VERSION}" } } ) do |faraday| faraday.request :retry, exceptions: [*Faraday::Retry::Middleware::DEFAULT_EXCEPTIONS, Faraday::ConnectionFailed] faraday.response :parse_dates faraday.request :json faraday.response :json end
Instance Attribute Summary collapse
-
#tokens ⇒ Object
readonly
Returns the value of attribute tokens.
Instance Method Summary collapse
- #create_clip(options = {}) ⇒ Object
- #create_entitlement_grant_url(options = {}) ⇒ Object
- #get_bits_leaderboard(options = {}) ⇒ Object
- #get_channel_editors(options = {}) ⇒ Object
- #get_channels(options = {}) ⇒ Object
- #get_cheermotes(options = {}) ⇒ Object
- #get_clips(options = {}) ⇒ Object
- #get_videos(options = {}) ⇒ Object
-
#initialize(tokens:) ⇒ Client
constructor
Initializes a Twitch client.
- #modify_channel(options = {}) ⇒ Object
- #search_categories(options = {}) ⇒ Object
- #search_channels(options = {}) ⇒ Object
- #start_commercial(options = {}) ⇒ Object
Methods included from CustomRewards
#create_custom_reward, #delete_custom_reward, #get_custom_reward, #get_custom_reward_redemption, #update_custom_reward, #update_redemption_status
Methods included from Users
#get_users, #get_users_follows, #update_user
Methods included from Subscriptions
Methods included from Streams
#create_stream_marker, #get_stream_key, #get_stream_markers, #get_streams, #get_streams_metadata
Methods included from Moderation
#check_automod_status, #get_banned_events, #get_banned_users, #get_moderator_events, #get_moderators
Methods included from Games
#get_game_analytics, #get_games, #get_top_games
Methods included from Extensions
#get_user_active_extensions, #get_user_extensions, #update_user_extensions
Constructor Details
#initialize(tokens:) ⇒ Client
Initializes a Twitch client.
-
tokens [TwitchOAuth2::Tokens] Tokens object with their refreshing logic inside.
All client and authentication information (‘client_id`, `:scopes`, etc.) stores there.
59 60 61 62 63 64 65 |
# File 'lib/twitch/client.rb', line 59 def initialize(tokens:) @tokens = tokens CONNECTION.headers['Client-ID'] = self.tokens.client.client_id end |
Instance Attribute Details
#tokens ⇒ Object (readonly)
Returns the value of attribute tokens.
53 54 55 |
# File 'lib/twitch/client.rb', line 53 def tokens @tokens end |
Instance Method Details
#create_clip(options = {}) ⇒ Object
67 68 69 |
# File 'lib/twitch/client.rb', line 67 def create_clip( = {}) initialize_response Clip, post('clips', ) end |
#create_entitlement_grant_url(options = {}) ⇒ Object
71 72 73 |
# File 'lib/twitch/client.rb', line 71 def create_entitlement_grant_url( = {}) initialize_response EntitlementGrantUrl, post('entitlements/upload', ) end |
#get_bits_leaderboard(options = {}) ⇒ Object
79 80 81 |
# File 'lib/twitch/client.rb', line 79 def get_bits_leaderboard( = {}) initialize_response BitsLeader, get('bits/leaderboard', ) end |
#get_channel_editors(options = {}) ⇒ Object
137 138 139 |
# File 'lib/twitch/client.rb', line 137 def get_channel_editors( = {}) initialize_response Editor, get('channels/editors', ) end |
#get_channels(options = {}) ⇒ Object
113 114 115 |
# File 'lib/twitch/client.rb', line 113 def get_channels( = {}) initialize_response Channel, get('channels', ) end |
#get_cheermotes(options = {}) ⇒ Object
83 84 85 |
# File 'lib/twitch/client.rb', line 83 def get_cheermotes( = {}) initialize_response Cheermote, get('bits/cheermotes', ) end |
#get_clips(options = {}) ⇒ Object
75 76 77 |
# File 'lib/twitch/client.rb', line 75 def get_clips( = {}) initialize_response Clip, get('clips', ) end |
#get_videos(options = {}) ⇒ Object
102 103 104 |
# File 'lib/twitch/client.rb', line 102 def get_videos( = {}) initialize_response Video, get('videos', ) end |
#modify_channel(options = {}) ⇒ Object
123 124 125 126 127 128 129 |
# File 'lib/twitch/client.rb', line 123 def modify_channel( = {}) response = patch('channels', ) return true if response.body.empty? response.body end |
#search_categories(options = {}) ⇒ Object
142 143 144 |
# File 'lib/twitch/client.rb', line 142 def search_categories( = {}) initialize_response Category, get('search/categories', ) end |
#search_channels(options = {}) ⇒ Object
118 119 120 |
# File 'lib/twitch/client.rb', line 118 def search_channels( = {}) initialize_response Channel, get('search/channels', ) end |
#start_commercial(options = {}) ⇒ Object
132 133 134 |
# File 'lib/twitch/client.rb', line 132 def start_commercial( = {}) initialize_response nil, post('channels/commercial', ) end |