Class: Notiflows::Resources::Users
- Inherits:
-
Object
- Object
- Notiflows::Resources::Users
- Defined in:
- lib/notiflows/resources/users.rb,
lib/notiflows/resources/users/deliveries.rb,
lib/notiflows/resources/users/preferences.rb,
lib/notiflows/resources/users/notifications.rb,
lib/notiflows/resources/users/subscriptions.rb,
lib/notiflows/resources/users/channel_settings.rb
Defined Under Namespace
Classes: ChannelSettings, Deliveries, Notifications, Preferences, Subscriptions
Instance Attribute Summary collapse
- #channel_settings ⇒ Notiflows::Resources::Users::ChannelSettings readonly
- #deliveries ⇒ Notiflows::Resources::Users::Deliveries readonly
- #notifications ⇒ Notiflows::Resources::Users::Notifications readonly
- #preferences ⇒ Notiflows::Resources::Users::Preferences readonly
- #subscriptions ⇒ Notiflows::Resources::Users::Subscriptions readonly
Instance Method Summary collapse
-
#delete(user_external_id, request_options: {}) ⇒ nil
Permanently delete a user and all their associated data including:.
-
#initialize(client:) ⇒ Users
constructor
private
A new instance of Users.
-
#list(after: nil, before: nil, created_after: nil, created_before: nil, limit: nil, request_options: {}) ⇒ Notiflows::Internal::CursorPage<Notiflows::Models::User>
Retrieve a paginated list of users in your project.
-
#retrieve(user_external_id, request_options: {}) ⇒ Notiflows::Models::User
Retrieve a single user by their external ID.
-
#upsert(user_external_id, external_id:, avatar: nil, channel_settings: nil, custom_fields: nil, email: nil, first_name: nil, last_name: nil, locale: nil, phone: nil, preferences: nil, timezone: nil, request_options: {}) ⇒ Notiflows::Models::User
Create a new user or update an existing user by external ID (upsert operation).
Constructor Details
#initialize(client:) ⇒ Users
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 Users.
157 158 159 160 161 162 163 164 |
# File 'lib/notiflows/resources/users.rb', line 157 def initialize(client:) @client = client @channel_settings = ChannelSettings.new(client: client) @deliveries = Deliveries.new(client: client) @notifications = Notifications.new(client: client) @preferences = Preferences.new(client: client) @subscriptions = Subscriptions.new(client: client) end |
Instance Attribute Details
#channel_settings ⇒ Notiflows::Resources::Users::ChannelSettings (readonly)
7 8 9 |
# File 'lib/notiflows/resources/users.rb', line 7 def channel_settings @channel_settings end |
#deliveries ⇒ Notiflows::Resources::Users::Deliveries (readonly)
10 11 12 |
# File 'lib/notiflows/resources/users.rb', line 10 def deliveries @deliveries end |
#notifications ⇒ Notiflows::Resources::Users::Notifications (readonly)
13 14 15 |
# File 'lib/notiflows/resources/users.rb', line 13 def notifications @notifications end |
#preferences ⇒ Notiflows::Resources::Users::Preferences (readonly)
16 17 18 |
# File 'lib/notiflows/resources/users.rb', line 16 def preferences @preferences end |
#subscriptions ⇒ Notiflows::Resources::Users::Subscriptions (readonly)
19 20 21 |
# File 'lib/notiflows/resources/users.rb', line 19 def subscriptions @subscriptions end |
Instance Method Details
#delete(user_external_id, request_options: {}) ⇒ nil
Permanently delete a user and all their associated data including:
- Subscriptions
- Preferences
- Channel settings
- Notifications and deliveries
This action cannot be undone.
92 93 94 95 96 97 98 99 |
# File 'lib/notiflows/resources/users.rb', line 92 def delete(user_external_id, params = {}) @client.request( method: :delete, path: ["users/%1$s", user_external_id], model: NilClass, options: params[:request_options] ) end |
#list(after: nil, before: nil, created_after: nil, created_before: nil, limit: nil, request_options: {}) ⇒ Notiflows::Internal::CursorPage<Notiflows::Models::User>
Retrieve a paginated list of users in your project. Users are sorted by creation date (newest first).
62 63 64 65 66 67 68 69 70 71 72 |
# File 'lib/notiflows/resources/users.rb', line 62 def list(params = {}) parsed, = ::Notiflows::UserListParams.dump_request(params) @client.request( method: :get, path: "users", query: parsed, page: ::Notiflows::Internal::CursorPage, model: ::Notiflows::User, options: ) end |
#retrieve(user_external_id, request_options: {}) ⇒ Notiflows::Models::User
Retrieve a single user by their external ID. The external ID is the identifier you assigned when creating the user.
33 34 35 36 37 38 39 40 |
# File 'lib/notiflows/resources/users.rb', line 33 def retrieve(user_external_id, params = {}) @client.request( method: :get, path: ["users/%1$s", user_external_id], model: ::Notiflows::User, options: params[:request_options] ) end |
#upsert(user_external_id, external_id:, avatar: nil, channel_settings: nil, custom_fields: nil, email: nil, first_name: nil, last_name: nil, locale: nil, phone: nil, preferences: nil, timezone: nil, request_options: {}) ⇒ Notiflows::Models::User
Create a new user or update an existing user by external ID (upsert operation).
- If the user doesn't exist, they will be created with the provided attributes.
- If the user exists, their attributes will be updated (merge behavior).
custom_fieldsare deep-merged with existing values.
Returns:
201 Createdwhen a new user is created200 OKwhen an existing user is updated
143 144 145 146 147 148 149 150 151 152 |
# File 'lib/notiflows/resources/users.rb', line 143 def upsert(user_external_id, params) parsed, = ::Notiflows::UserUpsertParams.dump_request(params) @client.request( method: :put, path: ["users/%1$s", user_external_id], body: parsed, model: ::Notiflows::User, options: ) end |