Class: Courier::Users::AsyncPreferencesClient
- Inherits:
-
Object
- Object
- Courier::Users::AsyncPreferencesClient
- Defined in:
- lib/trycourier/users/preferences/client.rb
Instance Attribute Summary collapse
-
#request_client ⇒ Object
readonly
Returns the value of attribute request_client.
Instance Method Summary collapse
-
#get(user_id:, topic_id:, request_options: nil) ⇒ Users::Preferences::UserPreferencesGetResponse
Fetch user preferences for a specific subscription topic.
- #initialize(request_client:) ⇒ Users::AsyncPreferencesClient constructor
-
#list(user_id:, request_options: nil) ⇒ Users::Preferences::UserPreferencesListResponse
Fetch all user preferences.
-
#update(user_id:, topic_id:, status:, default_status:, custom_routing: nil, has_custom_routing: nil, request_options: nil) ⇒ Users::Preferences::UserPreferencesUpdateResponse
Update or Create user preferences for a specific subscription topic.
Constructor Details
#initialize(request_client:) ⇒ Users::AsyncPreferencesClient
94 95 96 97 |
# File 'lib/trycourier/users/preferences/client.rb', line 94 def initialize(request_client:) # @type [AsyncRequestClient] @request_client = request_client end |
Instance Attribute Details
#request_client ⇒ Object (readonly)
Returns the value of attribute request_client.
90 91 92 |
# File 'lib/trycourier/users/preferences/client.rb', line 90 def request_client @request_client end |
Instance Method Details
#get(user_id:, topic_id:, request_options: nil) ⇒ Users::Preferences::UserPreferencesGetResponse
Fetch user preferences for a specific subscription topic.
124 125 126 127 128 129 130 131 132 133 134 135 136 |
# File 'lib/trycourier/users/preferences/client.rb', line 124 def get(user_id:, topic_id:, request_options: nil) Async do response = @request_client.conn.get("/users/#{user_id}/preferences/#{topic_id}") do |req| req..timeout = .timeout_in_seconds unless &.timeout_in_seconds.nil? unless &..nil? req.headers["Authorization"] = . end req.headers = { **req.headers, **(&.additional_headers || {}) }.compact end Users::Preferences::UserPreferencesGetResponse.from_json(json_object: response.body) end end |
#list(user_id:, request_options: nil) ⇒ Users::Preferences::UserPreferencesListResponse
Fetch all user preferences.
104 105 106 107 108 109 110 111 112 113 114 115 116 |
# File 'lib/trycourier/users/preferences/client.rb', line 104 def list(user_id:, request_options: nil) Async do response = @request_client.conn.get("/users/#{user_id}/preferences") do |req| req..timeout = .timeout_in_seconds unless &.timeout_in_seconds.nil? unless &..nil? req.headers["Authorization"] = . end req.headers = { **req.headers, **(&.additional_headers || {}) }.compact end Users::Preferences::UserPreferencesListResponse.from_json(json_object: response.body) end end |
#update(user_id:, topic_id:, status:, default_status:, custom_routing: nil, has_custom_routing: nil, request_options: nil) ⇒ Users::Preferences::UserPreferencesUpdateResponse
Update or Create user preferences for a specific subscription topic.
148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 |
# File 'lib/trycourier/users/preferences/client.rb', line 148 def update(user_id:, topic_id:, status:, default_status:, custom_routing: nil, has_custom_routing: nil, request_options: nil) Async do response = @request_client.conn.put("/users/#{user_id}/preferences/#{topic_id}") do |req| req..timeout = .timeout_in_seconds unless &.timeout_in_seconds.nil? unless &..nil? req.headers["Authorization"] = . end req.headers = { **req.headers, **(&.additional_headers || {}) }.compact req.body = { **(&.additional_body_parameters || {}), status: status, custom_routing: custom_routing, default_status: default_status, has_custom_routing: has_custom_routing }.compact end Users::Preferences::UserPreferencesUpdateResponse.from_json(json_object: response.body) end end |