Class: Notiflows::Resources::Users::ChannelSettings
- Inherits:
-
Object
- Object
- Notiflows::Resources::Users::ChannelSettings
- Defined in:
- lib/notiflows/resources/users/channel_settings.rb
Instance Method Summary collapse
-
#delete(channel_id, user_external_id:, request_options: {}) ⇒ nil
Remove a user's settings for a specific channel.
-
#initialize(client:) ⇒ ChannelSettings
constructor
private
A new instance of ChannelSettings.
-
#retrieve(channel_id, user_external_id:, request_options: {}) ⇒ Notiflows::Models::Users::UsersChannelSettings
Retrieve a user's settings for a specific channel.
-
#update(channel_id, user_external_id:, settings:, request_options: {}) ⇒ Notiflows::Models::Users::UsersChannelSettings
Update a user's settings for a specific channel.
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.
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.
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, = ::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: ) 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).
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, = ::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: ) 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.
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, = ::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: ) end |