Class: Twitch::CustomRewardRedemptionsResource

Inherits:
Resource
  • Object
show all
Defined in:
lib/twitch/resources/custom_reward_redemptions.rb

Instance Attribute Summary

Attributes inherited from Resource

#client

Instance Method Summary collapse

Methods inherited from Resource

#initialize

Constructor Details

This class inherits a constructor from Twitch::Resource

Instance Method Details

#list(broadcaster_id:, reward_id:, status:, **params) ⇒ Object

Required scope: channel:read:redemptions Broadcaster ID must match the user in the OAuth token



5
6
7
8
9
# File 'lib/twitch/resources/custom_reward_redemptions.rb', line 5

def list(broadcaster_id:, reward_id:, status:, **params)
  attributes = { broadcaster_id: broadcaster_id, reward_id: reward_id, status: status.upcase }
  response = get_request("channel_points/custom_rewards/redemptions", params: attributes.merge(params))
  Collection.from_response(response, type: CustomRewardRedemption)
end

#update(broadcaster_id:, reward_id:, redemption_id:, status:) ⇒ Object

Required scope: channel:manage:redemptions Broadcaster ID must match the user in the OAuth token



13
14
15
16
17
18
19
# File 'lib/twitch/resources/custom_reward_redemptions.rb', line 13

def update(broadcaster_id:, reward_id:, redemption_id:, status:)
  attributes = { status: status.upcase }
  url = "channel_points/custom_rewards/redemptions?broadcaster_id=#{broadcaster_id}&reward_id=#{reward_id}&id=#{redemption_id}&status=#{status.upcase}"
  response = patch_request(url, body: attributes)

  CustomRewardRedemption.new(response.body.dig("data")[0]) if response.success?
end