Class: WhopSDK::Resources::Audiences

Inherits:
Object
  • Object
show all
Defined in:
lib/whop_sdk/resources/audiences.rb,
sig/whop_sdk/resources/audiences.rbs

Overview

An Audience represents a customer list uploaded to Whop for ad targeting. Audiences belong to an account and sync to supported ad platforms as custom audiences.

Use the Audiences API to create audiences from CSV uploads, monitor processing status, and list or delete audiences for an account. Created audiences are usable for targeting after processing reaches ready or partial.

Instance Method Summary collapse

Constructor Details

#initialize(client:) ⇒ Audiences

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

Parameters:



99
100
101
# File 'lib/whop_sdk/resources/audiences.rb', line 99

def initialize(client:)
  @client = client
end

Instance Method Details

#create(account_id:, column_mapping:, file_id:, name:, request_options: {}) ⇒ WhopSDK::Models::Audience

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

Creates an audience from an uploaded customer identity CSV file and starts processing it.

Parameters:

  • account_id (String)

    Account ID, prefixed biz_.

  • column_mapping (WhopSDK::Models::AudienceCreateParams::ColumnMapping)

    Maps supported identity fields to CSV column headers. Map at least one of `email

  • file_id (String)

    Direct upload ID from the standard media upload endpoint.

  • name (String)

    Audience display name.

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

Returns:

See Also:



34
35
36
37
38
39
40
41
42
43
# File 'lib/whop_sdk/resources/audiences.rb', line 34

def create(params)
  parsed, options = WhopSDK::AudienceCreateParams.dump_request(params)
  @client.request(
    method: :post,
    path: "audiences",
    body: parsed,
    model: WhopSDK::Audience,
    options: options
  )
end

#delete(audience_id, request_options: {}) ⇒ WhopSDK::Models::AudienceDeleteResponse

Deletes an audience so it is no longer available for targeting.

Parameters:

  • audience_id (String)

    Audience ID, prefixed adaud_.

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

Returns:

See Also:



87
88
89
90
91
92
93
94
# File 'lib/whop_sdk/resources/audiences.rb', line 87

def delete(audience_id, params = {})
  @client.request(
    method: :delete,
    path: ["audiences/%1$s", audience_id],
    model: WhopSDK::Models::AudienceDeleteResponse,
    options: params[:request_options]
  )
end

#list(account_id:, after: nil, audience_id: nil, first: nil, request_options: {}) ⇒ WhopSDK::Internal::CursorPage<WhopSDK::Models::Audience>

Lists uploaded customer-list audiences for an account. Pass audience_id to return a specific audience.

Parameters:

  • account_id (String)

    Account ID, prefixed biz_.

  • after (String)

    Cursor for the next page of audiences.

  • audience_id (String)

    Audience ID, prefixed adaud_, used to filter the response to one audience.

  • first (Integer)

    Number of audiences to return. Defaults to 20; maximum 100.

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

Returns:

See Also:



63
64
65
66
67
68
69
70
71
72
73
74
# File 'lib/whop_sdk/resources/audiences.rb', line 63

def list(params)
  parsed, options = WhopSDK::AudienceListParams.dump_request(params)
  query = WhopSDK::Internal::Util.encode_query_params(parsed)
  @client.request(
    method: :get,
    path: "audiences",
    query: query,
    page: WhopSDK::Internal::CursorPage,
    model: WhopSDK::Audience,
    options: options
  )
end