Class: Whop_sdk::Users::Preferences::Notifications::Client
- Inherits:
-
Object
- Object
- Whop_sdk::Users::Preferences::Notifications::Client
- Defined in:
- lib/whop_sdk/users/preferences/notifications/client.rb
Instance Method Summary collapse
- #experiences ⇒ Whop_sdk::Experiences::Client
- #initialize(client:) ⇒ void constructor
-
#set(request_options: {}, **params) ⇒ Whop_sdk::Users::Preferences::Notifications::Types::SetNotificationsResponse
Sets the authenticated user's notification preferences.
- #topics ⇒ Whop_sdk::Topics::Client
Constructor Details
#initialize(client:) ⇒ void
11 12 13 |
# File 'lib/whop_sdk/users/preferences/notifications/client.rb', line 11 def initialize(client:) @client = client end |
Instance Method Details
#experiences ⇒ Whop_sdk::Experiences::Client
68 69 70 |
# File 'lib/whop_sdk/users/preferences/notifications/client.rb', line 68 def experiences @experiences ||= Whop_sdk::Users::Preferences::Notifications::Experiences::Client.new(client: @client) end |
#set(request_options: {}, **params) ⇒ Whop_sdk::Users::Preferences::Notifications::Types::SetNotificationsResponse
Sets the authenticated user's notification preferences. Each preference is addressed by scope, not by id,
so a scope read back from either list endpoint can be sent straight here.
A scope naming an experience with no topic sets that experience's level, and accepts all three levels. Any
other scope sets a topic override, which is binary — all or nothing. A topic override with no channel
applies to every delivery channel.
level: null clears the preference. Preferences are stored as overrides, so clearing one means the scope
inherits its default again rather than being switched off.
The batch is applied in one transaction: if any entry is rejected, none are written. Experience levels are applied before topic overrides, because setting a level replaces every topic preference for that experience — so an override sent alongside a level wins. The response reports what each scope now resolves to, in the order the entries were sent.
44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 |
# File 'lib/whop_sdk/users/preferences/notifications/client.rb', line 44 def set(request_options: {}, **params) params = Whop_sdk::Internal::Types::Utils.normalize_keys(params) request = Whop_sdk::Internal::JSON::Request.new( base_url: [:base_url], method: "PATCH", path: "users/me/preferences/notifications", body: Whop_sdk::Users::Preferences::Notifications::Types::SetNotificationsRequest.new(params).to_h, request_options: ) begin response = @client.send(request) rescue Net::HTTPRequestTimeout raise Whop_sdk::Errors::TimeoutError end code = response.code.to_i if code.between?(200, 299) Whop_sdk::Users::Preferences::Notifications::Types::SetNotificationsResponse.load(response.body) else error_class = Whop_sdk::Errors::ResponseError.subclass_for_code(code) raise error_class.new(response.body, code: code) end end |
#topics ⇒ Whop_sdk::Topics::Client
73 74 75 |
# File 'lib/whop_sdk/users/preferences/notifications/client.rb', line 73 def topics @topics ||= Whop_sdk::Users::Preferences::Notifications::Topics::Client.new(client: @client) end |