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:



193
194
195
# File 'lib/growsurf_ruby/resources/campaign/rewards.rb', line 193

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_active: 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 reward for a program. The reward type must be compatible with the program type.

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

  • description (String)

    Body param

  • image_url (String)

    Body param

  • is_active (Boolean)

    Body param

  • is_unlimited (Boolean)

    Body param

  • is_visible (Boolean)

    Body param

  • 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

  • next_milestone_suffix (String)

    Body param

  • number_of_winners (Integer)

    Body param

  • order (Integer)

    Body param

  • referral_coupon_code (String)

    Body param

  • 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:



81
82
83
84
85
86
87
88
89
90
# File 'lib/growsurf_ruby/resources/campaign/rewards.rb', line 81

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.

Parameters:

  • campaign_reward_id (String)

    Campaign reward ID.

  • id (String)

    GrowSurf program ID.

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

Returns:

See Also:



176
177
178
179
180
181
182
183
184
185
186
187
188
# File 'lib/growsurf_ruby/resources/campaign/rewards.rb', line 176

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 active, visible, and enabled rewards configured for a program.

Parameters:

Returns:



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

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_active: 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. Only the fields you send are changed; type is immutable and must not be supplied.

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

  • description (String)

    Body param

  • image_url (String)

    Body param

  • is_active (Boolean)

    Body param

  • is_unlimited (Boolean)

    Body param

  • is_visible (Boolean)

    Body param

  • 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

  • next_milestone_suffix (String)

    Body param

  • number_of_winners (Integer)

    Body param

  • order (Integer)

    Body param

  • referral_coupon_code (String)

    Body param

  • 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:



148
149
150
151
152
153
154
155
156
157
158
159
160
161
# File 'lib/growsurf_ruby/resources/campaign/rewards.rb', line 148

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