Class: GrowsurfRuby::Resources::Campaign::Participant

Inherits:
Object
  • Object
show all
Defined in:
lib/growsurf_ruby/resources/campaign/participant.rb

Instance Method Summary collapse

Constructor Details

#initialize(client:) ⇒ Participant

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 Participant.

Parameters:



440
441
442
# File 'lib/growsurf_ruby/resources/campaign/participant.rb', line 440

def initialize(client:)
  @client = client
end

Instance Method Details

#add(id, email:, fingerprint: nil, first_name: nil, ip_address: nil, last_name: nil, metadata: nil, referral_status: nil, referred_by: nil, request_options: {}) ⇒ GrowsurfRuby::Models::Campaign::CampaignParticipant

Adds a new participant to the program. If the email already exists, the existing participant is returned.

Parameters:

Returns:

See Also:



133
134
135
136
137
138
139
140
141
142
# File 'lib/growsurf_ruby/resources/campaign/participant.rb', line 133

def add(id, params)
  parsed, options = GrowsurfRuby::Campaign::ParticipantAddParams.dump_request(params)
  @client.request(
    method: :post,
    path: ["campaign/%1$s/participant", id],
    body: parsed,
    model: GrowsurfRuby::Campaign::CampaignParticipant,
    options: options
  )
end

#delete(participant_id_or_email, id:, request_options: {}) ⇒ GrowsurfRuby::Models::Campaign::ParticipantDeleteResponse

Removes a participant by GrowSurf participant ID or email address.

Parameters:

  • participant_id_or_email (String)

    GrowSurf participant ID or URL-encoded participant email address.

  • id (String)

    GrowSurf program ID.

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

Returns:

See Also:



91
92
93
94
95
96
97
98
99
100
101
102
103
# File 'lib/growsurf_ruby/resources/campaign/participant.rb', line 91

def delete(participant_id_or_email, params)
  parsed, options = GrowsurfRuby::Campaign::ParticipantDeleteParams.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/participant/%2$s", id, participant_id_or_email],
    model: GrowsurfRuby::Models::Campaign::ParticipantDeleteResponse,
    options: options
  )
end

#list_commissions(participant_id_or_email, id:, limit: nil, next_id: nil, status: nil, request_options: {}) ⇒ GrowsurfRuby::Models::ParticipantCommissionList

Retrieves a paged list of commissions earned by a participant.

Parameters:

  • participant_id_or_email (String)

    Path param: GrowSurf participant ID or URL-encoded participant email address.

  • id (String)

    Path param: GrowSurf program ID.

  • limit (Integer)

    Query param: Number of results to return. Maximum 100.

  • next_id (String)

    Query param: ID to start the next paged result set with.

  • status (Symbol, GrowsurfRuby::Models::Campaign::ParticipantListCommissionsParams::Status)

    Query param: Participant commission status.

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

Returns:

See Also:



163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
# File 'lib/growsurf_ruby/resources/campaign/participant.rb', line 163

def list_commissions(participant_id_or_email, params)
  parsed, options = GrowsurfRuby::Campaign::ParticipantListCommissionsParams.dump_request(params)
  query = GrowsurfRuby::Internal::Util.encode_query_params(parsed)
  id =
    parsed.delete(:id) do
      raise ArgumentError.new("missing required path argument #{_1}")
    end
  @client.request(
    method: :get,
    path: ["campaign/%1$s/participant/%2$s/commissions", id, participant_id_or_email],
    query: query.transform_keys(next_id: "nextId"),
    model: GrowsurfRuby::ParticipantCommissionList,
    options: options
  )
end

#list_payouts(participant_id_or_email, id:, limit: nil, next_id: nil, status: nil, request_options: {}) ⇒ GrowsurfRuby::Models::ParticipantPayoutList

Retrieves a paged list of payouts that belong to a participant.

Parameters:

  • participant_id_or_email (String)

    Path param: GrowSurf participant ID or URL-encoded participant email address.

  • id (String)

    Path param: GrowSurf program ID.

  • limit (Integer)

    Query param: Number of results to return. Maximum 100.

  • next_id (String)

    Query param: ID to start the next paged result set with.

  • status (Symbol, GrowsurfRuby::Models::Campaign::ParticipantListPayoutsParams::Status)

    Query param: Participant payout status.

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

Returns:

See Also:



198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
# File 'lib/growsurf_ruby/resources/campaign/participant.rb', line 198

def list_payouts(participant_id_or_email, params)
  parsed, options = GrowsurfRuby::Campaign::ParticipantListPayoutsParams.dump_request(params)
  query = GrowsurfRuby::Internal::Util.encode_query_params(parsed)
  id =
    parsed.delete(:id) do
      raise ArgumentError.new("missing required path argument #{_1}")
    end
  @client.request(
    method: :get,
    path: ["campaign/%1$s/participant/%2$s/payouts", id, participant_id_or_email],
    query: query.transform_keys(next_id: "nextId"),
    model: GrowsurfRuby::ParticipantPayoutList,
    options: options
  )
end

#list_referrals(participant_id_or_email, id:, desc: nil, email: nil, first_name: nil, last_name: nil, limit: nil, next_id: nil, offset: nil, referral_status: nil, sort_by: nil, request_options: {}) ⇒ GrowsurfRuby::Models::ReferralList

Retrieves referrals and email invites made by a participant.

Parameters:

  • participant_id_or_email (String)

    Path param: GrowSurf participant ID or URL-encoded participant email address.

  • id (String)

    Path param: GrowSurf program ID.

  • desc (Boolean)

    Query param: Return results in descending order when true.

  • email (String)

    Query param: URL-encoded email value to filter referral results.

  • first_name (String)

    Query param: First name value to filter results.

  • last_name (String)

    Query param: Last name value to filter results.

  • limit (Integer)

    Query param: Number of results to return. Maximum 100.

  • next_id (String)

    Query param: ID to start the next paged result set with.

  • offset (Integer)

    Query param: Offset number used to skip through a result set.

  • referral_status (Symbol, GrowsurfRuby::Models::Campaign::ReferralStatus)

    Query param

  • sort_by (Symbol, GrowsurfRuby::Models::Campaign::ParticipantListReferralsParams::SortBy)

    Query param: Field used to sort referral results.

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

Returns:

See Also:



245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
# File 'lib/growsurf_ruby/resources/campaign/participant.rb', line 245

def list_referrals(participant_id_or_email, params)
  parsed, options = GrowsurfRuby::Campaign::ParticipantListReferralsParams.dump_request(params)
  query = GrowsurfRuby::Internal::Util.encode_query_params(parsed)
  id =
    parsed.delete(:id) do
      raise ArgumentError.new("missing required path argument #{_1}")
    end
  @client.request(
    method: :get,
    path: ["campaign/%1$s/participant/%2$s/referrals", id, participant_id_or_email],
    query: query.transform_keys(
      first_name: "firstName",
      last_name: "lastName",
      next_id: "nextId",
      referral_status: "referralStatus",
      sort_by: "sortBy"
    ),
    model: GrowsurfRuby::ReferralList,
    options: options
  )
end

#list_rewards(participant_id_or_email, id:, limit: nil, next_id: nil, request_options: {}) ⇒ GrowsurfRuby::Models::Campaign::ParticipantListRewardsResponse

Retrieves a paged list of rewards earned by a participant.

Parameters:

  • participant_id_or_email (String)

    Path param: GrowSurf participant ID or URL-encoded participant email address.

  • id (String)

    Path param: GrowSurf program ID.

  • limit (Integer)

    Query param: Number of results to return. Maximum 100.

  • next_id (String)

    Query param: ID to start the next paged result set with.

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

Returns:

See Also:



284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
# File 'lib/growsurf_ruby/resources/campaign/participant.rb', line 284

def list_rewards(participant_id_or_email, params)
  parsed, options = GrowsurfRuby::Campaign::ParticipantListRewardsParams.dump_request(params)
  query = GrowsurfRuby::Internal::Util.encode_query_params(parsed)
  id =
    parsed.delete(:id) do
      raise ArgumentError.new("missing required path argument #{_1}")
    end
  @client.request(
    method: :get,
    path: ["campaign/%1$s/participant/%2$s/rewards", id, participant_id_or_email],
    query: query.transform_keys(next_id: "nextId"),
    model: GrowsurfRuby::Models::Campaign::ParticipantListRewardsResponse,
    options: options
  )
end

#record_transaction(participant_id_or_email, id:, currency:, gross_amount:, amount_cash_net: nil, amount_paid: nil, charge_id: nil, customer_id: nil, description: nil, external_id: nil, invoice_id: nil, invoice_subtotal_excluding_tax: nil, invoice_total: nil, invoice_total_excluding_tax: nil, net_amount: nil, order_id: nil, paid_at: nil, payment_id: nil, payment_intent_id: nil, subscription_id: nil, tax_amount: nil, total_tax_amount: nil, total_tax_amounts: nil, total_taxes: nil, transaction_id: nil, request_options: {}) ⇒ GrowsurfRuby::Models::Campaign::ParticipantRecordTransactionResponse::UnionMember0, GrowsurfRuby::Models::Campaign::ParticipantRecordTransactionResponse::UnionMember1

Records a sale made by a referred customer and generates affiliate commissions for their referrer when applicable.

Parameters:

  • participant_id_or_email (String)

    Path param: GrowSurf participant ID or URL-encoded participant email address.

  • id (String)

    Path param: GrowSurf program ID.

  • currency (String)

    Body param

  • gross_amount (Integer)

    Body param

  • amount_cash_net (Integer)

    Body param

  • amount_paid (Integer)

    Body param

  • charge_id (String)

    Body param

  • customer_id (String)

    Body param

  • description (String)

    Body param

  • external_id (String)

    Body param

  • invoice_id (String)

    Body param

  • invoice_subtotal_excluding_tax (Integer)

    Body param

  • invoice_total (Integer)

    Body param

  • invoice_total_excluding_tax (Integer)

    Body param

  • net_amount (Integer)

    Body param

  • order_id (String)

    Body param

  • paid_at (Integer)

    Body param

  • payment_id (String)

    Body param

  • payment_intent_id (String)

    Body param

  • subscription_id (String)

    Body param

  • tax_amount (Integer)

    Body param

  • total_tax_amount (Integer)

    Body param

  • total_tax_amounts (Array<Hash{Symbol=>Object}>)

    Body param

  • total_taxes (Array<Hash{Symbol=>Object}>)

    Body param

  • transaction_id (String)

    Body param

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

Returns:

See Also:



360
361
362
363
364
365
366
367
368
369
370
371
372
373
# File 'lib/growsurf_ruby/resources/campaign/participant.rb', line 360

def record_transaction(participant_id_or_email, params)
  parsed, options = GrowsurfRuby::Campaign::ParticipantRecordTransactionParams.dump_request(params)
  id =
    parsed.delete(:id) do
      raise ArgumentError.new("missing required path argument #{_1}")
    end
  @client.request(
    method: :post,
    path: ["campaign/%1$s/participant/%2$s/transaction", id, participant_id_or_email],
    body: parsed,
    model: GrowsurfRuby::Models::Campaign::ParticipantRecordTransactionResponse,
    options: options
  )
end

#retrieve(participant_id_or_email, id:, request_options: {}) ⇒ GrowsurfRuby::Models::Campaign::CampaignParticipant

Retrieves a single participant by GrowSurf participant ID or email address.

Parameters:

  • participant_id_or_email (String)

    GrowSurf participant ID or URL-encoded participant email address.

  • id (String)

    GrowSurf program ID.

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

Returns:

See Also:



20
21
22
23
24
25
26
27
28
29
30
31
32
# File 'lib/growsurf_ruby/resources/campaign/participant.rb', line 20

def retrieve(participant_id_or_email, params)
  parsed, options = GrowsurfRuby::Campaign::ParticipantRetrieveParams.dump_request(params)
  id =
    parsed.delete(:id) do
      raise ArgumentError.new("missing required path argument #{_1}")
    end
  @client.request(
    method: :get,
    path: ["campaign/%1$s/participant/%2$s", id, participant_id_or_email],
    model: GrowsurfRuby::Campaign::CampaignParticipant,
    options: options
  )
end

#send_invites(participant_id_or_email, id:, email_addresses:, message_text:, subject_text:, request_options: {}) ⇒ GrowsurfRuby::Models::Campaign::ParticipantSendInvitesResponse

Sends email invites on behalf of a participant to a list of email addresses.

Parameters:

  • participant_id_or_email (String)

    Path param: GrowSurf participant ID or URL-encoded participant email address.

  • id (String)

    Path param: GrowSurf program ID.

  • email_addresses (Array<String>)

    Body param

  • message_text (String)

    Body param

  • subject_text (String)

    Body param

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

Returns:

See Also:



394
395
396
397
398
399
400
401
402
403
404
405
406
407
# File 'lib/growsurf_ruby/resources/campaign/participant.rb', line 394

def send_invites(participant_id_or_email, params)
  parsed, options = GrowsurfRuby::Campaign::ParticipantSendInvitesParams.dump_request(params)
  id =
    parsed.delete(:id) do
      raise ArgumentError.new("missing required path argument #{_1}")
    end
  @client.request(
    method: :post,
    path: ["campaign/%1$s/participant/%2$s/invites", id, participant_id_or_email],
    body: parsed,
    model: GrowsurfRuby::Models::Campaign::ParticipantSendInvitesResponse,
    options: options
  )
end

#trigger_referral(participant_id_or_email, id:, request_options: {}) ⇒ GrowsurfRuby::Models::Campaign::ParticipantTriggerReferralResponse

Triggers referral credit for an existing referred participant by GrowSurf participant ID or email address.

Parameters:

  • participant_id_or_email (String)

    GrowSurf participant ID or URL-encoded participant email address.

  • id (String)

    GrowSurf program ID.

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

Returns:

See Also:



423
424
425
426
427
428
429
430
431
432
433
434
435
# File 'lib/growsurf_ruby/resources/campaign/participant.rb', line 423

def trigger_referral(participant_id_or_email, params)
  parsed, options = GrowsurfRuby::Campaign::ParticipantTriggerReferralParams.dump_request(params)
  id =
    parsed.delete(:id) do
      raise ArgumentError.new("missing required path argument #{_1}")
    end
  @client.request(
    method: :post,
    path: ["campaign/%1$s/participant/%2$s/ref", id, participant_id_or_email],
    model: GrowsurfRuby::Models::Campaign::ParticipantTriggerReferralResponse,
    options: options
  )
end

#update(participant_id_or_email, id:, email: nil, first_name: nil, last_name: nil, metadata: nil, referral_status: nil, referred_by: nil, unsubscribed: nil, vanity_keys: nil, request_options: {}) ⇒ GrowsurfRuby::Models::Campaign::CampaignParticipant

Updates a participant by GrowSurf participant ID or email address.

Parameters:

  • participant_id_or_email (String)

    Path param: GrowSurf participant ID or URL-encoded participant email address.

  • id (String)

    Path param: GrowSurf program ID.

  • email (String)

    Body param

  • first_name (String)

    Body param

  • last_name (String)

    Body param

  • metadata (Hash{Symbol=>Object})

    Body param: Shallow custom metadata object.

  • referral_status (Symbol, GrowsurfRuby::Models::Campaign::ParticipantUpdateParams::ReferralStatus)

    Body param

  • referred_by (String)

    Body param

  • unsubscribed (Boolean)

    Body param

  • vanity_keys (Array<String>)

    Body param

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

Returns:

See Also:



63
64
65
66
67
68
69
70
71
72
73
74
75
76
# File 'lib/growsurf_ruby/resources/campaign/participant.rb', line 63

def update(participant_id_or_email, params)
  parsed, options = GrowsurfRuby::Campaign::ParticipantUpdateParams.dump_request(params)
  id =
    parsed.delete(:id) do
      raise ArgumentError.new("missing required path argument #{_1}")
    end
  @client.request(
    method: :post,
    path: ["campaign/%1$s/participant/%2$s", id, participant_id_or_email],
    body: parsed,
    model: GrowsurfRuby::Campaign::CampaignParticipant,
    options: options
  )
end