|
4 | 4 | require_relative "../types/upserted_user" |
5 | 5 | require_relative "../types/user" |
6 | 6 | require_relative "../types/updated_user" |
| 7 | +require_relative "../types/user_preferences_response" |
| 8 | +require_relative "../types/notification_preferences" |
7 | 9 | require_relative "../types/metric_response" |
8 | 10 | require "json" |
9 | 11 | require_relative "types/users_metric_event_summary_request_aggregation" |
@@ -171,6 +173,73 @@ def update(id:, request:, request_options: nil) |
171 | 173 | TrophyApiClient::User.from_json(json_object: response.body) |
172 | 174 | end |
173 | 175 |
|
| 176 | + # Get a user's notification preferences. |
| 177 | + # |
| 178 | + # @param id [String] The user's ID in your database. |
| 179 | + # @param request_options [TrophyApiClient::RequestOptions] |
| 180 | + # @return [TrophyApiClient::UserPreferencesResponse] |
| 181 | + # @example |
| 182 | + # api = TrophyApiClient::Client.new( |
| 183 | + # base_url: "https://api.example.com", |
| 184 | + # environment: TrophyApiClient::Environment::PRODUCTION, |
| 185 | + # api_key: "YOUR_API_KEY" |
| 186 | + # ) |
| 187 | + # api.users.get_preferences(id: "user-123") |
| 188 | + def get_preferences(id:, request_options: nil) |
| 189 | + response = @request_client.conn.get do |req| |
| 190 | + req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil? |
| 191 | + req.headers["X-API-KEY"] = request_options.api_key unless request_options&.api_key.nil? |
| 192 | + req.headers = { |
| 193 | + **(req.headers || {}), |
| 194 | + **@request_client.get_headers, |
| 195 | + **(request_options&.additional_headers || {}) |
| 196 | + }.compact |
| 197 | + unless request_options.nil? || request_options&.additional_query_parameters.nil? |
| 198 | + req.params = { **(request_options&.additional_query_parameters || {}) }.compact |
| 199 | + end |
| 200 | + unless request_options.nil? || request_options&.additional_body_parameters.nil? |
| 201 | + req.body = { **(request_options&.additional_body_parameters || {}) }.compact |
| 202 | + end |
| 203 | + req.url "#{@request_client.get_url(environment: api, request_options: request_options)}/users/#{id}/preferences" |
| 204 | + end |
| 205 | + TrophyApiClient::UserPreferencesResponse.from_json(json_object: response.body) |
| 206 | + end |
| 207 | + |
| 208 | + # Update a user's notification preferences. |
| 209 | + # |
| 210 | + # @param id [String] The user's ID in your database. |
| 211 | + # @param notifications [Hash] Request of type TrophyApiClient::NotificationPreferences, as a Hash |
| 212 | + # * :achievement_completed (Array<TrophyApiClient::NotificationChannel>) |
| 213 | + # * :recap (Array<TrophyApiClient::NotificationChannel>) |
| 214 | + # * :reactivation (Array<TrophyApiClient::NotificationChannel>) |
| 215 | + # * :streak_reminder (Array<TrophyApiClient::NotificationChannel>) |
| 216 | + # @param request_options [TrophyApiClient::RequestOptions] |
| 217 | + # @return [TrophyApiClient::UserPreferencesResponse] |
| 218 | + # @example |
| 219 | + # api = TrophyApiClient::Client.new( |
| 220 | + # base_url: "https://api.example.com", |
| 221 | + # environment: TrophyApiClient::Environment::PRODUCTION, |
| 222 | + # api_key: "YOUR_API_KEY" |
| 223 | + # ) |
| 224 | + # api.users.update_preferences(id: "user-123", notifications: { streak_reminder: [EMAIL] }) |
| 225 | + def update_preferences(id:, notifications: nil, request_options: nil) |
| 226 | + response = @request_client.conn.patch do |req| |
| 227 | + req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil? |
| 228 | + req.headers["X-API-KEY"] = request_options.api_key unless request_options&.api_key.nil? |
| 229 | + req.headers = { |
| 230 | + **(req.headers || {}), |
| 231 | + **@request_client.get_headers, |
| 232 | + **(request_options&.additional_headers || {}) |
| 233 | + }.compact |
| 234 | + unless request_options.nil? || request_options&.additional_query_parameters.nil? |
| 235 | + req.params = { **(request_options&.additional_query_parameters || {}) }.compact |
| 236 | + end |
| 237 | + req.body = { **(request_options&.additional_body_parameters || {}), notifications: notifications }.compact |
| 238 | + req.url "#{@request_client.get_url(environment: api, request_options: request_options)}/users/#{id}/preferences" |
| 239 | + end |
| 240 | + TrophyApiClient::UserPreferencesResponse.from_json(json_object: response.body) |
| 241 | + end |
| 242 | + |
174 | 243 | # Get a single user's progress against all active metrics. |
175 | 244 | # |
176 | 245 | # @param id [String] ID of the user |
@@ -697,6 +766,79 @@ def update(id:, request:, request_options: nil) |
697 | 766 | end |
698 | 767 | end |
699 | 768 |
|
| 769 | + # Get a user's notification preferences. |
| 770 | + # |
| 771 | + # @param id [String] The user's ID in your database. |
| 772 | + # @param request_options [TrophyApiClient::RequestOptions] |
| 773 | + # @return [TrophyApiClient::UserPreferencesResponse] |
| 774 | + # @example |
| 775 | + # api = TrophyApiClient::Client.new( |
| 776 | + # base_url: "https://api.example.com", |
| 777 | + # environment: TrophyApiClient::Environment::PRODUCTION, |
| 778 | + # api_key: "YOUR_API_KEY" |
| 779 | + # ) |
| 780 | + # api.users.get_preferences(id: "user-123") |
| 781 | + def get_preferences(id:, request_options: nil) |
| 782 | + Async do |
| 783 | + response = @request_client.conn.get do |req| |
| 784 | + req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil? |
| 785 | + req.headers["X-API-KEY"] = request_options.api_key unless request_options&.api_key.nil? |
| 786 | + req.headers = { |
| 787 | + **(req.headers || {}), |
| 788 | + **@request_client.get_headers, |
| 789 | + **(request_options&.additional_headers || {}) |
| 790 | + }.compact |
| 791 | + unless request_options.nil? || request_options&.additional_query_parameters.nil? |
| 792 | + req.params = { **(request_options&.additional_query_parameters || {}) }.compact |
| 793 | + end |
| 794 | + unless request_options.nil? || request_options&.additional_body_parameters.nil? |
| 795 | + req.body = { **(request_options&.additional_body_parameters || {}) }.compact |
| 796 | + end |
| 797 | + req.url "#{@request_client.get_url(environment: api, |
| 798 | + request_options: request_options)}/users/#{id}/preferences" |
| 799 | + end |
| 800 | + TrophyApiClient::UserPreferencesResponse.from_json(json_object: response.body) |
| 801 | + end |
| 802 | + end |
| 803 | + |
| 804 | + # Update a user's notification preferences. |
| 805 | + # |
| 806 | + # @param id [String] The user's ID in your database. |
| 807 | + # @param notifications [Hash] Request of type TrophyApiClient::NotificationPreferences, as a Hash |
| 808 | + # * :achievement_completed (Array<TrophyApiClient::NotificationChannel>) |
| 809 | + # * :recap (Array<TrophyApiClient::NotificationChannel>) |
| 810 | + # * :reactivation (Array<TrophyApiClient::NotificationChannel>) |
| 811 | + # * :streak_reminder (Array<TrophyApiClient::NotificationChannel>) |
| 812 | + # @param request_options [TrophyApiClient::RequestOptions] |
| 813 | + # @return [TrophyApiClient::UserPreferencesResponse] |
| 814 | + # @example |
| 815 | + # api = TrophyApiClient::Client.new( |
| 816 | + # base_url: "https://api.example.com", |
| 817 | + # environment: TrophyApiClient::Environment::PRODUCTION, |
| 818 | + # api_key: "YOUR_API_KEY" |
| 819 | + # ) |
| 820 | + # api.users.update_preferences(id: "user-123", notifications: { streak_reminder: [EMAIL] }) |
| 821 | + def update_preferences(id:, notifications: nil, request_options: nil) |
| 822 | + Async do |
| 823 | + response = @request_client.conn.patch do |req| |
| 824 | + req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil? |
| 825 | + req.headers["X-API-KEY"] = request_options.api_key unless request_options&.api_key.nil? |
| 826 | + req.headers = { |
| 827 | + **(req.headers || {}), |
| 828 | + **@request_client.get_headers, |
| 829 | + **(request_options&.additional_headers || {}) |
| 830 | + }.compact |
| 831 | + unless request_options.nil? || request_options&.additional_query_parameters.nil? |
| 832 | + req.params = { **(request_options&.additional_query_parameters || {}) }.compact |
| 833 | + end |
| 834 | + req.body = { **(request_options&.additional_body_parameters || {}), notifications: notifications }.compact |
| 835 | + req.url "#{@request_client.get_url(environment: api, |
| 836 | + request_options: request_options)}/users/#{id}/preferences" |
| 837 | + end |
| 838 | + TrophyApiClient::UserPreferencesResponse.from_json(json_object: response.body) |
| 839 | + end |
| 840 | + end |
| 841 | + |
700 | 842 | # Get a single user's progress against all active metrics. |
701 | 843 | # |
702 | 844 | # @param id [String] ID of the user |
|
0 commit comments