Class: Onlyfans::Resources::Promotions

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

Instance Method Summary collapse

Constructor Details

#initialize(client:) ⇒ Promotions

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

Parameters:



127
128
129
# File 'lib/onlyfans/resources/promotions.rb', line 127

def initialize(client:)
  @client = client
end

Instance Method Details

#create(account, discount:, expiration_days:, offer_limit:, type:, free_trial_days: nil, message: nil, request_options: {}) ⇒ Onlyfans::Models::PromotionCreateResponse

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

Create a new promotion for the account.

Parameters:

  • account (String)

    The Account ID

  • discount (Integer)

    The discount percentage for the promotion’s first month. Set to 100 to make this

  • expiration_days (Integer)

    In how many days this offer will expire. Set to 0 to make this promotion infinit

  • offer_limit (Integer)

    Limit how many people can claim this offer. Set to 0 for no limits.

  • type (Symbol, Onlyfans::Models::PromotionCreateParams::Type)

    Whether this promotion should apply to new subscribers, expired subscribers, or

  • free_trial_days (Integer)

    Required only when discount is 100. Sets the duration (in days) of the free tria

  • message (String)

    Optionally, provide a message for this promotion.

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

Returns:

See Also:



32
33
34
35
36
37
38
39
40
41
# File 'lib/onlyfans/resources/promotions.rb', line 32

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

#delete(promotion_id, account:, request_options: {}) ⇒ Onlyfans::Models::PromotionDeleteResponse

Delete a promotion for the account.

Parameters:

  • promotion_id (String)

    The ID of the promotion to delete.

  • account (String)

    The Account ID

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

Returns:

See Also:



83
84
85
86
87
88
89
90
91
92
93
94
95
# File 'lib/onlyfans/resources/promotions.rb', line 83

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

#list(account, limit: nil, offset: nil, request_options: {}) ⇒ Onlyfans::Models::PromotionListResponse

List all promotions for the account.

Parameters:

  • account (String)

    The Account ID

  • limit (Integer)

    The number of promotions to return. Default ‘10`

  • offset (Integer)

    The offset used for pagination. Default ‘0`

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

Returns:

See Also:



58
59
60
61
62
63
64
65
66
67
68
# File 'lib/onlyfans/resources/promotions.rb', line 58

def list(, params = {})
  parsed, options = Onlyfans::PromotionListParams.dump_request(params)
  query = Onlyfans::Internal::Util.encode_query_params(parsed)
  @client.request(
    method: :get,
    path: ["api/%1$s/promotions", ],
    query: query,
    model: Onlyfans::Models::PromotionListResponse,
    options: options
  )
end

#stop(promotion_id, account:, request_options: {}) ⇒ Onlyfans::Models::PromotionStopResponse

Stop an active promotion for the account.

Parameters:

  • promotion_id (String)

    The ID of the promotion to stop.

  • account (String)

    The Account ID

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

Returns:

See Also:



110
111
112
113
114
115
116
117
118
119
120
121
122
# File 'lib/onlyfans/resources/promotions.rb', line 110

def stop(promotion_id, params)
  parsed, options = Onlyfans::PromotionStopParams.dump_request(params)
   =
    parsed.delete(:account) do
      raise ArgumentError.new("missing required path argument #{_1}")
    end
  @client.request(
    method: :post,
    path: ["api/%1$s/promotions/%2$s/stop", , promotion_id],
    model: Onlyfans::Models::PromotionStopResponse,
    options: options
  )
end