Class: Onlyfans::Resources::Promotions
- Inherits:
-
Object
- Object
- Onlyfans::Resources::Promotions
- Defined in:
- lib/onlyfans/resources/promotions.rb
Instance Method Summary collapse
-
#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.
-
#delete(promotion_id, account:, request_options: {}) ⇒ Onlyfans::Models::PromotionDeleteResponse
Delete a promotion for the account.
-
#initialize(client:) ⇒ Promotions
constructor
private
A new instance of Promotions.
-
#list(account, limit: nil, offset: nil, request_options: {}) ⇒ Onlyfans::Models::PromotionListResponse
List all promotions for the account.
-
#stop(promotion_id, account:, request_options: {}) ⇒ Onlyfans::Models::PromotionStopResponse
Stop an active promotion for the account.
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.
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.
32 33 34 35 36 37 38 39 40 41 |
# File 'lib/onlyfans/resources/promotions.rb', line 32 def create(account, params) parsed, = Onlyfans::PromotionCreateParams.dump_request(params) @client.request( method: :post, path: ["api/%1$s/promotions", account], body: parsed, model: Onlyfans::Models::PromotionCreateResponse, options: ) end |
#delete(promotion_id, account:, request_options: {}) ⇒ Onlyfans::Models::PromotionDeleteResponse
Delete a promotion for the account.
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, = Onlyfans::PromotionDeleteParams.dump_request(params) account = parsed.delete(:account) do raise ArgumentError.new("missing required path argument #{_1}") end @client.request( method: :delete, path: ["api/%1$s/promotions/%2$s", account, promotion_id], model: Onlyfans::Models::PromotionDeleteResponse, options: ) end |
#list(account, limit: nil, offset: nil, request_options: {}) ⇒ Onlyfans::Models::PromotionListResponse
List all promotions for the account.
58 59 60 61 62 63 64 65 66 67 68 |
# File 'lib/onlyfans/resources/promotions.rb', line 58 def list(account, params = {}) parsed, = Onlyfans::PromotionListParams.dump_request(params) query = Onlyfans::Internal::Util.encode_query_params(parsed) @client.request( method: :get, path: ["api/%1$s/promotions", account], query: query, model: Onlyfans::Models::PromotionListResponse, options: ) end |
#stop(promotion_id, account:, request_options: {}) ⇒ Onlyfans::Models::PromotionStopResponse
Stop an active promotion for the account.
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, = Onlyfans::PromotionStopParams.dump_request(params) account = 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", account, promotion_id], model: Onlyfans::Models::PromotionStopResponse, options: ) end |