Class: Courier::Resources::Audiences

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



130
131
132
# File 'lib/courier/resources/audiences.rb', line 130

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 (Courier::RequestOptions, Hash{Symbol=>Object}, nil)

Returns:

  • (nil)

See Also:



93
94
95
96
97
98
99
100
# File 'lib/courier/resources/audiences.rb', line 93

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: {}) ⇒ Courier::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 (Courier::RequestOptions, Hash{Symbol=>Object}, nil)

Returns:

See Also:



70
71
72
73
74
75
76
77
78
79
80
# File 'lib/courier/resources/audiences.rb', line 70

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

#list_members(audience_id, cursor: nil, request_options: {}) ⇒ Courier::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 (Courier::RequestOptions, Hash{Symbol=>Object}, nil)

Returns:

See Also:



115
116
117
118
119
120
121
122
123
124
125
# File 'lib/courier/resources/audiences.rb', line 115

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

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

Returns the specified audience by id.

Parameters:

  • audience_id (String)

    A unique identifier representing the audience_id

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

Returns:

See Also:



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

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

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

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

Creates or updates audience.

Parameters:

Returns:

See Also:



48
49
50
51
52
53
54
55
56
57
# File 'lib/courier/resources/audiences.rb', line 48

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