Class: Twitch::SubscriptionsResource
- Defined in:
- lib/twitch/resources/subscriptions.rb
Instance Attribute Summary
Attributes inherited from Resource
Instance Method Summary collapse
-
#counts(broadcaster_id:) ⇒ Object
Grabs the number of Subscribers and Subscriber Points a broadcaster has Broadcaster ID must match the user in the OAuth token Required scope: channel:read:subscriptions.
-
#is_subscribed(broadcaster_id:, user_id:, **params) ⇒ Object
Checks if a User is subscribed to a Broadcaster If 404 then the user is not subscribed User ID must match the user in the OAuth token Required scope: user:read:subscriptions.
-
#list(broadcaster_id:, **params) ⇒ Object
Get all subscriptions for a broadcaster Broadcaster ID must match the user in the OAuth token Required scope: channel:read:subscriptions.
Methods inherited from Resource
Constructor Details
This class inherits a constructor from Twitch::Resource
Instance Method Details
#counts(broadcaster_id:) ⇒ Object
Grabs the number of Subscribers and Subscriber Points a broadcaster has Broadcaster ID must match the user in the OAuth token Required scope: channel:read:subscriptions
24 25 26 27 28 |
# File 'lib/twitch/resources/subscriptions.rb', line 24 def counts(broadcaster_id:) response = get_request("subscriptions", params: { broadcaster_id: broadcaster_id }) SubscriptionCount.new(count: response.body["total"], points: response.body["points"]) end |
#is_subscribed(broadcaster_id:, user_id:, **params) ⇒ Object
Checks if a User is subscribed to a Broadcaster If 404 then the user is not subscribed User ID must match the user in the OAuth token Required scope: user:read:subscriptions
15 16 17 18 19 |
# File 'lib/twitch/resources/subscriptions.rb', line 15 def is_subscribed(broadcaster_id:, user_id:, **params) attrs = { broadcaster_id: broadcaster_id, user_id: user_id } response = get_request("subscriptions/user", params: attrs.merge(params)) Collection.from_response(response, type: Subscription) end |
#list(broadcaster_id:, **params) ⇒ Object
Get all subscriptions for a broadcaster Broadcaster ID must match the user in the OAuth token Required scope: channel:read:subscriptions
6 7 8 9 |
# File 'lib/twitch/resources/subscriptions.rb', line 6 def list(broadcaster_id:, **params) response = get_request("subscriptions", params: params.merge(broadcaster_id: broadcaster_id)) Collection.from_response(response, type: Subscription) end |