Class: Twitch::CustomReward
- Inherits:
-
Object
- Object
- Twitch::CustomReward
- Defined in:
- lib/twitch/custom_reward.rb
Overview
Data object for Twitch custom rewards
Defined Under Namespace
Classes: CustomRewardImage
Instance Attribute Summary collapse
-
#background_color ⇒ Object
readonly
The background color to use for the reward.
-
#broadcaster_id ⇒ Object
readonly
The ID that uniquely identifies the broadcaster.
-
#broadcaster_login ⇒ Object
readonly
The broadcaster’s login name.
-
#broadcaster_name ⇒ Object
readonly
The broadcaster’s display name.
-
#cooldown_expires_at ⇒ Object
readonly
The timestamp of when the cooldown period expires.
-
#cost ⇒ Object
readonly
The cost of the reward in Channel Points.
-
#default_image ⇒ Object
readonly
A set of default images for the reward.
-
#global_cooldown_setting ⇒ Object
readonly
The settings used to determine whether to apply a cooldown period between redemptions and the length of the cooldown.
-
#id ⇒ Object
readonly
The ID that uniquely identifies this custom reward.
-
#image ⇒ Object
readonly
A set of custom images for the reward.
-
#is_enabled ⇒ Object
readonly
A Boolean value that determines whether the reward is enabled.
-
#is_in_stock ⇒ Object
readonly
A Boolean value that determines whether the reward is currently in stock.
-
#is_paused ⇒ Object
readonly
A Boolean value that determines whether the reward is currently paused.
-
#is_user_input_required ⇒ Object
readonly
A Boolean value that determines whether the user must enter information when redeeming the reward.
-
#max_per_stream_setting ⇒ Object
readonly
The settings used to determine whether to apply a maximum to the number of redemptions allowed per live stream.
-
#max_per_user_per_stream_setting ⇒ Object
readonly
The settings used to determine whether to apply a maximum to the number of redemptions allowed per user per live stream.
-
#prompt ⇒ Object
readonly
The prompt shown to the viewer when they redeem the reward if user input is required (see the ‘is_user_input_required` field).
-
#redemptions_redeemed_current_stream ⇒ Object
readonly
The number of redemptions redeemed during the current live stream.
-
#should_redemptions_skip_request_queue ⇒ Object
readonly
A Boolean value that determines whether redemptions should be set to FULFILLED status immediately when a reward is redeemed.
-
#title ⇒ Object
readonly
The title of the reward.
Instance Method Summary collapse
-
#initialize(attributes = {}) ⇒ CustomReward
constructor
A new instance of CustomReward.
Constructor Details
#initialize(attributes = {}) ⇒ CustomReward
Returns a new instance of CustomReward.
83 84 85 86 87 88 89 |
# File 'lib/twitch/custom_reward.rb', line 83 def initialize(attributes = {}) attributes.each do |key, value| value = CustomRewardImage.new(value) if IMAGE_ATTRS.include?(key) && !value.nil? instance_variable_set "@#{key}", value end end |
Instance Attribute Details
#background_color ⇒ Object (readonly)
The background color to use for the reward. The color is in Hex format (for example, ‘#00E5CB`).
44 45 46 |
# File 'lib/twitch/custom_reward.rb', line 44 def background_color @background_color end |
#broadcaster_id ⇒ Object (readonly)
The ID that uniquely identifies the broadcaster.
23 24 25 |
# File 'lib/twitch/custom_reward.rb', line 23 def broadcaster_id @broadcaster_id end |
#broadcaster_login ⇒ Object (readonly)
The broadcaster’s login name.
25 26 27 |
# File 'lib/twitch/custom_reward.rb', line 25 def broadcaster_login @broadcaster_login end |
#broadcaster_name ⇒ Object (readonly)
The broadcaster’s display name.
27 28 29 |
# File 'lib/twitch/custom_reward.rb', line 27 def broadcaster_name @broadcaster_name end |
#cooldown_expires_at ⇒ Object (readonly)
The timestamp of when the cooldown period expires. Is ‘nil` if the reward isn’t in a cooldown state. See the `global_cooldown_setting` field.
78 79 80 |
# File 'lib/twitch/custom_reward.rb', line 78 def cooldown_expires_at @cooldown_expires_at end |
#cost ⇒ Object (readonly)
The cost of the reward in Channel Points.
36 37 38 |
# File 'lib/twitch/custom_reward.rb', line 36 def cost @cost end |
#default_image ⇒ Object (readonly)
A set of default images for the reward.
41 42 43 |
# File 'lib/twitch/custom_reward.rb', line 41 def default_image @default_image end |
#global_cooldown_setting ⇒ Object (readonly)
The settings used to determine whether to apply a cooldown period between redemptions and the length of the cooldown.
59 60 61 |
# File 'lib/twitch/custom_reward.rb', line 59 def global_cooldown_setting @global_cooldown_setting end |
#id ⇒ Object (readonly)
The ID that uniquely identifies this custom reward.
29 30 31 |
# File 'lib/twitch/custom_reward.rb', line 29 def id @id end |
#image ⇒ Object (readonly)
A set of custom images for the reward. This field is ‘nil` if the broadcaster didn’t upload images.
39 40 41 |
# File 'lib/twitch/custom_reward.rb', line 39 def image @image end |
#is_enabled ⇒ Object (readonly)
A Boolean value that determines whether the reward is enabled. Is ‘true` if enabled; otherwise, `false`. Disabled rewards aren’t shown to the user.
47 48 49 |
# File 'lib/twitch/custom_reward.rb', line 47 def is_enabled @is_enabled end |
#is_in_stock ⇒ Object (readonly)
A Boolean value that determines whether the reward is currently in stock. Is ‘true` if the reward is in stock. Viewers can’t redeem out of stock rewards.
65 66 67 |
# File 'lib/twitch/custom_reward.rb', line 65 def is_in_stock @is_in_stock end |
#is_paused ⇒ Object (readonly)
A Boolean value that determines whether the reward is currently paused. Is ‘true` if the reward is paused. Viewers can’t redeem paused rewards.
62 63 64 |
# File 'lib/twitch/custom_reward.rb', line 62 def is_paused @is_paused end |
#is_user_input_required ⇒ Object (readonly)
A Boolean value that determines whether the user must enter information when redeeming the reward. Is ‘true` if the user is prompted.
50 51 52 |
# File 'lib/twitch/custom_reward.rb', line 50 def is_user_input_required @is_user_input_required end |
#max_per_stream_setting ⇒ Object (readonly)
The settings used to determine whether to apply a maximum to the number of redemptions allowed per live stream.
53 54 55 |
# File 'lib/twitch/custom_reward.rb', line 53 def max_per_stream_setting @max_per_stream_setting end |
#max_per_user_per_stream_setting ⇒ Object (readonly)
The settings used to determine whether to apply a maximum to the number of redemptions allowed per user per live stream.
56 57 58 |
# File 'lib/twitch/custom_reward.rb', line 56 def max_per_user_per_stream_setting @max_per_user_per_stream_setting end |
#prompt ⇒ Object (readonly)
The prompt shown to the viewer when they redeem the reward if user input is required (see the ‘is_user_input_required` field).
34 35 36 |
# File 'lib/twitch/custom_reward.rb', line 34 def prompt @prompt end |
#redemptions_redeemed_current_stream ⇒ Object (readonly)
The number of redemptions redeemed during the current live stream. The number counts against the ‘max_per_stream_setting` limit. This field is `nil` if the broadcaster’s stream isn’t live or `max_per_stream_setting` isn’t enabled.
74 75 76 |
# File 'lib/twitch/custom_reward.rb', line 74 def redemptions_redeemed_current_stream @redemptions_redeemed_current_stream end |
#should_redemptions_skip_request_queue ⇒ Object (readonly)
A Boolean value that determines whether redemptions should be set to FULFILLED status immediately when a reward is redeemed. If ‘false`, status is set to UNFULFILLED and follows the normal request queue process.
69 70 71 |
# File 'lib/twitch/custom_reward.rb', line 69 def should_redemptions_skip_request_queue @should_redemptions_skip_request_queue end |
#title ⇒ Object (readonly)
The title of the reward.
31 32 33 |
# File 'lib/twitch/custom_reward.rb', line 31 def title @title end |