Class: Notiflows::Resources::Users::Preferences

Inherits:
Object
  • Object
show all
Defined in:
lib/notiflows/resources/users/preferences.rb

Instance Method Summary collapse

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.

Parameters:



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

Parameters:

Returns:

See Also:



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
      }
    }
  }
}

Parameters:

Returns:

See Also:



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, options = ::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: options
  )
end