Class: Courier::Resources::Audiences
- Inherits:
-
Object
- Object
- Courier::Resources::Audiences
- Defined in:
- lib/courier/resources/audiences.rb,
sig/courier/resources/audiences.rbs
Overview
Define filter-based groups whose membership Courier recalculates as user profiles change.
Instance Method Summary collapse
-
#delete(audience_id, request_options: {}) ⇒ nil
Deletes an audience permanently, so update any caller sending to it by audience id first.
-
#initialize(client:) ⇒ Audiences
constructor
private
A new instance of Audiences.
-
#list(cursor: nil, request_options: {}) ⇒ Courier::Models::AudienceListResponse
Returns the audiences in the workspace with paging.
-
#list_members(audience_id, cursor: nil, request_options: {}) ⇒ Courier::Models::AudienceListMembersResponse
Returns the users currently matching an audience filter, with paging.
-
#retrieve(audience_id, request_options: {}) ⇒ Courier::Models::Audience
Returns one audience with its name, description, and the filter and AND or OR operator that decide which users belong to it.
-
#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.
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.
137 138 139 |
# File 'lib/courier/resources/audiences.rb', line 137 def initialize(client:) @client = client end |
Instance Method Details
#delete(audience_id, request_options: {}) ⇒ nil
Deletes an audience permanently, so update any caller sending to it by audience id first. Those sends fail once the audience is gone.
99 100 101 102 103 104 105 106 |
# File 'lib/courier/resources/audiences.rb', line 99 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
Returns the audiences in the workspace with paging. Audiences are filter-based groups that recalculate as user profiles change.
75 76 77 78 79 80 81 82 83 84 85 |
# File 'lib/courier/resources/audiences.rb', line 75 def list(params = {}) parsed, = 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: ) end |
#list_members(audience_id, cursor: nil, request_options: {}) ⇒ Courier::Models::AudienceListMembersResponse
Returns the users currently matching an audience filter, with paging. Membership is recalculated, so results shift as profiles change.
122 123 124 125 126 127 128 129 130 131 132 |
# File 'lib/courier/resources/audiences.rb', line 122 def list_members(audience_id, params = {}) parsed, = 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: ) end |
#retrieve(audience_id, request_options: {}) ⇒ Courier::Models::Audience
Returns one audience with its name, description, and the filter and AND or OR operator that decide which users belong to it.
20 21 22 23 24 25 26 27 |
# File 'lib/courier/resources/audiences.rb', line 20 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 replaces an audience from a filter and an AND or OR operator. Membership recalculates automatically as profiles change.
52 53 54 55 56 57 58 59 60 61 |
# File 'lib/courier/resources/audiences.rb', line 52 def update(audience_id, params = {}) parsed, = Courier::AudienceUpdateParams.dump_request(params) @client.request( method: :put, path: ["audiences/%1$s", audience_id], body: parsed, model: Courier::Models::AudienceUpdateResponse, options: ) end |