Class: Onlyfans::Resources::SmartLinks

Inherits:
Object
  • Object
show all
Defined in:
lib/onlyfans/resources/smart_links.rb

Overview

APIs for managing Smart Links (Free Trial Links and Tracking Links with pooled inventory)

Instance Method Summary collapse

Constructor Details

#initialize(client:) ⇒ SmartLinks

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

Parameters:



316
317
318
# File 'lib/onlyfans/resources/smart_links.rb', line 316

def initialize(client:)
  @client = client
end

Instance Method Details

#create(account_id:, link_type:, name:, free_trial_days: nil, request_options: {}) ⇒ Onlyfans::Models::SmartLinkCreateResponse

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

Create a new Smart Link for the account. Smart Links are pooled Free Trial or Tracking links that rotate inventory automatically.

Parameters:

  • account_id (String)

    The prefixed ID of the account to create the Smart Link for

  • link_type (Symbol, Onlyfans::Models::SmartLinkCreateParams::LinkType)

    The type of Smart Link to create

  • name (String)

    The name of the Smart Link

  • free_trial_days (Integer)

    The number of free trial days (required if ‘link_type` is `free_trial`). Must be

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

Returns:

See Also:



29
30
31
32
33
34
35
36
37
38
# File 'lib/onlyfans/resources/smart_links.rb', line 29

def create(params)
  parsed, options = Onlyfans::SmartLinkCreateParams.dump_request(params)
  @client.request(
    method: :post,
    path: "api/smart-links",
    body: parsed,
    model: Onlyfans::Models::SmartLinkCreateResponse,
    options: options
  )
end

#delete(smart_link_id, request_options: {}) ⇒ Onlyfans::Models::SmartLinkDeleteResponse

Delete a Smart Link by its ID

Parameters:

  • smart_link_id (String)

    The ID of the Smart Link

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

Returns:

See Also:



105
106
107
108
109
110
111
112
# File 'lib/onlyfans/resources/smart_links.rb', line 105

def delete(smart_link_id, params = {})
  @client.request(
    method: :delete,
    path: ["api/smart-links/%1$s", smart_link_id],
    model: Onlyfans::Models::SmartLinkDeleteResponse,
    options: params[:request_options]
  )
end

#list(account_ids: nil, limit: nil, meta_pixel_ids: nil, name: nil, offset: nil, request_options: {}) ⇒ Onlyfans::Models::SmartLinkListResponse

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

List all Smart Links

Parameters:

  • account_ids (String, nil)

    Comma-separated account prefixed IDs to include.

  • limit (Integer)

    The number of Smart Links to return. Default ‘50`. Must be at least 1. Must not

  • meta_pixel_ids (String, nil)

    Comma-separated Meta Pixel IDs to include.

  • name (String, nil)

    Filter Smart Links by name. Must not be greater than 255 characters.

  • offset (Integer)

    The offset used for pagination. Default ‘0`. Must be at least 0.

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

Returns:

See Also:



82
83
84
85
86
87
88
89
90
91
92
# File 'lib/onlyfans/resources/smart_links.rb', line 82

def list(params = {})
  parsed, options = Onlyfans::SmartLinkListParams.dump_request(params)
  query = Onlyfans::Internal::Util.encode_query_params(parsed)
  @client.request(
    method: :get,
    path: "api/smart-links",
    query: query,
    model: Onlyfans::Models::SmartLinkListResponse,
    options: options
  )
end

#list_clicks(smart_link_id, date_end: nil, date_start: nil, include_bots: nil, include_duplicates: nil, limit: nil, offset: nil, request_options: {}) ⇒ Onlyfans::Models::SmartLinkListClicksResponse

Query smart link clicks in a date range with optional bot/duplicate filtering

Parameters:

  • smart_link_id (String)

    The ID of the smart link.

  • date_end (String)

    Optional report range end date

  • date_start (String)

    Optional report range start date

  • include_bots (Boolean)

    Include clicks marked as bots. Default ‘true`

  • include_duplicates (Boolean)

    Include duplicate clicks. Default ‘true`

  • limit (Integer)

    Rows per page. Default ‘100`

  • offset (Integer)

    Offset for pagination. Default ‘0`

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

Returns:

See Also:



137
138
139
140
141
142
143
144
145
146
147
# File 'lib/onlyfans/resources/smart_links.rb', line 137

def list_clicks(smart_link_id, params = {})
  parsed, options = Onlyfans::SmartLinkListClicksParams.dump_request(params)
  query = Onlyfans::Internal::Util.encode_query_params(parsed)
  @client.request(
    method: :get,
    path: ["api/smart-links/%1$s/clicks", smart_link_id],
    query: query,
    model: Onlyfans::Models::SmartLinkListClicksResponse,
    options: options
  )
end

#list_conversions(smart_link_id, conversion_type: nil, date_end: nil, date_start: nil, include_bots: nil, include_duplicates: nil, limit: nil, offset: nil, onlyfans_user_id: nil, request_options: {}) ⇒ Onlyfans::Models::SmartLinkListConversionsResponse

Query smart link conversions in a date range with optional bot/duplicate and conversion type filtering

Parameters:

  • smart_link_id (String)

    The ID of the smart link.

  • conversion_type (Symbol, Onlyfans::Models::SmartLinkListConversionsParams::ConversionType)

    Optional conversion type filter

  • date_end (String)

    Optional report range end date

  • date_start (String)

    Optional report range start date

  • include_bots (Boolean)

    Include conversions from clicks marked as bots. Default ‘true`

  • include_duplicates (Boolean)

    Include conversions from duplicate clicks. Default ‘true`

  • limit (Integer)

    Rows per page. Default ‘100`

  • offset (Integer)

    Offset for pagination. Default ‘0`

  • onlyfans_user_id (String)

    Optional - Search for conversions by OnlyFans User ID

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

Returns:

See Also:



177
178
179
180
181
182
183
184
185
186
187
# File 'lib/onlyfans/resources/smart_links.rb', line 177

def list_conversions(smart_link_id, params = {})
  parsed, options = Onlyfans::SmartLinkListConversionsParams.dump_request(params)
  query = Onlyfans::Internal::Util.encode_query_params(parsed)
  @client.request(
    method: :get,
    path: ["api/smart-links/%1$s/conversions", smart_link_id],
    query: query,
    model: Onlyfans::Models::SmartLinkListConversionsResponse,
    options: options
  )
end

#list_fans(smart_link_id, has_messages: nil, limit: nil, min_messages_sent_by_fan: nil, min_revenue_net: nil, min_tips_net: nil, offset: nil, sort: nil, request_options: {}) ⇒ Onlyfans::Models::SmartLinkListFansResponse

Query attributed Smart Link fans with aggregate fan metrics and subscriber attribution metadata

Parameters:

  • smart_link_id (String)

    The ID of the smart link.

  • has_messages (Boolean)

    Optional - Filter to fans with or without fan-sent messages

  • limit (Integer)

    Rows per page. Default ‘100`

  • min_messages_sent_by_fan (Integer)

    Optional minimum number of messages sent by fan

  • min_revenue_net (Float)

    Optional minimum net revenue

  • min_tips_net (Float)

    Optional minimum net tips

  • offset (Integer)

    Offset for pagination. Default ‘0`

  • sort (Symbol, Onlyfans::Models::SmartLinkListFansParams::Sort)

    Optional sort field. Default ‘-revenue_net`

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

Returns:

See Also:



215
216
217
218
219
220
221
222
223
224
225
# File 'lib/onlyfans/resources/smart_links.rb', line 215

def list_fans(smart_link_id, params = {})
  parsed, options = Onlyfans::SmartLinkListFansParams.dump_request(params)
  query = Onlyfans::Internal::Util.encode_query_params(parsed)
  @client.request(
    method: :get,
    path: ["api/smart-links/%1$s/fans", smart_link_id],
    query: query,
    model: Onlyfans::Models::SmartLinkListFansResponse,
    options: options
  )
end

#list_spenders(smart_link_id, limit: nil, min_spend: nil, offset: nil, request_options: {}) ⇒ Onlyfans::Models::SmartLinkListSpendersResponse

Compatibility endpoint returning fans with attributed spend through a Smart Link

Parameters:

  • smart_link_id (String)

    The ID of the smart link.

  • limit (Integer)

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

  • min_spend (Float)

    Minimal spend of a fan. Default ‘1`

  • offset (Integer)

    The offset used for pagination. Default ‘0`

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

Returns:

See Also:



244
245
246
247
248
249
250
251
252
253
254
# File 'lib/onlyfans/resources/smart_links.rb', line 244

def list_spenders(smart_link_id, params = {})
  parsed, options = Onlyfans::SmartLinkListSpendersParams.dump_request(params)
  query = Onlyfans::Internal::Util.encode_query_params(parsed)
  @client.request(
    method: :get,
    path: ["api/smart-links/%1$s/spenders", smart_link_id],
    query: query.transform_keys(min_spend: "minSpend"),
    model: Onlyfans::Models::SmartLinkListSpendersResponse,
    options: options
  )
end

#retrieve(smart_link_id, request_options: {}) ⇒ Onlyfans::Models::SmartLinkRetrieveResponse

Get a specific Smart Link by its ID

Parameters:

  • smart_link_id (String)

    The ID of the Smart Link

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

Returns:

See Also:



51
52
53
54
55
56
57
58
# File 'lib/onlyfans/resources/smart_links.rb', line 51

def retrieve(smart_link_id, params = {})
  @client.request(
    method: :get,
    path: ["api/smart-links/%1$s", smart_link_id],
    model: Onlyfans::Models::SmartLinkRetrieveResponse,
    options: params[:request_options]
  )
end

#retrieve_cohort_arps(smart_link_id, acquisition_end: nil, acquisition_start: nil, revenue_basis: nil, request_options: {}) ⇒ nil

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

Parameters:

Returns:

  • (nil)

See Also:



273
274
275
276
277
278
279
280
281
282
283
# File 'lib/onlyfans/resources/smart_links.rb', line 273

def retrieve_cohort_arps(smart_link_id, params = {})
  parsed, options = Onlyfans::SmartLinkRetrieveCohortArpsParams.dump_request(params)
  query = Onlyfans::Internal::Util.encode_query_params(parsed)
  @client.request(
    method: :get,
    path: ["api/smart-links/%1$s/cohort-arps", smart_link_id],
    query: query,
    model: NilClass,
    options: options
  )
end

#retrieve_stats(smart_link_id, date_end: nil, date_start: nil, request_options: {}) ⇒ Onlyfans::Models::SmartLinkRetrieveStatsResponse

Get dashboard-style summary plus daily and monthly metrics for a specific Smart Link on the current team

Parameters:

  • smart_link_id (String)

    The ID of the smart link.

  • date_end (String)

    Optional stats range end date

  • date_start (String)

    Optional stats range start date

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

Returns:

See Also:



301
302
303
304
305
306
307
308
309
310
311
# File 'lib/onlyfans/resources/smart_links.rb', line 301

def retrieve_stats(smart_link_id, params = {})
  parsed, options = Onlyfans::SmartLinkRetrieveStatsParams.dump_request(params)
  query = Onlyfans::Internal::Util.encode_query_params(parsed)
  @client.request(
    method: :get,
    path: ["api/smart-links/%1$s/stats", smart_link_id],
    query: query,
    model: Onlyfans::Models::SmartLinkRetrieveStatsResponse,
    options: options
  )
end