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:



185
186
187
# File 'lib/growsurf_ruby/resources/campaign/rewards.rb', line 185

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, title: 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

  • title (String)

    Body param

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

Returns:

See Also:



77
78
79
80
81
82
83
84
85
86
# File 'lib/growsurf_ruby/resources/campaign/rewards.rb', line 77

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

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

Deletes a program reward.

Parameters:

  • reward_id (String)

    Program reward ID.

  • id (String)

    GrowSurf program ID.

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

Returns:

See Also:



168
169
170
171
172
173
174
175
176
177
178
179
180
# File 'lib/growsurf_ruby/resources/campaign/rewards.rb', line 168

def delete(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/rewards/%2$s", id, 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/rewards", id],
    model: GrowsurfRuby::Models::Campaign::CampaignRewardListResponse,
    options: params[:request_options]
  )
end

#update(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, title: nil, request_options: {}) ⇒ GrowsurfRuby::Models::Campaign::Reward

Updates an existing program reward. Only the fields you send are changed; type is immutable and must not be supplied.

Parameters:

  • reward_id (String)

    Path param: Program 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

  • title (String)

    Body param

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

Returns:

See Also:



140
141
142
143
144
145
146
147
148
149
150
151
152
153
# File 'lib/growsurf_ruby/resources/campaign/rewards.rb', line 140

def update(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/rewards/%2$s", id, reward_id],
    body: parsed,
    model: GrowsurfRuby::Models::Campaign::Reward,
    options: options
  )
end