Class: SurgeAPI::Resources::Audiences

Inherits:
Object
  • Object
show all
Defined in:
lib/surge_api/resources/audiences.rb

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:



92
93
94
# File 'lib/surge_api/resources/audiences.rb', line 92

def initialize(client:)
  @client = client
end

Instance Method Details

#add_contact(audience_id, id:, request_options: {}) ⇒ SurgeAPI::Models::Contact

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

Adds an existing contact to a manual audience.

Parameters:

  • audience_id (String)

    The audience ID to add the contact to.

  • id (String)

    The ID of the contact to add. The contact must belong to the same account as the

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

Returns:

See Also:



46
47
48
49
50
51
52
53
54
55
# File 'lib/surge_api/resources/audiences.rb', line 46

def add_contact(audience_id, params)
  parsed, options = SurgeAPI::AudienceAddContactParams.dump_request(params)
  @client.request(
    method: :post,
    path: ["audiences/%1$s/contacts", audience_id],
    body: parsed,
    model: SurgeAPI::Contact,
    options: options
  )
end

#create(account_id, name:, request_options: {}) ⇒ SurgeAPI::Models::AudienceCreateResponse

Creates a new audience.

Parameters:

  • account_id (String)

    The account for which the audience should be created.

  • name (String)

    The audience name.

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

Returns:

See Also:



19
20
21
22
23
24
25
26
27
28
# File 'lib/surge_api/resources/audiences.rb', line 19

def create(, params)
  parsed, options = SurgeAPI::AudienceCreateParams.dump_request(params)
  @client.request(
    method: :post,
    path: ["accounts/%1$s/audiences", ],
    body: parsed,
    model: SurgeAPI::Models::AudienceCreateResponse,
    options: options
  )
end

#list_contacts(audience_id, after: nil, before: nil, request_options: {}) ⇒ SurgeAPI::Internal::Cursor<SurgeAPI::Models::Contact>

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

List all contacts in an audience with cursor-based pagination. The account is inferred from the audience.

Parameters:

  • audience_id (String)

    The audience ID to list contacts for.

  • after (String)

    Cursor for forward pagination. Use the next_cursor from a previous response.

  • before (String)

    Cursor for backward pagination. Use the previous_cursor from a previous response

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

Returns:

See Also:



76
77
78
79
80
81
82
83
84
85
86
87
# File 'lib/surge_api/resources/audiences.rb', line 76

def list_contacts(audience_id, params = {})
  parsed, options = SurgeAPI::AudienceListContactsParams.dump_request(params)
  query = SurgeAPI::Internal::Util.encode_query_params(parsed)
  @client.request(
    method: :get,
    path: ["audiences/%1$s/contacts", audience_id],
    query: query,
    page: SurgeAPI::Internal::Cursor,
    model: SurgeAPI::Contact,
    options: options
  )
end