Class: WhopSDK::Resources::Ads

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

Overview

Ads

Instance Method Summary collapse

Constructor Details

#initialize(client:) ⇒ Ads

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

Parameters:



145
146
147
# File 'lib/whop_sdk/resources/ads.rb', line 145

def initialize(client:)
  @client = client
end

Instance Method Details

#list(ad_group_id: nil, after: nil, before: nil, campaign_id: nil, company_id: nil, created_after: nil, created_before: nil, first: nil, include_paused: nil, last: nil, order_by: nil, order_direction: nil, query: nil, stats_from: nil, stats_to: nil, status: nil, request_options: {}) ⇒ WhopSDK::Internal::CursorPage<WhopSDK::Models::AdListResponse>

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

List ads scoped by ad group, campaign, or company.

Required permissions:

  • ‘ad_campaign:basic:read`

Parameters:

  • ad_group_id (String, nil)

    Filter by ad group. Provide exactly one of ad*group_id, campaign_id, or company*

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

  • campaign_id (String, nil)

    Filter by campaign. Provide exactly one of ad*group_id, campaign_id, or company*

  • company_id (String, nil)

    Filter by company. Provide exactly one of ad_group_id, campaign_id, or company_i

  • created_after (Time, nil)

    Only return ads created after this timestamp.

  • created_before (Time, nil)

    Only return ads created before this timestamp.

  • first (Integer, nil)

    Returns the first n elements from the list.

  • include_paused (Boolean, nil)

    When false, excludes paused ads so pagination matches the dashboard’s hide-pause

  • last (Integer, nil)

    Returns the last n elements from the list.

  • order_by (Symbol, WhopSDK::Models::AdListParams::OrderBy, nil)

    Columns that the listAds query can sort by.

  • order_direction (Symbol, WhopSDK::Models::Direction, nil)

    The direction of the sort.

  • query (String, nil)

    Case-insensitive substring match against the ad title or tag.

  • stats_from (Time, nil)

    Start of the stats date range used when order_by is a stats column.

  • stats_to (Time, nil)

    End of the stats date range used when order_by is a stats column.

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

    The status of an external ad.

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

Returns:

See Also:



79
80
81
82
83
84
85
86
87
88
89
90
# File 'lib/whop_sdk/resources/ads.rb', line 79

def list(params = {})
  parsed, options = WhopSDK::AdListParams.dump_request(params)
  query = WhopSDK::Internal::Util.encode_query_params(parsed)
  @client.request(
    method: :get,
    path: "ads",
    query: query,
    page: WhopSDK::Internal::CursorPage,
    model: WhopSDK::Models::AdListResponse,
    options: options
  )
end

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

Pauses an ad.

Required permissions:

  • ‘ad_campaign:update`

  • ‘ad_campaign:basic:read`

Parameters:

  • id (String)

    The unique identifier of the ad to pause.

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

Returns:

See Also:



108
109
110
111
112
113
114
115
# File 'lib/whop_sdk/resources/ads.rb', line 108

def pause(id, params = {})
  @client.request(
    method: :post,
    path: ["ads/%1$s/pause", id],
    model: WhopSDK::Ad,
    options: params[:request_options]
  )
end

#retrieve(id, request_options: {}) ⇒ WhopSDK::Models::Ad

Retrieve an ad by its unique identifier.

Required permissions:

  • ‘ad_campaign:basic:read`

Parameters:

  • id (String)

    The unique identifier of the ad.

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

Returns:

See Also:



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

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

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

Resumes a paused ad.

Required permissions:

  • ‘ad_campaign:update`

  • ‘ad_campaign:basic:read`

Parameters:

  • id (String)

    The unique identifier of the ad to unpause.

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

Returns:

See Also:



133
134
135
136
137
138
139
140
# File 'lib/whop_sdk/resources/ads.rb', line 133

def unpause(id, params = {})
  @client.request(
    method: :post,
    path: ["ads/%1$s/unpause", id],
    model: WhopSDK::Ad,
    options: params[:request_options]
  )
end