Class: WhopSDK::Resources::AdCampaigns

Inherits:
Object
  • Object
show all
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

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.

Parameters:



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.

Parameters:

Returns:

See Also:



48
49
50
51
52
53
54
55
56
57
# File 'lib/whop_sdk/resources/ad_campaigns.rb', line 48

def create(params)
  parsed, options = WhopSDK::AdCampaignCreateParams.dump_request(params)
  @client.request(
    method: :post,
    path: "ad_campaigns",
    body: parsed,
    model: WhopSDK::AdCampaign,
    options: 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.

Parameters:

  • id (String)

    The ad campaign ID.

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

Returns:

  • (Boolean)

See Also:



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.

Parameters:

  • account_id (String)

    The account the campaigns belong to. Defaults to the account-scoped key's own ac

  • after (String)

    Cursor to fetch the page after (from page_info.end_cursor).

  • before (String)

    Cursor to fetch the page before (from page_info.start_cursor).

  • created_after (String)

    Only return campaigns created after this timestamp.

  • created_before (String)

    Only return campaigns created before this timestamp.

  • direction (Symbol, WhopSDK::Models::AdCampaignListParams::Direction)

    The sort direction. Defaults to desc.

  • first (Integer)

    The number of campaigns to return.

  • last (Integer)

    The number of campaigns to return from the end of the range.

  • order (Symbol, WhopSDK::Models::AdCampaignListParams::Order)

    The field to sort by. Defaults to created_at. Stat columns (spend, impressions,

  • query (String)

    Filter campaigns by a title or ID substring.

  • stats_from (String)

    Start of the stats window. Defaults to all-time.

  • stats_to (String)

    End of the stats window. Defaults to now.

  • status (Symbol, WhopSDK::Models::AdCampaignListParams::Status)

    Only return campaigns with this status.

  • time_zone (String)

    IANA timezone (e.g. America/New_York) the stats window is interpreted in. Bare s

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

Returns:

See Also:



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, options = 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: options
  )
end

#pause(id, request_options: {}) ⇒ WhopSDK::Models::AdCampaign

Pauses an active ad campaign.

Parameters:

Returns:

See Also:



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.

Parameters:

  • id (String)

    The ad campaign ID.

  • stats_from (String)

    Start of the stats window.

  • stats_to (String)

    End of the stats window.

  • time_zone (String)

    IANA timezone the stats window is interpreted in. Defaults to UTC.

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

Returns:

See Also:



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, options = 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: options
  )
end

#unpause(id, request_options: {}) ⇒ WhopSDK::Models::AdCampaign

Resumes a paused ad campaign.

Parameters:

Returns:

See Also:



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.

Parameters:

Returns:

See Also:



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, options = WhopSDK::AdCampaignUpdateParams.dump_request(params)
  @client.request(
    method: :patch,
    path: ["ad_campaigns/%1$s", id],
    body: parsed,
    model: WhopSDK::AdCampaign,
    options: options
  )
end