Class: Courier::Resources::Users::Preferences
- Inherits:
-
Object
- Object
- Courier::Resources::Users::Preferences
- Defined in:
- lib/courier/resources/users/preferences.rb
Instance Method Summary collapse
-
#initialize(client:) ⇒ Preferences
constructor
private
A new instance of Preferences.
-
#retrieve(user_id, tenant_id: nil, request_options: {}) ⇒ Courier::Models::Users::PreferenceRetrieveResponse
Some parameter documentations has been truncated, see Models::Users::PreferenceRetrieveParams for more details.
-
#retrieve_topic(topic_id, user_id:, tenant_id: nil, request_options: {}) ⇒ Courier::Models::Users::PreferenceRetrieveTopicResponse
Some parameter documentations has been truncated, see Models::Users::PreferenceRetrieveTopicParams for more details.
-
#update_or_create_topic(topic_id, user_id:, topic:, tenant_id: nil, request_options: {}) ⇒ Courier::Models::Users::PreferenceUpdateOrCreateTopicResponse
Some parameter documentations has been truncated, see Models::Users::PreferenceUpdateOrCreateTopicParams for more details.
Constructor Details
#initialize(client:) ⇒ Preferences
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 Preferences.
110 111 112 |
# File 'lib/courier/resources/users/preferences.rb', line 110 def initialize(client:) @client = client end |
Instance Method Details
#retrieve(user_id, tenant_id: nil, request_options: {}) ⇒ Courier::Models::Users::PreferenceRetrieveResponse
Some parameter documentations has been truncated, see Models::Users::PreferenceRetrieveParams for more details.
Fetch all user preferences.
23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/courier/resources/users/preferences.rb', line 23 def retrieve(user_id, params = {}) parsed, = Courier::Users::PreferenceRetrieveParams.dump_request(params) query = Courier::Internal::Util.encode_query_params(parsed) @client.request( method: :get, path: ["users/%1$s/preferences", user_id], query: query, model: Courier::Models::Users::PreferenceRetrieveResponse, options: ) end |
#retrieve_topic(topic_id, user_id:, tenant_id: nil, request_options: {}) ⇒ Courier::Models::Users::PreferenceRetrieveTopicResponse
Some parameter documentations has been truncated, see Models::Users::PreferenceRetrieveTopicParams for more details.
Fetch user preferences for a specific subscription topic.
53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 |
# File 'lib/courier/resources/users/preferences.rb', line 53 def retrieve_topic(topic_id, params) parsed, = Courier::Users::PreferenceRetrieveTopicParams.dump_request(params) query = Courier::Internal::Util.encode_query_params(parsed) user_id = parsed.delete(:user_id) do raise ArgumentError.new("missing required path argument #{_1}") end @client.request( method: :get, path: ["users/%1$s/preferences/%2$s", user_id, topic_id], query: query, model: Courier::Models::Users::PreferenceRetrieveTopicResponse, options: ) end |
#update_or_create_topic(topic_id, user_id:, topic:, tenant_id: nil, request_options: {}) ⇒ Courier::Models::Users::PreferenceUpdateOrCreateTopicResponse
Some parameter documentations has been truncated, see Models::Users::PreferenceUpdateOrCreateTopicParams for more details.
Update or Create user preferences for a specific subscription topic.
89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 |
# File 'lib/courier/resources/users/preferences.rb', line 89 def update_or_create_topic(topic_id, params) query_params = [:tenant_id] parsed, = Courier::Users::PreferenceUpdateOrCreateTopicParams.dump_request(params) query = Courier::Internal::Util.encode_query_params(parsed.slice(*query_params)) user_id = parsed.delete(:user_id) do raise ArgumentError.new("missing required path argument #{_1}") end @client.request( method: :put, path: ["users/%1$s/preferences/%2$s", user_id, topic_id], query: query, body: parsed.except(*query_params), model: Courier::Models::Users::PreferenceUpdateOrCreateTopicResponse, options: ) end |