Class: GrowsurfRuby::Resources::Campaign

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

Defined Under Namespace

Classes: Commission, Participant, Reward

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(client:) ⇒ Campaign

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

Parameters:



258
259
260
261
262
263
# File 'lib/growsurf_ruby/resources/campaign.rb', line 258

def initialize(client:)
  @client = client
  @participant = GrowsurfRuby::Resources::Campaign::Participant.new(client: client)
  @reward = GrowsurfRuby::Resources::Campaign::Reward.new(client: client)
  @commission = GrowsurfRuby::Resources::Campaign::Commission.new(client: client)
end

Instance Attribute Details

#commissionGrowsurfRuby::Resources::Campaign::Commission (readonly)

Affiliate transaction, commission, and payout operations.



15
16
17
# File 'lib/growsurf_ruby/resources/campaign.rb', line 15

def commission
  @commission
end

#participantGrowsurfRuby::Resources::Campaign::Participant (readonly)



7
8
9
# File 'lib/growsurf_ruby/resources/campaign.rb', line 7

def participant
  @participant
end

#rewardGrowsurfRuby::Resources::Campaign::Reward (readonly)

Participant reward retrieval and manual reward operations.



11
12
13
# File 'lib/growsurf_ruby/resources/campaign.rb', line 11

def reward
  @reward
end

Instance Method Details

#list(request_options: {}) ⇒ GrowsurfRuby::Models::CampaignListResponse

Retrieves a list of your programs. Deleted programs are not returned.

Parameters:

Returns:

See Also:



46
47
48
49
50
51
52
53
# File 'lib/growsurf_ruby/resources/campaign.rb', line 46

def list(params = {})
  @client.request(
    method: :get,
    path: "campaigns",
    model: GrowsurfRuby::Models::CampaignListResponse,
    options: params[:request_options]
  )
end

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

Retrieves a paged list of all participant commissions in an affiliate program.

Parameters:

Returns:

See Also:



72
73
74
75
76
77
78
79
80
81
82
# File 'lib/growsurf_ruby/resources/campaign.rb', line 72

def list_commissions(id, params = {})
  parsed, options = GrowsurfRuby::CampaignListCommissionsParams.dump_request(params)
  query = GrowsurfRuby::Internal::Util.encode_query_params(parsed)
  @client.request(
    method: :get,
    path: ["campaign/%1$s/commissions", id],
    query: query.transform_keys(next_id: "nextId"),
    model: GrowsurfRuby::ParticipantCommissionList,
    options: options
  )
end

#list_leaderboard(id, is_monthly: nil, leaderboard_type: nil, limit: nil, next_id: nil, request_options: {}) ⇒ GrowsurfRuby::Models::ParticipantList

Retrieves participants in leaderboard order for the specified leaderboard type.

Parameters:

Returns:

See Also:



103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
# File 'lib/growsurf_ruby/resources/campaign.rb', line 103

def list_leaderboard(id, params = {})
  parsed, options = GrowsurfRuby::CampaignListLeaderboardParams.dump_request(params)
  query = GrowsurfRuby::Internal::Util.encode_query_params(parsed)
  @client.request(
    method: :get,
    path: ["campaign/%1$s/leaderboard", id],
    query: query.transform_keys(
      is_monthly: "isMonthly",
      leaderboard_type: "leaderboardType",
      next_id: "nextId"
    ),
    model: GrowsurfRuby::ParticipantList,
    options: options
  )
end

#list_participants(id, limit: nil, next_id: nil, request_options: {}) ⇒ GrowsurfRuby::Models::ParticipantList

Retrieves a paged list of participants in a program.

Parameters:

  • id (String)

    GrowSurf program ID.

  • limit (Integer)

    Number of results to return. Maximum 100.

  • next_id (String)

    ID to start the next paged result set with.

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

Returns:

See Also:



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

def list_participants(id, params = {})
  parsed, options = GrowsurfRuby::CampaignListParticipantsParams.dump_request(params)
  query = GrowsurfRuby::Internal::Util.encode_query_params(parsed)
  @client.request(
    method: :get,
    path: ["campaign/%1$s/participants", id],
    query: query.transform_keys(next_id: "nextId"),
    model: GrowsurfRuby::ParticipantList,
    options: options
  )
end

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

Retrieves a paged list of all participant payouts in an affiliate program.

Parameters:

Returns:

See Also:



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

def list_payouts(id, params = {})
  parsed, options = GrowsurfRuby::CampaignListPayoutsParams.dump_request(params)
  query = GrowsurfRuby::Internal::Util.encode_query_params(parsed)
  @client.request(
    method: :get,
    path: ["campaign/%1$s/payouts", id],
    query: query.transform_keys(next_id: "nextId"),
    model: GrowsurfRuby::ParticipantPayoutList,
    options: options
  )
end

#list_referrals(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 a list of all referrals and email invites made by participants in a program.

Parameters:

  • id (String)

    GrowSurf program ID.

  • desc (Boolean)

    Return results in descending order when true.

  • email (String)

    URL-encoded email value to filter referral results.

  • first_name (String)

    First name value to filter results.

  • last_name (String)

    Last name value to filter results.

  • limit (Integer)

    Number of results to return. Maximum 100.

  • next_id (String)

    ID to start the next paged result set with.

  • offset (Integer)

    Offset number used to skip through a result set.

  • referral_status (Symbol, GrowsurfRuby::Models::Campaign::ReferralStatus)
  • sort_by (Symbol, GrowsurfRuby::Models::CampaignListReferralsParams::SortBy)

    Field used to sort referral results.

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

Returns:

See Also:



205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
# File 'lib/growsurf_ruby/resources/campaign.rb', line 205

def list_referrals(id, params = {})
  parsed, options = GrowsurfRuby::CampaignListReferralsParams.dump_request(params)
  query = GrowsurfRuby::Internal::Util.encode_query_params(parsed)
  @client.request(
    method: :get,
    path: ["campaign/%1$s/referrals", id],
    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

#retrieve(id, request_options: {}) ⇒ GrowsurfRuby::Models::CampaignAPI

Retrieves a program for the given program ID.

Parameters:

Returns:

See Also:



28
29
30
31
32
33
34
35
# File 'lib/growsurf_ruby/resources/campaign.rb', line 28

def retrieve(id, params = {})
  @client.request(
    method: :get,
    path: ["campaign/%1$s", id],
    model: GrowsurfRuby::CampaignAPI,
    options: params[:request_options]
  )
end

#retrieve_analytics(id, days: nil, end_date: nil, start_date: nil, request_options: {}) ⇒ GrowsurfRuby::Models::CampaignRetrieveAnalyticsResponse

Some parameter documentations has been truncated, see Models::CampaignRetrieveAnalyticsParams for more details.

Retrieves analytics for a program.

Parameters:

  • id (String)

    GrowSurf program ID.

  • days (Integer)

    Last number of days to retrieve analytics for. Defaults to 365. Maximum 1825.

  • end_date (Integer)

    End date of the analytics timeframe as a Unix timestamp in milliseconds. Require

  • start_date (Integer)

    Start date of the analytics timeframe as a Unix timestamp in milliseconds. Requi

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

Returns:

See Also:



243
244
245
246
247
248
249
250
251
252
253
# File 'lib/growsurf_ruby/resources/campaign.rb', line 243

def retrieve_analytics(id, params = {})
  parsed, options = GrowsurfRuby::CampaignRetrieveAnalyticsParams.dump_request(params)
  query = GrowsurfRuby::Internal::Util.encode_query_params(parsed)
  @client.request(
    method: :get,
    path: ["campaign/%1$s/analytics", id],
    query: query.transform_keys(end_date: "endDate", start_date: "startDate"),
    model: GrowsurfRuby::Models::CampaignRetrieveAnalyticsResponse,
    options: options
  )
end