Class: Courier::Resources::Users::Preferences
- Inherits:
-
Object
- Object
- Courier::Resources::Users::Preferences
- Defined in:
- lib/courier/resources/users/preferences.rb,
sig/courier/resources/users/preferences.rbs
Overview
Read and write a single user's notification preferences, per topic and per channel.
Instance Method Summary collapse
-
#bulk_replace(user_id, topics:, tenant_id: nil, request_options: {}) ⇒ Courier::Models::Users::PreferenceBulkReplaceResponse
Some parameter documentations has been truncated, see Models::Users::PreferenceBulkReplaceParams for more details.
-
#bulk_update(user_id, topics:, tenant_id: nil, idempotency_key: nil, x_idempotency_expiration: nil, request_options: {}) ⇒ Courier::Models::Users::PreferenceBulkUpdateResponse
Some parameter documentations has been truncated, see Models::Users::PreferenceBulkUpdateParams for more details.
-
#delete_topic(topic_id, user_id:, tenant_id: nil, request_options: {}) ⇒ nil
Some parameter documentations has been truncated, see Models::Users::PreferenceDeleteTopicParams for more details.
-
#initialize(client:) ⇒ Preferences
constructor
private
A new instance of Preferences.
-
#retrieve(user_id, tenant_id: nil, request_options: {}) ⇒ Courier::Models::Users::PreferenceRetrieveResponse
Some parameter documentations has been truncated, see Models::Users::PreferenceRetrieveParams for more details.
-
#retrieve_topic(topic_id, user_id:, tenant_id: nil, request_options: {}) ⇒ Courier::Models::Users::PreferenceRetrieveTopicResponse
Some parameter documentations has been truncated, see Models::Users::PreferenceRetrieveTopicParams for more details.
-
#update_or_create_topic(topic_id, user_id:, topic:, tenant_id: nil, request_options: {}) ⇒ Courier::Models::Users::PreferenceUpdateOrCreateTopicResponse
Some parameter documentations has been truncated, see Models::Users::PreferenceUpdateOrCreateTopicParams for more details.
Constructor Details
#initialize(client:) ⇒ Preferences
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 Preferences.
223 224 225 |
# File 'lib/courier/resources/users/preferences.rb', line 223 def initialize(client:) @client = client end |
Instance Method Details
#bulk_replace(user_id, topics:, tenant_id: nil, request_options: {}) ⇒ Courier::Models::Users::PreferenceBulkReplaceResponse
Some parameter documentations has been truncated, see Models::Users::PreferenceBulkReplaceParams for more details.
Replaces a user's entire set of preference overrides. Any topic you leave out is reset to its default, so send the full set rather than a subset.
57 58 59 60 61 62 63 64 65 66 67 68 69 |
# File 'lib/courier/resources/users/preferences.rb', line 57 def bulk_replace(user_id, params) query_params = [:tenant_id] parsed, = Courier::Users::PreferenceBulkReplaceParams.dump_request(params) query = Courier::Internal::Util.encode_query_params(parsed.slice(*query_params)) @client.request( method: :put, path: ["users/%1$s/preferences", user_id], query: query, body: parsed.except(*query_params), model: Courier::Models::Users::PreferenceBulkReplaceResponse, options: ) end |
#bulk_update(user_id, topics:, tenant_id: nil, idempotency_key: nil, x_idempotency_expiration: nil, request_options: {}) ⇒ Courier::Models::Users::PreferenceBulkUpdateResponse
Some parameter documentations has been truncated, see Models::Users::PreferenceBulkUpdateParams for more details.
Adds or updates a user's preferences for several subscription topics at once. Topics you leave out keep whatever they were set to before.
94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 |
# File 'lib/courier/resources/users/preferences.rb', line 94 def bulk_update(user_id, params) query_params = [:tenant_id] header_params = {idempotency_key: "idempotency-key", x_idempotency_expiration: "x-idempotency-expiration"} parsed, = Courier::Users::PreferenceBulkUpdateParams.dump_request(params) query = Courier::Internal::Util.encode_query_params(parsed.slice(*query_params)) @client.request( method: :post, path: ["users/%1$s/preferences", user_id], query: query, headers: parsed.slice(*header_params.keys).transform_keys(header_params), body: parsed.except(*query_params, *header_params.keys), model: Courier::Models::Users::PreferenceBulkUpdateResponse, options: ) end |
#delete_topic(topic_id, user_id:, tenant_id: nil, request_options: {}) ⇒ nil
Some parameter documentations has been truncated, see Models::Users::PreferenceDeleteTopicParams for more details.
Removes a user's override for one subscription topic, resetting it to the effective default from the tenant or workspace.
130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 |
# File 'lib/courier/resources/users/preferences.rb', line 130 def delete_topic(topic_id, params) parsed, = Courier::Users::PreferenceDeleteTopicParams.dump_request(params) query = Courier::Internal::Util.encode_query_params(parsed) user_id = parsed.delete(:user_id) do raise ArgumentError.new("missing required path argument #{_1}") end @client.request( method: :delete, path: ["users/%1$s/preferences/%2$s", user_id, topic_id], query: query, model: NilClass, options: ) end |
#retrieve(user_id, tenant_id: nil, request_options: {}) ⇒ Courier::Models::Users::PreferenceRetrieveResponse
Some parameter documentations has been truncated, see Models::Users::PreferenceRetrieveParams for more details.
Returns a user's preference overrides with paging, one entry per subscription topic they have set a choice for.
26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/courier/resources/users/preferences.rb', line 26 def retrieve(user_id, params = {}) parsed, = Courier::Users::PreferenceRetrieveParams.dump_request(params) query = Courier::Internal::Util.encode_query_params(parsed) @client.request( method: :get, path: ["users/%1$s/preferences", user_id], query: query, model: Courier::Models::Users::PreferenceRetrieveResponse, options: ) end |
#retrieve_topic(topic_id, user_id:, tenant_id: nil, request_options: {}) ⇒ Courier::Models::Users::PreferenceRetrieveTopicResponse
Some parameter documentations has been truncated, see Models::Users::PreferenceRetrieveTopicParams for more details.
Returns a user's opt-in status and channel choices for one subscription topic, or the effective default if they have set no override.
165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 |
# File 'lib/courier/resources/users/preferences.rb', line 165 def retrieve_topic(topic_id, params) parsed, = Courier::Users::PreferenceRetrieveTopicParams.dump_request(params) query = Courier::Internal::Util.encode_query_params(parsed) user_id = parsed.delete(:user_id) do raise ArgumentError.new("missing required path argument #{_1}") end @client.request( method: :get, path: ["users/%1$s/preferences/%2$s", user_id, topic_id], query: query, model: Courier::Models::Users::PreferenceRetrieveTopicResponse, options: ) end |
#update_or_create_topic(topic_id, user_id:, topic:, tenant_id: nil, request_options: {}) ⇒ Courier::Models::Users::PreferenceUpdateOrCreateTopicResponse
Some parameter documentations has been truncated, see Models::Users::PreferenceUpdateOrCreateTopicParams for more details.
Sets a user's opt-in status and channel choices for one subscription topic, overriding the tenant default for that topic only.
202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 |
# File 'lib/courier/resources/users/preferences.rb', line 202 def update_or_create_topic(topic_id, params) query_params = [:tenant_id] parsed, = Courier::Users::PreferenceUpdateOrCreateTopicParams.dump_request(params) query = Courier::Internal::Util.encode_query_params(parsed.slice(*query_params)) user_id = parsed.delete(:user_id) do raise ArgumentError.new("missing required path argument #{_1}") end @client.request( method: :put, path: ["users/%1$s/preferences/%2$s", user_id, topic_id], query: query, body: parsed.except(*query_params), model: Courier::Models::Users::PreferenceUpdateOrCreateTopicResponse, options: ) end |