Class: Scrimmage::Rewards
- Inherits:
-
Object
- Object
- Scrimmage::Rewards
- Extended by:
- Forwardable
- Defined in:
- lib/scrimmage/rewards.rb
Instance Attribute Summary collapse
-
#client ⇒ Object
readonly
Returns the value of attribute client.
Instance Method Summary collapse
-
#initialize(client: Scrimmage.default_client) ⇒ Rewards
constructor
A new instance of Rewards.
-
#track_rewardable(user_id, data_type, rewards = []) ⇒ Array<Scrimmage::Object>
Track one or multiple rewards.
-
#track_rewardable_once(user_id, data_type, unique_id, reward) ⇒ Scrimmage::Object
Track Rewardable with a single event.
Constructor Details
#initialize(client: Scrimmage.default_client) ⇒ Rewards
Returns a new instance of Rewards.
7 8 9 |
# File 'lib/scrimmage/rewards.rb', line 7 def initialize(client: Scrimmage.default_client) @client = client end |
Instance Attribute Details
#client ⇒ Object (readonly)
Returns the value of attribute client.
5 6 7 |
# File 'lib/scrimmage/rewards.rb', line 5 def client @client end |
Instance Method Details
#track_rewardable(user_id, data_type, rewards = []) ⇒ Array<Scrimmage::Object>
Track one or multiple rewards
20 21 22 23 24 25 |
# File 'lib/scrimmage/rewards.rb', line 20 def track_rewardable(user_id, data_type, rewards = []) rewards = [rewards] unless rewards.is_a? Array rewards.map do |reward| client.create_integration_reward(user_id, data_type, reward) end end |
#track_rewardable_once(user_id, data_type, unique_id, reward) ⇒ Scrimmage::Object
Track Rewardable with a single event
37 38 39 |
# File 'lib/scrimmage/rewards.rb', line 37 def track_rewardable_once(user_id, data_type, unique_id, reward) client.create_integration_reward(user_id, data_type, unique_id, reward) end |