Class: WhopSDK::Resources::AdCampaigns

Inherits:
Object
  • Object
show all
Defined in:
lib/whop_sdk/resources/ad_campaigns.rb

Overview

Ad campaigns

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:



158
159
160
# File 'lib/whop_sdk/resources/ad_campaigns.rb', line 158

def initialize(client:)
  @client = client
end

Instance Method Details

#list(after: nil, before: nil, company_id: nil, created_after: nil, created_before: nil, first: nil, last: nil, query: nil, status: nil, request_options: {}) ⇒ WhopSDK::Internal::CursorPage<WhopSDK::Models::AdCampaignListResponse>

Returns a paginated list of ad campaigns for a company, with optional filtering by status, and creation date.

Required permissions:

  • ‘ad_campaign:basic:read`

Parameters:

  • after (String, nil)

    Returns the elements in the list that come after the specified cursor.

  • before (String, nil)

    Returns the elements in the list that come before the specified cursor.

  • company_id (String, nil)

    The unique identifier of the company to list ad campaigns for.

  • created_after (Time, nil)

    Only return ad campaigns created after this timestamp.

  • created_before (Time, nil)

    Only return ad campaigns created before this timestamp.

  • first (Integer, nil)

    Returns the first n elements from the list.

  • last (Integer, nil)

    Returns the last n elements from the list.

  • query (String, nil)

    Case-insensitive substring match against the campaign title.

  • status (Symbol, WhopSDK::Models::AdCampaignStatus, nil)

    The status of an ad campaign.

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

Returns:

See Also:



94
95
96
97
98
99
100
101
102
103
104
105
# File 'lib/whop_sdk/resources/ad_campaigns.rb', line 94

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

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

Pauses an ad campaign, optionally until a specific date.

Required permissions:

  • ‘ad_campaign:update`

Parameters:

  • id (String)

    The unique identifier of the ad campaign to pause.

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

Returns:

See Also:



122
123
124
125
126
127
128
129
# File 'lib/whop_sdk/resources/ad_campaigns.rb', line 122

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, request_options: {}) ⇒ WhopSDK::Models::AdCampaign

Retrieves a single ad campaign by its unique identifier.

Required permissions:

  • ‘ad_campaign:basic:read`

Parameters:

  • id (String)

    The unique identifier of the ad campaign.

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

Returns:

See Also:



22
23
24
25
26
27
28
29
# File 'lib/whop_sdk/resources/ad_campaigns.rb', line 22

def retrieve(id, params = {})
  @client.request(
    method: :get,
    path: ["ad_campaigns/%1$s", id],
    model: WhopSDK::AdCampaign,
    options: params[:request_options]
  )
end

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

Resumes a paused ad campaign.

Required permissions:

  • ‘ad_campaign:update`

Parameters:

  • id (String)

    The unique identifier of the ad campaign to unpause.

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

Returns:

See Also:



146
147
148
149
150
151
152
153
# File 'lib/whop_sdk/resources/ad_campaigns.rb', line 146

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, budget: nil, request_options: {}) ⇒ WhopSDK::Models::AdCampaign

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

Updates an ad campaign synchronously.

Required permissions:

  • ‘ad_campaign:update`

Parameters:

  • id (String)

    The unique identifier of the ad campaign to update.

  • budget (Float, nil)

    The campaign budget in dollars. The interpretation (daily or lifetime) follows t

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

Returns:

See Also:



51
52
53
54
55
56
57
58
59
60
# File 'lib/whop_sdk/resources/ad_campaigns.rb', line 51

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