Class: Twitch::CustomReward

Inherits:
Object
  • Object
show all
Defined in:
lib/twitch/custom_reward.rb

Overview

Data object for Twitch custom rewards

Defined Under Namespace

Classes: CustomRewardImage

Instance Attribute Summary collapse

Instance Method Summary collapse

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_colorObject (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_idObject (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_loginObject (readonly)

The broadcaster’s login name.



25
26
27
# File 'lib/twitch/custom_reward.rb', line 25

def 
  @broadcaster_login
end

#broadcaster_nameObject (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_atObject (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

#costObject (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_imageObject (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_settingObject (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

#idObject (readonly)

The ID that uniquely identifies this custom reward.



29
30
31
# File 'lib/twitch/custom_reward.rb', line 29

def id
  @id
end

#imageObject (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_enabledObject (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_stockObject (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_pausedObject (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_requiredObject (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_settingObject (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_settingObject (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

#promptObject (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_streamObject (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_queueObject (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

#titleObject (readonly)

The title of the reward.



31
32
33
# File 'lib/twitch/custom_reward.rb', line 31

def title
  @title
end