Class: Courier::Resources::Users::Preferences

Inherits:
Object
  • Object
show all
Defined in:
lib/courier/resources/users/preferences.rb

Instance Method Summary collapse

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.

Parameters:



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.

Parameters:

  • user_id (String)

    A unique identifier associated with the user whose preferences you wish to retri

  • tenant_id (String, nil)

    Query the preferences of a user for this specific tenant context.

  • request_options (Courier::RequestOptions, Hash{Symbol=>Object}, nil)

Returns:

See Also:



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, options = 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: 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.

Parameters:

  • topic_id (String)

    Path param: A unique identifier associated with a subscription topic.

  • user_id (String)

    Path param: A unique identifier associated with the user whose preferences you w

  • tenant_id (String, nil)

    Query param: Query the preferences of a user for this specific tenant context.

  • request_options (Courier::RequestOptions, Hash{Symbol=>Object}, nil)

Returns:

See Also:



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, options = 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: 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.

Parameters:

  • topic_id (String)

    Path param: A unique identifier associated with a subscription topic.

  • user_id (String)

    Path param: A unique identifier associated with the user whose preferences you w

  • topic (Courier::Models::Users::PreferenceUpdateOrCreateTopicParams::Topic)

    Body param

  • tenant_id (String, nil)

    Query param: Update the preferences of a user for this specific tenant context.

  • request_options (Courier::RequestOptions, Hash{Symbol=>Object}, nil)

Returns:

See Also:



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, options = 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: options
  )
end