Class: GrowsurfRuby::Resources::Campaign::Rewards

Inherits:
Object
  • Object
show all
Defined in:
lib/growsurf_ruby/resources/campaign/rewards.rb,
sig/growsurf_ruby/resources/campaign/rewards.rbs

Instance Method Summary collapse

Constructor Details

#initialize(client:) ⇒ Rewards

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns a new instance of Rewards.

Parameters:



201
202
203
# File 'lib/growsurf_ruby/resources/campaign/rewards.rb', line 201

def initialize(client:)
  @client = client
end

Instance Method Details

#create(id, type:, commission_structure: nil, conversions_required: nil, coupon_code: nil, description: nil, image_url: nil, is_unlimited: nil, is_visible: nil, limit: nil, limit_duration: nil, metadata: nil, next_milestone_prefix: nil, next_milestone_suffix: nil, number_of_winners: nil, order: nil, referral_coupon_code: nil, referral_description: nil, referred_reward_upfront: nil, referred_value: nil, title: nil, value: nil, request_options: {}) ⇒ GrowsurfRuby::Models::Campaign::Reward

Creates a new campaign reward (CampaignReward) with a GrowSurf-assigned ID. The reward type must be compatible with the program type (affiliate programs support only AFFILIATE rewards; referral programs support all other types). Enabling an active reward of a type automatically enables that reward type on the program.

Parameters:

  • id (String)

    Path param: GrowSurf program ID.

  • type (Symbol, GrowsurfRuby::Models::Campaign::RewardCreateParams::Type)

    Body param: The reward type. Immutable after creation.

  • commission_structure (GrowsurfRuby::Models::CommissionStructure)

    Body param

  • conversions_required (Integer)

    Body param

  • coupon_code (String)

    Body param: Legacy static coupon code shown to the referrer in the reward-won emai

  • description (String)

    Body param

  • image_url (String)

    Body param

  • is_unlimited (Boolean)

    Body param: Whether the reward can be earned an unlimited number of times. Defaul

  • is_visible (Boolean)

    Body param: Whether the reward is enabled. When false the reward is disabled: hi

  • limit (Integer)

    Body param

  • limit_duration (Symbol, GrowsurfRuby::Models::Campaign::RewardCreateParams::LimitDuration)

    Body param

  • metadata (Hash{Symbol=>Object})

    Body param: Custom key/value metadata (single-level; values are stored as string

  • next_milestone_prefix (String)

    Body param: Text shown before a participant's referral count in milestone-prog

  • next_milestone_suffix (String)

    Body param: Text shown after a participant's referral count in milestone-progr

  • number_of_winners (Integer)

    Body param: The number of winners (LEADERBOARD rewards only). With `limitDur

  • order (Integer)

    Body param

  • referral_coupon_code (String)

    Body param: Legacy static coupon code shown to the referred friend (double-si

  • referral_description (String)

    Body param

  • referred_reward_upfront (Boolean)

    Body param

  • referred_value (GrowsurfRuby::Models::RewardTaxValuation)

    Body param: Tax valuation for the referred friend's side of a double-sided rewa

  • title (String)

    Body param

  • value (GrowsurfRuby::Models::RewardTaxValuation)

    Body param: Tax valuation for the reward (the referrer's side of a double-sided

  • request_options (GrowsurfRuby::RequestOptions, Hash{Symbol=>Object}, nil)

Returns:

See Also:



84
85
86
87
88
89
90
91
92
93
# File 'lib/growsurf_ruby/resources/campaign/rewards.rb', line 84

def create(id, params)
  parsed, options = GrowsurfRuby::Campaign::RewardCreateParams.dump_request(params)
  @client.request(
    method: :post,
    path: ["campaign/%1$s/reward-configs", id],
    body: parsed,
    model: GrowsurfRuby::Models::Campaign::Reward,
    options: options
  )
end

#delete(campaign_reward_id, id:, request_options: {}) ⇒ GrowsurfRuby::Models::Campaign::DeleteRewardResponse

Deletes a campaign reward (CampaignReward). The reward is deactivated, removed from the program's reward set, and any connected upfront-discount coupons are cleaned up. If campaign copy still references any of the reward's metadata keys via {{campaignReward[…]}} tokens, the delete returns a 409 listing the referencing fields — update those fields first.

Parameters:

  • campaign_reward_id (String)

    Campaign reward ID.

  • id (String)

    GrowSurf program ID.

  • request_options (GrowsurfRuby::RequestOptions, Hash{Symbol=>Object}, nil)

Returns:

See Also:



184
185
186
187
188
189
190
191
192
193
194
195
196
# File 'lib/growsurf_ruby/resources/campaign/rewards.rb', line 184

def delete(campaign_reward_id, params)
  parsed, options = GrowsurfRuby::Campaign::RewardDeleteParams.dump_request(params)
  id =
    parsed.delete(:id) do
      raise ArgumentError.new("missing required path argument #{_1}")
    end
  @client.request(
    method: :delete,
    path: ["campaign/%1$s/reward-configs/%2$s", id, campaign_reward_id],
    model: GrowsurfRuby::Models::Campaign::DeleteRewardResponse,
    options: options
  )
end

#list(id, request_options: {}) ⇒ GrowsurfRuby::Models::Campaign::CampaignRewardListResponse

Retrieves the list of a program's configured rewards (CampaignRewards) — the same set embedded in the rewards array of the campaign response. Delete a reward with DELETE /campaign/{id}/reward-configs/{campaignRewardId}.

Parameters:

Returns:



18
19
20
21
22
23
24
25
# File 'lib/growsurf_ruby/resources/campaign/rewards.rb', line 18

def list(id, params = {})
  @client.request(
    method: :get,
    path: ["campaign/%1$s/reward-configs", id],
    model: GrowsurfRuby::Models::Campaign::CampaignRewardListResponse,
    options: params[:request_options]
  )
end

#update(campaign_reward_id, id:, commission_structure: nil, conversions_required: nil, coupon_code: nil, description: nil, image_url: nil, is_unlimited: nil, is_visible: nil, limit: nil, limit_duration: nil, metadata: nil, next_milestone_prefix: nil, next_milestone_suffix: nil, number_of_winners: nil, order: nil, referral_coupon_code: nil, referral_description: nil, referred_reward_upfront: nil, referred_value: nil, title: nil, value: nil, request_options: {}) ⇒ GrowsurfRuby::Models::Campaign::Reward

Updates an existing campaign reward (CampaignReward). The reward type is immutable and cannot be changed. When the update replaces metadata, renamed keys automatically rewrite any {{campaignReward[…]}} references in campaign copy; removing a key that campaign copy still references returns a 409 listing the referencing fields.

Parameters:

  • campaign_reward_id (String)

    Path param: Campaign reward ID.

  • id (String)

    Path param: GrowSurf program ID.

  • commission_structure (GrowsurfRuby::Models::CommissionStructure)

    Body param

  • conversions_required (Integer)

    Body param

  • coupon_code (String)

    Body param: Legacy static coupon code shown to the referrer in the reward-won emai

  • description (String)

    Body param

  • image_url (String)

    Body param

  • is_unlimited (Boolean)

    Body param: Whether the reward can be earned an unlimited number of times. Defaul

  • is_visible (Boolean)

    Body param: Whether the reward is enabled. When false the reward is disabled: hi

  • limit (Integer)

    Body param

  • limit_duration (Symbol, GrowsurfRuby::Models::Campaign::RewardUpdateParams::LimitDuration)

    Body param

  • metadata (Hash{Symbol=>Object})

    Body param: Custom key/value metadata (single-level; values are stored as string

  • next_milestone_prefix (String)

    Body param: Text shown before a participant's referral count in milestone-prog

  • next_milestone_suffix (String)

    Body param: Text shown after a participant's referral count in milestone-progr

  • number_of_winners (Integer)

    Body param: The number of winners (LEADERBOARD rewards only). With `limitDur

  • order (Integer)

    Body param

  • referral_coupon_code (String)

    Body param: Legacy static coupon code shown to the referred friend (double-si

  • referral_description (String)

    Body param

  • referred_reward_upfront (Boolean)

    Body param

  • referred_value (GrowsurfRuby::Models::RewardTaxValuation)

    Body param: Tax valuation for the referred friend's side of a double-sided rewa

  • title (String)

    Body param

  • value (GrowsurfRuby::Models::RewardTaxValuation)

    Body param: Tax valuation for the reward (the referrer's side of a double-sided

  • request_options (GrowsurfRuby::RequestOptions, Hash{Symbol=>Object}, nil)

Returns:

See Also:



152
153
154
155
156
157
158
159
160
161
162
163
164
165
# File 'lib/growsurf_ruby/resources/campaign/rewards.rb', line 152

def update(campaign_reward_id, params)
  parsed, options = GrowsurfRuby::Campaign::RewardUpdateParams.dump_request(params)
  id =
    parsed.delete(:id) do
      raise ArgumentError.new("missing required path argument #{_1}")
    end
  @client.request(
    method: :patch,
    path: ["campaign/%1$s/reward-configs/%2$s", id, campaign_reward_id],
    body: parsed,
    model: GrowsurfRuby::Models::Campaign::Reward,
    options: options
  )
end