Class: WhopSDK::Resources::AdCampaigns
- Inherits:
-
Object
- Object
- WhopSDK::Resources::AdCampaigns
- Defined in:
- lib/whop_sdk/resources/ad_campaigns.rb,
sig/whop_sdk/resources/ad_campaigns.rbs
Overview
An Ad Campaign is the top-level container for paid ads on an ad network. It sets the platform, objective, and budget strategy shared by its ad groups and ads.
Use the Ad Campaigns API to create campaigns, list campaigns for an account, retrieve or update campaign settings, and pause or resume campaign delivery.
Instance Method Summary collapse
-
#create(objective:, platform:, title:, account_id: nil, bid_type: nil, budget_amount: nil, budget_optimization: nil, budget_type: nil, desired_cost_per_result: nil, ends_at: nil, special_ad_categories: nil, starts_at: nil, request_options: {}) ⇒ WhopSDK::Models::AdCampaign
Some parameter documentations has been truncated, see Models::AdCampaignCreateParams for more details.
-
#delete(id, request_options: {}) ⇒ Boolean
Deletes an ad campaign and archives it on the ad platform (cascades to ad groups and ads).
-
#initialize(client:) ⇒ AdCampaigns
constructor
private
A new instance of AdCampaigns.
-
#list(account_id: nil, after: nil, before: nil, created_after: nil, created_before: nil, direction: nil, first: nil, last: nil, order: nil, query: nil, stats_from: nil, stats_to: nil, status: nil, time_zone: nil, request_options: {}) ⇒ WhopSDK::Internal::CursorPage<WhopSDK::Models::AdCampaign>
Some parameter documentations has been truncated, see Models::AdCampaignListParams for more details.
-
#pause(id, request_options: {}) ⇒ WhopSDK::Models::AdCampaign
Pauses an active ad campaign.
-
#retrieve(id, stats_from: nil, stats_to: nil, time_zone: nil, request_options: {}) ⇒ WhopSDK::Models::AdCampaign
Retrieves a single ad campaign with stats over the requested window.
-
#unpause(id, request_options: {}) ⇒ WhopSDK::Models::AdCampaign
Resumes a paused ad campaign.
-
#update(id, bid_type: nil, budget_amount: nil, budget_optimization: nil, ends_at: nil, starts_at: nil, status: nil, title: nil, request_options: {}) ⇒ WhopSDK::Models::AdCampaign
Some parameter documentations has been truncated, see Models::AdCampaignUpdateParams for more details.
Constructor Details
#initialize(client:) ⇒ AdCampaigns
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 AdCampaigns.
247 248 249 |
# File 'lib/whop_sdk/resources/ad_campaigns.rb', line 247 def initialize(client:) @client = client end |
Instance Method Details
#create(objective:, platform:, title:, account_id: nil, bid_type: nil, budget_amount: nil, budget_optimization: nil, budget_type: nil, desired_cost_per_result: nil, ends_at: nil, special_ad_categories: nil, starts_at: nil, request_options: {}) ⇒ WhopSDK::Models::AdCampaign
Some parameter documentations has been truncated, see Models::AdCampaignCreateParams for more details.
Creates an ad campaign for an account.
48 49 50 51 52 53 54 55 56 57 |
# File 'lib/whop_sdk/resources/ad_campaigns.rb', line 48 def create(params) parsed, = WhopSDK::AdCampaignCreateParams.dump_request(params) @client.request( method: :post, path: "ad_campaigns", body: parsed, model: WhopSDK::AdCampaign, options: ) end |
#delete(id, request_options: {}) ⇒ Boolean
Deletes an ad campaign and archives it on the ad platform (cascades to ad groups and ads). Returns true on success.
195 196 197 198 199 200 201 202 |
# File 'lib/whop_sdk/resources/ad_campaigns.rb', line 195 def delete(id, params = {}) @client.request( method: :delete, path: ["ad_campaigns/%1$s", id], model: WhopSDK::Internal::Type::Boolean, options: params[:request_options] ) end |
#list(account_id: nil, after: nil, before: nil, created_after: nil, created_before: nil, direction: nil, first: nil, last: nil, order: nil, query: nil, stats_from: nil, stats_to: nil, status: nil, time_zone: nil, request_options: {}) ⇒ WhopSDK::Internal::CursorPage<WhopSDK::Models::AdCampaign>
Some parameter documentations has been truncated, see Models::AdCampaignListParams for more details.
Lists the ad campaigns for an account, with stats over the requested window.
170 171 172 173 174 175 176 177 178 179 180 181 |
# File 'lib/whop_sdk/resources/ad_campaigns.rb', line 170 def list(params = {}) parsed, = WhopSDK::AdCampaignListParams.dump_request(params) query = WhopSDK::Internal::Util.encode_query_params(parsed) @client.request( method: :get, path: "ad_campaigns", query: query, page: WhopSDK::Internal::CursorPage, model: WhopSDK::AdCampaign, options: ) end |
#pause(id, request_options: {}) ⇒ WhopSDK::Models::AdCampaign
Pauses an active ad campaign.
215 216 217 218 219 220 221 222 |
# File 'lib/whop_sdk/resources/ad_campaigns.rb', line 215 def pause(id, params = {}) @client.request( method: :post, path: ["ad_campaigns/%1$s/pause", id], model: WhopSDK::AdCampaign, options: params[:request_options] ) end |
#retrieve(id, stats_from: nil, stats_to: nil, time_zone: nil, request_options: {}) ⇒ WhopSDK::Models::AdCampaign
Retrieves a single ad campaign with stats over the requested window.
76 77 78 79 80 81 82 83 84 85 86 |
# File 'lib/whop_sdk/resources/ad_campaigns.rb', line 76 def retrieve(id, params = {}) parsed, = WhopSDK::AdCampaignRetrieveParams.dump_request(params) query = WhopSDK::Internal::Util.encode_query_params(parsed) @client.request( method: :get, path: ["ad_campaigns/%1$s", id], query: query, model: WhopSDK::AdCampaign, options: ) end |
#unpause(id, request_options: {}) ⇒ WhopSDK::Models::AdCampaign
Resumes a paused ad campaign.
235 236 237 238 239 240 241 242 |
# File 'lib/whop_sdk/resources/ad_campaigns.rb', line 235 def unpause(id, params = {}) @client.request( method: :post, path: ["ad_campaigns/%1$s/unpause", id], model: WhopSDK::AdCampaign, options: params[:request_options] ) end |
#update(id, bid_type: nil, budget_amount: nil, budget_optimization: nil, ends_at: nil, starts_at: nil, status: nil, title: nil, request_options: {}) ⇒ WhopSDK::Models::AdCampaign
Some parameter documentations has been truncated, see Models::AdCampaignUpdateParams for more details.
Updates an ad campaign's editable fields (title, budget, schedule, bid strategy, and — before launch — budget optimization), and launches a draft campaign by setting status to active. Objective, budget type, special ad categories and desired cost per result are fixed at creation and cannot be changed.
119 120 121 122 123 124 125 126 127 128 |
# File 'lib/whop_sdk/resources/ad_campaigns.rb', line 119 def update(id, params = {}) parsed, = WhopSDK::AdCampaignUpdateParams.dump_request(params) @client.request( method: :patch, path: ["ad_campaigns/%1$s", id], body: parsed, model: WhopSDK::AdCampaign, options: ) end |