Class: Courier::Resources::Profiles::Lists
- Inherits:
-
Object
- Object
- Courier::Resources::Profiles::Lists
- Defined in:
- lib/courier/resources/profiles/lists.rb,
sig/courier/resources/profiles/lists.rbs
Overview
Store the contact information Courier delivers to for each user — email, phone number, push tokens, and any custom data you send to.
Instance Method Summary collapse
-
#delete(user_id, request_options: {}) ⇒ Courier::Models::Profiles::ListDeleteResponse
Some parameter documentations has been truncated, see Models::Profiles::ListDeleteParams for more details.
-
#initialize(client:) ⇒ Lists
constructor
private
A new instance of Lists.
-
#retrieve(user_id, cursor: nil, request_options: {}) ⇒ Courier::Models::Profiles::ListRetrieveResponse
Some parameter documentations has been truncated, see Models::Profiles::ListRetrieveParams for more details.
-
#subscribe(user_id, lists:, idempotency_key: nil, x_idempotency_expiration: nil, request_options: {}) ⇒ Courier::Models::Profiles::ListSubscribeResponse
Some parameter documentations has been truncated, see Models::Profiles::ListSubscribeParams for more details.
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.
100 101 102 |
# File 'lib/courier/resources/profiles/lists.rb', line 100 def initialize(client:) @client = client end |
Instance Method Details
#delete(user_id, request_options: {}) ⇒ Courier::Models::Profiles::ListDeleteResponse
Some parameter documentations has been truncated, see Models::Profiles::ListDeleteParams for more details.
Removes every list subscription for a user at once. Their profile and preferences are untouched, so this only affects list-targeted sends.
53 54 55 56 57 58 59 60 |
# File 'lib/courier/resources/profiles/lists.rb', line 53 def delete(user_id, params = {}) @client.request( method: :delete, path: ["profiles/%1$s/lists", user_id], model: Courier::Models::Profiles::ListDeleteResponse, options: params[:request_options] ) end |
#retrieve(user_id, cursor: nil, request_options: {}) ⇒ Courier::Models::Profiles::ListRetrieveResponse
Some parameter documentations has been truncated, see Models::Profiles::ListRetrieveParams for more details.
Returns the lists a user is subscribed to, with paging. Use it to check what a recipient will receive before sending to a list.
26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/courier/resources/profiles/lists.rb', line 26 def retrieve(user_id, params = {}) parsed, = Courier::Profiles::ListRetrieveParams.dump_request(params) query = Courier::Internal::Util.encode_query_params(parsed) @client.request( method: :get, path: ["profiles/%1$s/lists", user_id], query: query, model: Courier::Models::Profiles::ListRetrieveResponse, options: ) end |
#subscribe(user_id, lists:, idempotency_key: nil, x_idempotency_expiration: nil, request_options: {}) ⇒ Courier::Models::Profiles::ListSubscribeResponse
Some parameter documentations has been truncated, see Models::Profiles::ListSubscribeParams for more details.
Subscribes a user to one or more lists, creating any list that does not yet exist. Optional preferences apply to each subscription.
83 84 85 86 87 88 89 90 91 92 93 94 95 |
# File 'lib/courier/resources/profiles/lists.rb', line 83 def subscribe(user_id, params) parsed, = Courier::Profiles::ListSubscribeParams.dump_request(params) header_params = {idempotency_key: "idempotency-key", x_idempotency_expiration: "x-idempotency-expiration"} @client.request( method: :post, path: ["profiles/%1$s/lists", user_id], headers: parsed.slice(*header_params.keys).transform_keys(header_params), body: parsed.except(*header_params.keys), model: Courier::Models::Profiles::ListSubscribeResponse, options: ) end |