Class: Courier::Resources::Lists
- Inherits:
-
Object
- Object
- Courier::Resources::Lists
- Defined in:
- lib/courier/resources/lists.rb,
lib/courier/resources/lists/subscriptions.rb,
sig/courier/resources/lists.rbs,
sig/courier/resources/lists/subscriptions.rbs
Overview
Manage static groups of users that you subscribe explicitly, and send to them by list id or list pattern.
Defined Under Namespace
Classes: Subscriptions
Instance Attribute Summary collapse
-
#subscriptions ⇒ Courier::Resources::Lists::Subscriptions
readonly
Manage static groups of users that you subscribe explicitly, and send to them by list id or list pattern.
Instance Method Summary collapse
-
#delete(list_id, request_options: {}) ⇒ nil
Deletes a list, halting sends that target it.
-
#initialize(client:) ⇒ Lists
constructor
private
A new instance of Lists.
-
#list(cursor: nil, pattern: nil, request_options: {}) ⇒ Courier::Models::ListListResponse
Some parameter documentations has been truncated, see Models::ListListParams for more details.
-
#restore(list_id, request_options: {}) ⇒ nil
Restores a previously deleted list along with its subscribers, so a list removed by mistake can be brought back rather than rebuilt.
-
#retrieve(list_id, request_options: {}) ⇒ Courier::Models::SubscriptionList
Returns one list by id with its name and created and updated timestamps.
-
#update(list_id, name:, preferences: nil, request_options: {}) ⇒ nil
Creates or replaces a list from a name and preferences.
Constructor Details
#initialize(client:) ⇒ Lists
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 Lists.
135 136 137 138 |
# File 'lib/courier/resources/lists.rb', line 135 def initialize(client:) @client = client @subscriptions = Courier::Resources::Lists::Subscriptions.new(client: client) end |
Instance Attribute Details
#subscriptions ⇒ Courier::Resources::Lists::Subscriptions (readonly)
Manage static groups of users that you subscribe explicitly, and send to them by list id or list pattern.
11 12 13 |
# File 'lib/courier/resources/lists.rb', line 11 def subscriptions @subscriptions end |
Instance Method Details
#delete(list_id, request_options: {}) ⇒ nil
Deletes a list, halting sends that target it. A previously deleted list can be brought back with the companion restore endpoint.
102 103 104 105 106 107 108 109 |
# File 'lib/courier/resources/lists.rb', line 102 def delete(list_id, params = {}) @client.request( method: :delete, path: ["lists/%1$s", list_id], model: NilClass, options: params[:request_options] ) end |
#list(cursor: nil, pattern: nil, request_options: {}) ⇒ Courier::Models::ListListResponse
Some parameter documentations has been truncated, see Models::ListListParams for more details.
Returns the workspace's lists, filterable by a pattern to fetch a subset such as every regional list. Paged by cursor.
78 79 80 81 82 83 84 85 86 87 88 |
# File 'lib/courier/resources/lists.rb', line 78 def list(params = {}) parsed, = Courier::ListListParams.dump_request(params) query = Courier::Internal::Util.encode_query_params(parsed) @client.request( method: :get, path: "lists", query: query, model: Courier::Models::ListListResponse, options: ) end |
#restore(list_id, request_options: {}) ⇒ nil
Restores a previously deleted list along with its subscribers, so a list removed by mistake can be brought back rather than rebuilt.
123 124 125 126 127 128 129 130 |
# File 'lib/courier/resources/lists.rb', line 123 def restore(list_id, params = {}) @client.request( method: :put, path: ["lists/%1$s/restore", list_id], model: NilClass, options: params[:request_options] ) end |
#retrieve(list_id, request_options: {}) ⇒ Courier::Models::SubscriptionList
Returns one list by id with its name and created and updated timestamps. Fetch its subscribers separately with the subscriptions endpoint.
25 26 27 28 29 30 31 32 |
# File 'lib/courier/resources/lists.rb', line 25 def retrieve(list_id, params = {}) @client.request( method: :get, path: ["lists/%1$s", list_id], model: Courier::SubscriptionList, options: params[:request_options] ) end |
#update(list_id, name:, preferences: nil, request_options: {}) ⇒ nil
Creates or replaces a list from a name and preferences. Subscribers are managed through the separate subscriptions endpoints.
50 51 52 53 54 55 56 57 58 59 |
# File 'lib/courier/resources/lists.rb', line 50 def update(list_id, params) parsed, = Courier::ListUpdateParams.dump_request(params) @client.request( method: :put, path: ["lists/%1$s", list_id], body: parsed, model: NilClass, options: ) end |