Class: Notiflows::Resources::Users::Preferences
- Inherits:
-
Object
- Object
- Notiflows::Resources::Users::Preferences
- Defined in:
- lib/notiflows/resources/users/preferences.rb
Instance Method Summary collapse
-
#initialize(client:) ⇒ Preferences
constructor
private
A new instance of Preferences.
-
#retrieve(user_external_id, request_options: {}) ⇒ ::Notiflows::Models::Users::UsersPreferences
Retrieve a user's notification preferences.
-
#update(user_external_id, channel_types: nil, notiflows: nil, request_options: {}) ⇒ ::Notiflows::Models::Users::UsersPreferences
Update a user's notification preferences.
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.
80 81 82 |
# File 'lib/notiflows/resources/users/preferences.rb', line 80 def initialize(client:) @client = client end |
Instance Method Details
#retrieve(user_external_id, request_options: {}) ⇒ ::Notiflows::Models::Users::UsersPreferences
Retrieve a user's notification preferences.
Preferences control which notifications the user receives:
channel_types: Global opt-in/opt-out per channel type (email, sms, push, etc.)notiflows: Per-notiflow preferences with optional channel overrides
24 25 26 27 28 29 30 31 |
# File 'lib/notiflows/resources/users/preferences.rb', line 24 def retrieve(user_external_id, params = {}) @client.request( method: :get, path: ["users/%1$s/preferences", user_external_id], model: ::Notiflows::Users::UsersPreferences, options: params[:request_options] ) end |
#update(user_external_id, channel_types: nil, notiflows: nil, request_options: {}) ⇒ ::Notiflows::Models::Users::UsersPreferences
Update a user's notification preferences. Only provided fields are updated (partial update).
Channel types: Set to false to opt the user out of a channel globally.
Notiflow preferences: Override settings for specific notiflows:
{
"notiflows": {
"notiflow_uuid": {
"enabled": true,
"channel_types": {
"email": false
}
}
}
}
66 67 68 69 70 71 72 73 74 75 |
# File 'lib/notiflows/resources/users/preferences.rb', line 66 def update(user_external_id, params = {}) parsed, = ::Notiflows::Users::PreferenceUpdateParams.dump_request(params) @client.request( method: :put, path: ["users/%1$s/preferences", user_external_id], body: parsed, model: ::Notiflows::Users::UsersPreferences, options: ) end |