Class: Trycourier::Resources::Users::Preferences

Inherits:
Object
  • Object
show all
Defined in:
lib/trycourier/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:



108
109
110
# File 'lib/trycourier/resources/users/preferences.rb', line 108

def initialize(client:)
  @client = client
end

Instance Method Details

#retrieve(user_id, tenant_id: nil, request_options: {}) ⇒ Trycourier::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 (Trycourier::RequestOptions, Hash{Symbol=>Object}, nil)

Returns:

See Also:



23
24
25
26
27
28
29
30
31
32
# File 'lib/trycourier/resources/users/preferences.rb', line 23

def retrieve(user_id, params = {})
  parsed, options = Trycourier::Users::PreferenceRetrieveParams.dump_request(params)
  @client.request(
    method: :get,
    path: ["users/%1$s/preferences", user_id],
    query: parsed,
    model: Trycourier::Models::Users::PreferenceRetrieveResponse,
    options: options
  )
end

#retrieve_topic(topic_id, user_id: , tenant_id: nil, request_options: {}) ⇒ Trycourier::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 (Trycourier::RequestOptions, Hash{Symbol=>Object}, nil)

Returns:

See Also:



52
53
54
55
56
57
58
59
60
61
62
63
64
65
# File 'lib/trycourier/resources/users/preferences.rb', line 52

def retrieve_topic(topic_id, params)
  parsed, options = Trycourier::Users::PreferenceRetrieveTopicParams.dump_request(params)
  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: parsed,
    model: Trycourier::Models::Users::PreferenceRetrieveTopicResponse,
    options: options
  )
end

#update_or_create_topic(topic_id, user_id: , topic: , tenant_id: nil, request_options: {}) ⇒ Trycourier::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:

Returns:

See Also:



88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
# File 'lib/trycourier/resources/users/preferences.rb', line 88

def update_or_create_topic(topic_id, params)
  parsed, options = Trycourier::Users::PreferenceUpdateOrCreateTopicParams.dump_request(params)
  user_id =
    parsed.delete(:user_id) do
      raise ArgumentError.new("missing required path argument #{_1}")
    end
  query_params = [:tenant_id]
  @client.request(
    method: :put,
    path: ["users/%1$s/preferences/%2$s", user_id, topic_id],
    query: parsed.slice(*query_params),
    body: parsed.except(*query_params),
    model: Trycourier::Models::Users::PreferenceUpdateOrCreateTopicResponse,
    options: options
  )
end