Class: Courier::Resources::Profiles
- Inherits:
-
Object
- Object
- Courier::Resources::Profiles
- Defined in:
- lib/courier/resources/profiles.rb,
lib/courier/resources/profiles/lists.rb,
sig/courier/resources/profiles.rbs,
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.
Defined Under Namespace
Classes: Lists
Instance Attribute Summary collapse
-
#lists ⇒ Courier::Resources::Profiles::Lists
readonly
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
-
#create(user_id, profile:, idempotency_key: nil, x_idempotency_expiration: nil, request_options: {}) ⇒ Courier::Models::ProfileCreateResponse
Some parameter documentations has been truncated, see Models::ProfileCreateParams for more details.
-
#delete(user_id, request_options: {}) ⇒ nil
Some parameter documentations has been truncated, see Models::ProfileDeleteParams for more details.
-
#initialize(client:) ⇒ Profiles
constructor
private
A new instance of Profiles.
-
#replace(user_id, profile:, request_options: {}) ⇒ Courier::Models::ProfileReplaceResponse
Some parameter documentations has been truncated, see Models::ProfileReplaceParams for more details.
-
#retrieve(user_id, request_options: {}) ⇒ Courier::Models::ProfileRetrieveResponse
Some parameter documentations has been truncated, see Models::ProfileRetrieveParams for more details.
-
#update(user_id, patch:, request_options: {}) ⇒ nil
Some parameter documentations has been truncated, see Models::ProfileUpdateParams for more details.
Constructor Details
#initialize(client:) ⇒ Profiles
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 Profiles.
155 156 157 158 |
# File 'lib/courier/resources/profiles.rb', line 155 def initialize(client:) @client = client @lists = Courier::Resources::Profiles::Lists.new(client: client) end |
Instance Attribute Details
#lists ⇒ Courier::Resources::Profiles::Lists (readonly)
Store the contact information Courier delivers to for each user — email, phone number, push tokens, and any custom data you send to.
11 12 13 |
# File 'lib/courier/resources/profiles.rb', line 11 def lists @lists end |
Instance Method Details
#create(user_id, profile:, idempotency_key: nil, x_idempotency_expiration: nil, request_options: {}) ⇒ Courier::Models::ProfileCreateResponse
Some parameter documentations has been truncated, see Models::ProfileCreateParams for more details.
Merges the supplied values into a user's profile, creating it if absent and leaving any key you omit untouched. Prefer this for everyday writes.
34 35 36 37 38 39 40 41 42 43 44 45 46 |
# File 'lib/courier/resources/profiles.rb', line 34 def create(user_id, params) parsed, = Courier::ProfileCreateParams.dump_request(params) header_params = {idempotency_key: "idempotency-key", x_idempotency_expiration: "x-idempotency-expiration"} @client.request( method: :post, path: ["profiles/%1$s", user_id], headers: parsed.slice(*header_params.keys).transform_keys(header_params), body: parsed.except(*header_params.keys), model: Courier::Models::ProfileCreateResponse, options: ) end |
#delete(user_id, request_options: {}) ⇒ nil
Some parameter documentations has been truncated, see Models::ProfileDeleteParams for more details.
Deletes a user's profile and stored contact details. List subscriptions and preferences are separate resources, so remove those too if required.
115 116 117 118 119 120 121 122 |
# File 'lib/courier/resources/profiles.rb', line 115 def delete(user_id, params = {}) @client.request( method: :delete, path: ["profiles/%1$s", user_id], model: NilClass, options: params[:request_options] ) end |
#replace(user_id, profile:, request_options: {}) ⇒ Courier::Models::ProfileReplaceResponse
Some parameter documentations has been truncated, see Models::ProfileReplaceParams for more details.
Overwrites a user profile in full, removing any key absent from the request body. Use the patch endpoint when changing a single field.
141 142 143 144 145 146 147 148 149 150 |
# File 'lib/courier/resources/profiles.rb', line 141 def replace(user_id, params) parsed, = Courier::ProfileReplaceParams.dump_request(params) @client.request( method: :put, path: ["profiles/%1$s", user_id], body: parsed, model: Courier::Models::ProfileReplaceResponse, options: ) end |
#retrieve(user_id, request_options: {}) ⇒ Courier::Models::ProfileRetrieveResponse
Some parameter documentations has been truncated, see Models::ProfileRetrieveParams for more details.
Returns a user's stored profile and preferences, including the email address, phone number, and push tokens Courier can reach them on.
63 64 65 66 67 68 69 70 |
# File 'lib/courier/resources/profiles.rb', line 63 def retrieve(user_id, params = {}) @client.request( method: :get, path: ["profiles/%1$s", user_id], model: Courier::Models::ProfileRetrieveResponse, options: params[:request_options] ) end |
#update(user_id, patch:, request_options: {}) ⇒ nil
Some parameter documentations has been truncated, see Models::ProfileUpdateParams for more details.
Applies a JSON Patch to a user profile, adding, removing, or replacing individual fields without sending the whole object.
89 90 91 92 93 94 95 96 97 98 |
# File 'lib/courier/resources/profiles.rb', line 89 def update(user_id, params) parsed, = Courier::ProfileUpdateParams.dump_request(params) @client.request( method: :patch, path: ["profiles/%1$s", user_id], body: parsed, model: NilClass, options: ) end |