Class: Trycourier::Resources::Audiences

Inherits:
Object
  • Object
show all
Defined in:
lib/trycourier/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:



123
124
125
# File 'lib/trycourier/resources/audiences.rb', line 123

def initialize(client:)
  @client = client
end

Instance Method Details

#delete(audience_id, request_options: {}) ⇒ nil

Deletes the specified audience.

Parameters:

  • audience_id (String)

    A unique identifier representing the audience id

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

Returns:

  • (nil)

See Also:



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

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

#list(cursor: nil, request_options: {}) ⇒ Trycourier::Models::AudienceListResponse

Get the audiences associated with the authorization token.

Parameters:

  • cursor (String, nil)

    A unique identifier that allows for fetching the next set of audiences

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

Returns:

See Also:



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

def list(params = {})
  parsed, options = Trycourier::AudienceListParams.dump_request(params)
  @client.request(
    method: :get,
    path: "audiences",
    query: parsed,
    model: Trycourier::Models::AudienceListResponse,
    options: options
  )
end

#list_members(audience_id, cursor: nil, request_options: {}) ⇒ Trycourier::Models::AudienceListMembersResponse

Get list of members of an audience.

Parameters:

  • audience_id (String)

    A unique identifier representing the audience id

  • cursor (String, nil)

    A unique identifier that allows for fetching the next set of members

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

Returns:

See Also:



109
110
111
112
113
114
115
116
117
118
# File 'lib/trycourier/resources/audiences.rb', line 109

def list_members(audience_id, params = {})
  parsed, options = Trycourier::AudienceListMembersParams.dump_request(params)
  @client.request(
    method: :get,
    path: ["audiences/%1$s/members", audience_id],
    query: parsed,
    model: Trycourier::Models::AudienceListMembersResponse,
    options: options
  )
end

#retrieve(audience_id, request_options: {}) ⇒ Trycourier::Models::Audience

Returns the specified audience by id.

Parameters:

  • audience_id (String)

    A unique identifier representing the audience_id

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

Returns:

See Also:



17
18
19
20
21
22
23
24
# File 'lib/trycourier/resources/audiences.rb', line 17

def retrieve(audience_id, params = {})
  @client.request(
    method: :get,
    path: ["audiences/%1$s", audience_id],
    model: Trycourier::Audience,
    options: params[:request_options]
  )
end

#update(audience_id, description: nil, filter: nil, name: nil, request_options: {}) ⇒ Trycourier::Models::AudienceUpdateResponse

Creates or updates audience.

Parameters:

  • audience_id (String)

    A unique identifier representing the audience id

  • description (String, nil)

    A description of the audience

  • filter (Trycourier::Models::Filter, nil)

    A single filter to use for filtering

  • name (String, nil)

    The name of the audience

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

Returns:

See Also:



43
44
45
46
47
48
49
50
51
52
# File 'lib/trycourier/resources/audiences.rb', line 43

def update(audience_id, params = {})
  parsed, options = Trycourier::AudienceUpdateParams.dump_request(params)
  @client.request(
    method: :put,
    path: ["audiences/%1$s", audience_id],
    body: parsed,
    model: Trycourier::Models::AudienceUpdateResponse,
    options: options
  )
end