Class: Notiflows::Resources::Users

Inherits:
Object
  • Object
show all
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

Instance Method Summary collapse

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.

Parameters:



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.

Parameters:

Returns:

  • (nil)

See Also:



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).

Parameters:

  • after (String) —

    Cursor for fetching the next page

  • before (String) —

    Cursor for fetching the previous page

  • created_after (String) —

    Filter users created after this datetime (ISO 8601)

  • created_before (String) —

    Filter users created before this datetime (ISO 8601)

  • limit (Integer) —

    Number of items per page (default: 25, max: 1000)

  • request_options (Notiflows::RequestOptions, Hash{Symbol=>Object}, nil)

Returns:

See Also:



62
63
64
65
66
67
68
69
70
71
72
# File 'lib/notiflows/resources/users.rb', line 62

def list(params = {})
  parsed, options = ::Notiflows::UserListParams.dump_request(params)
  @client.request(
    method: :get,
    path: "users",
    query: parsed,
    page: ::Notiflows::Internal::CursorPage,
    model: ::Notiflows::User,
    options: 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.

Parameters:

  • user_external_id (String) —

    User external ID (your system's user identifier)

  • request_options (Notiflows::RequestOptions, Hash{Symbol=>Object}, nil)

Returns:

See Also:



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_fields are deep-merged with existing values.

Returns:

  • 201 Created when a new user is created
  • 200 OK when an existing user is updated

Parameters:

  • user_external_id (String) —

    User external ID

  • external_id (String) —

    Your system's unique identifier for this user. Required for creating new users.

  • avatar (String) —

    URL to user's avatar image (must start with http:// or https://)

  • channel_settings (Array<Notiflows::Models::UserUpsertParams::ChannelSetting>) —

    Initial channel settings (e.g., device tokens for push)

  • custom_fields (Object) —

    Custom attributes. Deep-merged with existing values on update.

  • email (String) —

    User's email address

  • first_name (String) —

    User's first name

  • last_name (String) —

    User's last name

  • locale (String) —

    BCP 47 locale code (e.g., en-US, es-ES, fr-FR)

  • phone (String) —

    User's phone number in E.164 format

  • preferences (::Notiflows::Models::Users::UpdatePreferencesRequest) —

    Request body for updating user preferences. Only provided fields are updated.

  • timezone (String) —

    IANA timezone (e.g., America/New_York, Europe/London)

  • request_options (Notiflows::RequestOptions, Hash{Symbol=>Object}, nil)

Returns:

See Also:



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, options = ::Notiflows::UserUpsertParams.dump_request(params)
  @client.request(
    method: :put,
    path: ["users/%1$s", user_external_id],
    body: parsed,
    model: ::Notiflows::User,
    options: options
  )
end