Class: Notiflows::Resources::Users::ChannelSettings

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

Instance Method Summary collapse

Constructor Details

#initialize(client:) ⇒ ChannelSettings

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

Parameters:



126
127
128
# File 'lib/notiflows/resources/users/channel_settings.rb', line 126

def initialize(client:)
  @client = client
end

Instance Method Details

#delete(channel_id, user_external_id:, request_options: {}) ⇒ nil

Remove a user's settings for a specific channel.

After deletion, the user will no longer receive notifications through this channel until new settings are configured.

Parameters:

  • channel_id (String) —

    Channel ID (UUID)

  • user_external_id (String) —

    User external ID

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

Returns:

  • (nil)

See Also:



109
110
111
112
113
114
115
116
117
118
119
120
121
# File 'lib/notiflows/resources/users/channel_settings.rb', line 109

def delete(channel_id, params)
  parsed, options = ::Notiflows::Users::ChannelSettingDeleteParams.dump_request(params)
  user_external_id =
    parsed.delete(:user_external_id) do
      raise ArgumentError.new("missing required path argument #{_1}")
    end
  @client.request(
    method: :delete,
    path: ["users/%1$s/channel-settings/%2$s", user_external_id, channel_id],
    model: NilClass,
    options: options
  )
end

#retrieve(channel_id, user_external_id:, request_options: {}) ⇒ Notiflows::Models::Users::UsersChannelSettings

Retrieve a user's settings for a specific channel.

Channel settings store provider-specific data like device tokens (for push) or Slack user IDs (for chat).

Parameters:

  • channel_id (String) —

    Channel ID (UUID)

  • user_external_id (String) —

    User external ID

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

Returns:

See Also:



23
24
25
26
27
28
29
30
31
32
33
34
35
# File 'lib/notiflows/resources/users/channel_settings.rb', line 23

def retrieve(channel_id, params)
  parsed, options = ::Notiflows::Users::ChannelSettingRetrieveParams.dump_request(params)
  user_external_id =
    parsed.delete(:user_external_id) do
      raise ArgumentError.new("missing required path argument #{_1}")
    end
  @client.request(
    method: :get,
    path: ["users/%1$s/channel-settings/%2$s", user_external_id, channel_id],
    model: ::Notiflows::Users::UsersChannelSettings,
    options: options
  )
end

#update(channel_id, user_external_id:, settings:, request_options: {}) ⇒ Notiflows::Models::Users::UsersChannelSettings

Update a user's settings for a specific channel. Creates the settings if they don't exist.

Provider-specific settings:

Mobile Push (APNS/FCM):

{
  "settings": {
    "device_tokens": ["token1", "token2"]
  }
}

Slack:

{
  "settings": {
    "slack_channel_id": "C0123456789",
    "slack_user_id": "U0123456789"
  }
}

At least one of slack_channel_id or slack_user_id must be provided.

Parameters:

Returns:

See Also:



78
79
80
81
82
83
84
85
86
87
88
89
90
91
# File 'lib/notiflows/resources/users/channel_settings.rb', line 78

def update(channel_id, params)
  parsed, options = ::Notiflows::Users::ChannelSettingUpdateParams.dump_request(params)
  user_external_id =
    parsed.delete(:user_external_id) do
      raise ArgumentError.new("missing required path argument #{_1}")
    end
  @client.request(
    method: :put,
    path: ["users/%1$s/channel-settings/%2$s", user_external_id, channel_id],
    body: parsed,
    model: ::Notiflows::Users::UsersChannelSettings,
    options: options
  )
end