Class: Onlyfans::Resources::TrackingLinks

Inherits:
Object
  • Object
show all
Defined in:
lib/onlyfans/resources/tracking_links.rb,
lib/onlyfans/resources/tracking_links/tags.rb

Overview

APIs for managing tracking links

Defined Under Namespace

Classes: Tags

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(client:) ⇒ TrackingLinks

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

Parameters:



284
285
286
287
# File 'lib/onlyfans/resources/tracking_links.rb', line 284

def initialize(client:)
  @client = client
  @tags = Onlyfans::Resources::TrackingLinks::Tags.new(client: client)
end

Instance Attribute Details

#tagsOnlyfans::Resources::TrackingLinks::Tags (readonly)

APIs for managing tracking links



9
10
11
# File 'lib/onlyfans/resources/tracking_links.rb', line 9

def tags
  @tags
end

Instance Method Details

#create(account, name:, tags: nil, request_options: {}) ⇒ Onlyfans::Models::TrackingLinkCreateResponse

Create a new Tracking Link for the account

Parameters:

  • account (String)

    The Account ID

  • name (String)

    The name of the Tracking Link

  • tags (Array<String>)

    Array of tag names to add to the tracking link.

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

Returns:

See Also:



26
27
28
29
30
31
32
33
34
35
# File 'lib/onlyfans/resources/tracking_links.rb', line 26

def create(, params)
  parsed, options = Onlyfans::TrackingLinkCreateParams.dump_request(params)
  @client.request(
    method: :post,
    path: ["api/%1$s/tracking-links", ],
    body: parsed,
    model: Onlyfans::Models::TrackingLinkCreateResponse,
    options: options
  )
end

#delete(tracking_link_id, account:, request_options: {}) ⇒ Onlyfans::Models::TrackingLinkDeleteResponse

Delete a Tracking Link

Parameters:

  • tracking_link_id (String)

    The ID of the tracking link.

  • account (String)

    The Account ID

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

Returns:

See Also:



119
120
121
122
123
124
125
126
127
128
129
130
131
# File 'lib/onlyfans/resources/tracking_links.rb', line 119

def delete(tracking_link_id, params)
  parsed, options = Onlyfans::TrackingLinkDeleteParams.dump_request(params)
   =
    parsed.delete(:account) do
      raise ArgumentError.new("missing required path argument #{_1}")
    end
  @client.request(
    method: :delete,
    path: ["api/%1$s/tracking-links/%2$s", , tracking_link_id],
    model: Onlyfans::Models::TrackingLinkDeleteResponse,
    options: options
  )
end

#get_cohort_arps(tracking_link_id, account:, acquisition_end: nil, acquisition_start: nil, revenue_basis: nil, request_options: {}) ⇒ nil

Get per-link time-to-profit cohort ARPS windows for a specific Tracking Link

Parameters:

  • tracking_link_id (String)

    Path param: The ID of the tracking link.

  • account (String)

    Path param: The Account ID

  • acquisition_end (String)

    Query param: Optional acquisition range end date

  • acquisition_start (String)

    Query param: Optional acquisition range start date

  • revenue_basis (Symbol, Onlyfans::Models::TrackingLinkGetCohortArpsParams::RevenueBasis)

    Query param: Revenue basis. Defaults to ‘net`.

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

Returns:

  • (nil)

See Also:



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

def get_cohort_arps(tracking_link_id, params)
  parsed, options = Onlyfans::TrackingLinkGetCohortArpsParams.dump_request(params)
  query = Onlyfans::Internal::Util.encode_query_params(parsed)
   =
    parsed.delete(:account) do
      raise ArgumentError.new("missing required path argument #{_1}")
    end
  @client.request(
    method: :get,
    path: ["api/%1$s/tracking-links/%2$s/cohort-arps", , tracking_link_id],
    query: query,
    model: NilClass,
    options: options
  )
end

#get_stats(tracking_link_id, account:, date_end: nil, date_start: nil, request_options: {}) ⇒ Onlyfans::Models::TrackingLinkGetStatsResponse

Get dashboard-style summary plus daily and monthly metrics for a specific Tracking Link. <Callout title=‘Important information’> - ‘daily_metrics` returns **incremental per-day values**, not cumulative totals. - Cumulative totals are available in the `summary` section. - Historical daily data is only available from when we began recording daily link stats. - Daily data can only be tracked from the date the account was connected to OnlyFans API; earlier periods are not available. </Callout>

Parameters:

  • tracking_link_id (String)

    Path param: The ID of the tracking link.

  • account (String)

    Path param: The Account ID

  • date_end (String)

    Query param: Optional stats range end date

  • date_start (String)

    Query param: Optional stats range start date

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

Returns:

See Also:



191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
# File 'lib/onlyfans/resources/tracking_links.rb', line 191

def get_stats(tracking_link_id, params)
  parsed, options = Onlyfans::TrackingLinkGetStatsParams.dump_request(params)
  query = Onlyfans::Internal::Util.encode_query_params(parsed)
   =
    parsed.delete(:account) do
      raise ArgumentError.new("missing required path argument #{_1}")
    end
  @client.request(
    method: :get,
    path: ["api/%1$s/tracking-links/%2$s/stats", , tracking_link_id],
    query: query,
    model: Onlyfans::Models::TrackingLinkGetStatsResponse,
    options: options
  )
end

#list(account, end_date: nil, limit: nil, offset: nil, sort: nil, sortby: nil, start_date: nil, synchronous: nil, with_deleted: nil, request_options: {}) ⇒ Onlyfans::Models::TrackingLinkListResponse

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

List all tracking links for the account and revenue data

Parameters:

  • account (String)

    The Account ID

  • end_date (String, nil)

    The end date for Tracking Links. Keep empty to get all.

  • limit (Integer, nil)

    The number of tracking links to return. Default ‘3`

  • offset (Integer, nil)

    The offset used for pagination. Default ‘0`

  • sort (Symbol, Onlyfans::Models::TrackingLinkListParams::Sort, nil)

    Sort the results. Default ‘desc`

  • sortby (Symbol, Onlyfans::Models::TrackingLinkListParams::Sortby, nil)

    Sort by subscriber count (claims), or creation date

  • start_date (String, nil)

    The start date for Tracking Links. Keep empty to get all.

  • synchronous (Boolean, nil)

    Wait for the revenue data to finish processing, instead of processing in the bac

  • with_deleted (Boolean, nil)

    Whether or not to include deleted tracking links in the response. Default ‘false

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

Returns:

See Also:



94
95
96
97
98
99
100
101
102
103
104
# File 'lib/onlyfans/resources/tracking_links.rb', line 94

def list(, params = {})
  parsed, options = Onlyfans::TrackingLinkListParams.dump_request(params)
  query = Onlyfans::Internal::Util.encode_query_params(parsed)
  @client.request(
    method: :get,
    path: ["api/%1$s/tracking-links", ],
    query: query.transform_keys(end_date: "endDate", start_date: "startDate"),
    model: Onlyfans::Models::TrackingLinkListResponse,
    options: options
  )
end

#list_spenders(tracking_link_id, account:, limit: nil, min_spend: nil, offset: nil, request_options: {}) ⇒ Onlyfans::Models::TrackingLinkListSpendersResponse

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

Get list of spenders who made purchases through a Tracking Link

Parameters:

  • tracking_link_id (String)

    Path param: The ID of the Tracking Link. Can be retrieved from the above store a

  • account (String)

    Path param: The Account ID

  • limit (Integer)

    Query param: The number of spenders to return per page. Default ‘50`.

  • min_spend (Float)

    Query param: Minimal spend of a fan. Default ‘1`. Must be at least 1.

  • offset (Integer)

    Query param: The offset used for pagination. Default ‘0`.

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

Returns:

See Also:



229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
# File 'lib/onlyfans/resources/tracking_links.rb', line 229

def list_spenders(tracking_link_id, params)
  parsed, options = Onlyfans::TrackingLinkListSpendersParams.dump_request(params)
  query = Onlyfans::Internal::Util.encode_query_params(parsed)
   =
    parsed.delete(:account) do
      raise ArgumentError.new("missing required path argument #{_1}")
    end
  @client.request(
    method: :get,
    path: ["api/%1$s/tracking-links/%2$s/spenders", , tracking_link_id],
    query: query.transform_keys(min_spend: "minSpend"),
    model: Onlyfans::Models::TrackingLinkListSpendersResponse,
    options: options
  )
end

#list_subscribers(tracking_link_id, account:, limit:, offset:, request_options: {}) ⇒ Onlyfans::Models::TrackingLinkListSubscribersResponse

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

Get list of subscribers who joined through a Tracking Link

Parameters:

  • tracking_link_id (String)

    Path param: The ID of the Tracking Link. Can be retrieved from the above store a

  • account (String)

    Path param: The Account ID

  • limit (Integer)

    Query param: The number of subscribers to return per page. Default ‘10`

  • offset (Integer)

    Query param: The offset used for pagination. Default ‘0`

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

Returns:

See Also:



265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
# File 'lib/onlyfans/resources/tracking_links.rb', line 265

def list_subscribers(tracking_link_id, params)
  parsed, options = Onlyfans::TrackingLinkListSubscribersParams.dump_request(params)
  query = Onlyfans::Internal::Util.encode_query_params(parsed)
   =
    parsed.delete(:account) do
      raise ArgumentError.new("missing required path argument #{_1}")
    end
  @client.request(
    method: :get,
    path: ["api/%1$s/tracking-links/%2$s/subscribers", , tracking_link_id],
    query: query,
    model: Onlyfans::Models::TrackingLinkListSubscribersResponse,
    options: options
  )
end

#retrieve(tracking_link_id, account:, request_options: {}) ⇒ Onlyfans::Models::TrackingLinkRetrieveResponse

Get individual Tracking Link details and it’s revenue data

Parameters:

  • tracking_link_id (String)

    The ID of the tracking link.

  • account (String)

    The Account ID

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

Returns:

See Also:



50
51
52
53
54
55
56
57
58
59
60
61
62
# File 'lib/onlyfans/resources/tracking_links.rb', line 50

def retrieve(tracking_link_id, params)
  parsed, options = Onlyfans::TrackingLinkRetrieveParams.dump_request(params)
   =
    parsed.delete(:account) do
      raise ArgumentError.new("missing required path argument #{_1}")
    end
  @client.request(
    method: :get,
    path: ["api/%1$s/tracking-links/%2$s", , tracking_link_id],
    model: Onlyfans::Models::TrackingLinkRetrieveResponse,
    options: options
  )
end