trycourier 4.18.2 → 4.19.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (56) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +9 -0
  3. data/lib/courier/models/publish_preferences_request.rb +40 -0
  4. data/lib/courier/models/users/bulk_preference_topic.rb +59 -0
  5. data/lib/courier/models/users/preference_bulk_replace_params.rb +93 -0
  6. data/lib/courier/models/users/preference_bulk_replace_response.rb +27 -0
  7. data/lib/courier/models/users/preference_bulk_update_params.rb +92 -0
  8. data/lib/courier/models/users/preference_bulk_update_response.rb +48 -0
  9. data/lib/courier/models/workspace_preference_create_request.rb +9 -1
  10. data/lib/courier/models/workspace_preference_get_response.rb +9 -1
  11. data/lib/courier/models/workspace_preference_publish_params.rb +1 -1
  12. data/lib/courier/models/workspace_preference_replace_request.rb +13 -1
  13. data/lib/courier/models/workspace_preference_topic_create_request.rb +9 -1
  14. data/lib/courier/models/workspace_preference_topic_get_response.rb +9 -1
  15. data/lib/courier/models/workspace_preference_topic_replace_request.rb +13 -1
  16. data/lib/courier/models.rb +2 -0
  17. data/lib/courier/resources/users/preferences.rb +96 -0
  18. data/lib/courier/resources/workspace_preferences/topics.rb +6 -2
  19. data/lib/courier/resources/workspace_preferences.rb +22 -4
  20. data/lib/courier/version.rb +1 -1
  21. data/lib/courier.rb +6 -0
  22. data/rbi/courier/models/publish_preferences_request.rbi +58 -0
  23. data/rbi/courier/models/users/bulk_preference_topic.rbi +99 -0
  24. data/rbi/courier/models/users/preference_bulk_replace_params.rbi +188 -0
  25. data/rbi/courier/models/users/preference_bulk_replace_response.rbi +50 -0
  26. data/rbi/courier/models/users/preference_bulk_update_params.rbi +186 -0
  27. data/rbi/courier/models/users/preference_bulk_update_response.rbi +94 -0
  28. data/rbi/courier/models/workspace_preference_create_request.rbi +8 -0
  29. data/rbi/courier/models/workspace_preference_get_response.rbi +8 -0
  30. data/rbi/courier/models/workspace_preference_publish_params.rbi +1 -1
  31. data/rbi/courier/models/workspace_preference_replace_request.rbi +10 -0
  32. data/rbi/courier/models/workspace_preference_topic_create_request.rbi +8 -0
  33. data/rbi/courier/models/workspace_preference_topic_get_response.rbi +8 -0
  34. data/rbi/courier/models/workspace_preference_topic_replace_request.rbi +10 -0
  35. data/rbi/courier/models.rbi +2 -0
  36. data/rbi/courier/resources/users/preferences.rbi +83 -0
  37. data/rbi/courier/resources/workspace_preferences/topics.rbi +7 -0
  38. data/rbi/courier/resources/workspace_preferences.rbi +23 -4
  39. data/sig/courier/models/publish_preferences_request.rbs +26 -0
  40. data/sig/courier/models/users/bulk_preference_topic.rbs +48 -0
  41. data/sig/courier/models/users/preference_bulk_replace_params.rbs +87 -0
  42. data/sig/courier/models/users/preference_bulk_replace_response.rbs +27 -0
  43. data/sig/courier/models/users/preference_bulk_update_params.rbs +87 -0
  44. data/sig/courier/models/users/preference_bulk_update_response.rbs +39 -0
  45. data/sig/courier/models/workspace_preference_create_request.rbs +5 -0
  46. data/sig/courier/models/workspace_preference_get_response.rbs +5 -0
  47. data/sig/courier/models/workspace_preference_publish_params.rbs +1 -1
  48. data/sig/courier/models/workspace_preference_replace_request.rbs +5 -0
  49. data/sig/courier/models/workspace_preference_topic_create_request.rbs +5 -0
  50. data/sig/courier/models/workspace_preference_topic_get_response.rbs +5 -0
  51. data/sig/courier/models/workspace_preference_topic_replace_request.rbs +5 -0
  52. data/sig/courier/models.rbs +2 -0
  53. data/sig/courier/resources/users/preferences.rbs +14 -0
  54. data/sig/courier/resources/workspace_preferences/topics.rbs +2 -0
  55. data/sig/courier/resources/workspace_preferences.rbs +5 -0
  56. metadata +19 -1
@@ -32,6 +32,102 @@ module Courier
32
32
  )
33
33
  end
34
34
 
35
+ # Some parameter documentations has been truncated, see
36
+ # {Courier::Models::Users::PreferenceBulkReplaceParams} for more details.
37
+ #
38
+ # Replace a user's complete set of preference overrides in a single request. The
39
+ # topics in the request body become the recipient's entire set of overrides:
40
+ # listed topics are created or updated, and every existing override that is not
41
+ # included in the body is reset to its topic default. Submitting an empty `topics`
42
+ # array is a valid clear-all that resets every existing override.
43
+ #
44
+ # This operation is validation-atomic (all-or-nothing): structural validation
45
+ # fails fast with a single `400`, and if any topic is semantically invalid (an
46
+ # unknown topic, a `REQUIRED` topic that cannot be opted out, or a custom routing
47
+ # request that is not available on the workspace's plan) the request returns a
48
+ # single `400` aggregating every failure in `errors` and writes nothing. On
49
+ # success it returns `200` with `items` (the complete resulting override set) and
50
+ # `deleted` (the ids of the overrides that were reset to default).
51
+ #
52
+ # Every `topic_id` in the response — in `items`, `deleted`, and any `errors` — is
53
+ # returned in Courier's canonical topic id form, regardless of the form supplied
54
+ # in the request.
55
+ #
56
+ # @overload bulk_replace(user_id, topics:, tenant_id: nil, request_options: {})
57
+ #
58
+ # @param user_id [String] Path param: A unique identifier associated with the user whose preferences you w
59
+ #
60
+ # @param topics [Array<Courier::Models::Users::PreferenceBulkReplaceParams::Topic>] Body param: The complete set of topic overrides for the user. Up to 50 topics ma
61
+ #
62
+ # @param tenant_id [String, nil] Query param: Update the preferences of a user for this specific tenant context.
63
+ #
64
+ # @param request_options [Courier::RequestOptions, Hash{Symbol=>Object}, nil]
65
+ #
66
+ # @return [Courier::Models::Users::PreferenceBulkReplaceResponse]
67
+ #
68
+ # @see Courier::Models::Users::PreferenceBulkReplaceParams
69
+ def bulk_replace(user_id, params)
70
+ query_params = [:tenant_id]
71
+ parsed, options = Courier::Users::PreferenceBulkReplaceParams.dump_request(params)
72
+ query = Courier::Internal::Util.encode_query_params(parsed.slice(*query_params))
73
+ @client.request(
74
+ method: :put,
75
+ path: ["users/%1$s/preferences", user_id],
76
+ query: query,
77
+ body: parsed.except(*query_params),
78
+ model: Courier::Models::Users::PreferenceBulkReplaceResponse,
79
+ options: options
80
+ )
81
+ end
82
+
83
+ # Some parameter documentations has been truncated, see
84
+ # {Courier::Models::Users::PreferenceBulkUpdateParams} for more details.
85
+ #
86
+ # Additively create or update a user's preferences for one or more subscription
87
+ # topics in a single request. Only the topics included in the request body are
88
+ # created or updated; any existing overrides for topics not listed are left
89
+ # untouched.
90
+ #
91
+ # Structural validation of the request body fails fast with a single `400`. Beyond
92
+ # that, each topic is processed independently (partial-success, not
93
+ # all-or-nothing): valid topics are written and returned in `items`, while topics
94
+ # that cannot be applied are collected in `errors` with a per-topic `reason` (for
95
+ # example an unknown topic, a `REQUIRED` topic that cannot be opted out, a custom
96
+ # routing request that is not available on the workspace's plan, or a write
97
+ # failure). The request therefore returns `200` with both lists whenever the body
98
+ # is structurally valid.
99
+ #
100
+ # Every `topic_id` in the response — in both `items` and `errors` — is returned in
101
+ # Courier's canonical topic id form, regardless of the form supplied in the
102
+ # request.
103
+ #
104
+ # @overload bulk_update(user_id, topics:, tenant_id: nil, request_options: {})
105
+ #
106
+ # @param user_id [String] Path param: A unique identifier associated with the user whose preferences you w
107
+ #
108
+ # @param topics [Array<Courier::Models::Users::PreferenceBulkUpdateParams::Topic>] Body param: The topics to create or update. Between 1 and 50 topics may be provi
109
+ #
110
+ # @param tenant_id [String, nil] Query param: Update the preferences of a user for this specific tenant context.
111
+ #
112
+ # @param request_options [Courier::RequestOptions, Hash{Symbol=>Object}, nil]
113
+ #
114
+ # @return [Courier::Models::Users::PreferenceBulkUpdateResponse]
115
+ #
116
+ # @see Courier::Models::Users::PreferenceBulkUpdateParams
117
+ def bulk_update(user_id, params)
118
+ query_params = [:tenant_id]
119
+ parsed, options = Courier::Users::PreferenceBulkUpdateParams.dump_request(params)
120
+ query = Courier::Internal::Util.encode_query_params(parsed.slice(*query_params))
121
+ @client.request(
122
+ method: :post,
123
+ path: ["users/%1$s/preferences", user_id],
124
+ query: query,
125
+ body: parsed.except(*query_params),
126
+ model: Courier::Models::Users::PreferenceBulkUpdateResponse,
127
+ options: options
128
+ )
129
+ end
130
+
35
131
  # Some parameter documentations has been truncated, see
36
132
  # {Courier::Models::Users::PreferenceDeleteTopicParams} for more details.
37
133
  #
@@ -11,7 +11,7 @@ module Courier
11
11
  # 404 if the workspace preference does not exist. The topic id is generated and
12
12
  # returned.
13
13
  #
14
- # @overload create(section_id, default_status:, name:, allowed_preferences: nil, include_unsubscribe_header: nil, routing_options: nil, topic_data: nil, request_options: {})
14
+ # @overload create(section_id, default_status:, name:, allowed_preferences: nil, description: nil, include_unsubscribe_header: nil, routing_options: nil, topic_data: nil, request_options: {})
15
15
  #
16
16
  # @param section_id [String] Id of the workspace preference to create the topic in.
17
17
  #
@@ -21,6 +21,8 @@ module Courier
21
21
  #
22
22
  # @param allowed_preferences [Array<Symbol, Courier::Models::WorkspacePreferenceTopicCreateRequest::AllowedPreference>, nil] Preference controls a recipient may customize for this topic. Defaults to empty
23
23
  #
24
+ # @param description [String, nil] Optional description shown under the topic on the hosted preferences page.
25
+ #
24
26
  # @param include_unsubscribe_header [Boolean, nil] Whether to include a list-unsubscribe header on emails for this topic.
25
27
  #
26
28
  # @param routing_options [Array<Symbol, Courier::Models::ChannelClassification>, nil] Default channels delivered for this topic. Defaults to empty if omitted.
@@ -126,7 +128,7 @@ module Courier
126
128
  # Replace a topic within a workspace preference. Full document replacement;
127
129
  # missing optional fields are cleared. Same 404 rules as GET.
128
130
  #
129
- # @overload replace(topic_id, section_id:, default_status:, name:, allowed_preferences: nil, include_unsubscribe_header: nil, routing_options: nil, topic_data: nil, request_options: {})
131
+ # @overload replace(topic_id, section_id:, default_status:, name:, allowed_preferences: nil, description: nil, include_unsubscribe_header: nil, routing_options: nil, topic_data: nil, request_options: {})
130
132
  #
131
133
  # @param topic_id [String] Path param: Id of the subscription preference topic.
132
134
  #
@@ -138,6 +140,8 @@ module Courier
138
140
  #
139
141
  # @param allowed_preferences [Array<Symbol, Courier::Models::WorkspacePreferenceTopicReplaceRequest::AllowedPreference>, nil] Body param: Preference controls a recipient may customize. Omit to clear.
140
142
  #
143
+ # @param description [String, nil] Body param: Optional description shown under the topic on the hosted preferences
144
+ #
141
145
  # @param include_unsubscribe_header [Boolean, nil] Body param: Whether to include a list-unsubscribe header on emails for this topi
142
146
  #
143
147
  # @param routing_options [Array<Symbol, Courier::Models::ChannelClassification>, nil] Body param: Default channels delivered for this topic. Omit to clear.
@@ -10,10 +10,12 @@ module Courier
10
10
  # returned. Topics are created inside a workspace preference via POST
11
11
  # /preferences/sections/{section_id}/topics.
12
12
  #
13
- # @overload create(name:, has_custom_routing: nil, routing_options: nil, request_options: {})
13
+ # @overload create(name:, description: nil, has_custom_routing: nil, routing_options: nil, request_options: {})
14
14
  #
15
15
  # @param name [String] Human-readable name for the workspace preference.
16
16
  #
17
+ # @param description [String, nil] Optional description shown under the section on the hosted preferences page.
18
+ #
17
19
  # @param has_custom_routing [Boolean, nil] Whether the workspace preference defines custom routing for its topics.
18
20
  #
19
21
  # @param routing_options [Array<Symbol, Courier::Models::ChannelClassification>, nil] Default channels for the workspace preference. Defaults to empty if omitted.
@@ -94,11 +96,20 @@ module Courier
94
96
  )
95
97
  end
96
98
 
99
+ # Some parameter documentations has been truncated, see
100
+ # {Courier::Models::WorkspacePreferencePublishParams} for more details.
101
+ #
97
102
  # Publish the workspace's preferences page. Takes a snapshot of every workspace
98
103
  # preference with its topics under a new published version, making the current
99
104
  # state visible on the hosted preferences page (non-draft).
100
105
  #
101
- # @overload publish(request_options: {})
106
+ # @overload publish(brand_id: nil, description: nil, heading: nil, request_options: {})
107
+ #
108
+ # @param brand_id [String, nil] Brand for the hosted page - "default" (workspace default brand), "none" (no bran
109
+ #
110
+ # @param description [String, nil] Description shown under the heading on the hosted preferences page.
111
+ #
112
+ # @param heading [String, nil] Heading shown at the top of the hosted preferences page.
102
113
  #
103
114
  # @param request_options [Courier::RequestOptions, Hash{Symbol=>Object}, nil]
104
115
  #
@@ -106,23 +117,30 @@ module Courier
106
117
  #
107
118
  # @see Courier::Models::WorkspacePreferencePublishParams
108
119
  def publish(params = {})
120
+ parsed, options = Courier::WorkspacePreferencePublishParams.dump_request(params)
109
121
  @client.request(
110
122
  method: :post,
111
123
  path: "preferences/publish",
124
+ body: parsed,
112
125
  model: Courier::PublishPreferencesResponse,
113
- options: params[:request_options]
126
+ options: options
114
127
  )
115
128
  end
116
129
 
130
+ # Some parameter documentations has been truncated, see
131
+ # {Courier::Models::WorkspacePreferenceReplaceParams} for more details.
132
+ #
117
133
  # Replace a workspace preference. Full document replacement; missing optional
118
134
  # fields are cleared. Topics attached to the workspace preference are unaffected.
119
135
  #
120
- # @overload replace(section_id, name:, has_custom_routing: nil, routing_options: nil, request_options: {})
136
+ # @overload replace(section_id, name:, description: nil, has_custom_routing: nil, routing_options: nil, request_options: {})
121
137
  #
122
138
  # @param section_id [String] Id of the workspace preference.
123
139
  #
124
140
  # @param name [String] Human-readable name for the workspace preference.
125
141
  #
142
+ # @param description [String, nil] Optional description shown under the section on the hosted preferences page. Omi
143
+ #
126
144
  # @param has_custom_routing [Boolean, nil] Whether the workspace preference defines custom routing for its topics.
127
145
  #
128
146
  # @param routing_options [Array<Symbol, Courier::Models::ChannelClassification>, nil] Default channels for the workspace preference. Omit to clear.
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Courier
4
- VERSION = "4.18.2"
4
+ VERSION = "4.19.0"
5
5
  end
data/lib/courier.rb CHANGED
@@ -80,6 +80,7 @@ require_relative "courier/models/post_tenant_template_publish_request"
80
80
  require_relative "courier/models/put_tenant_template_request"
81
81
  require_relative "courier/models/users/user_token"
82
82
  require_relative "courier/models/workspace_preference_create_request"
83
+ require_relative "courier/models/publish_preferences_request"
83
84
  require_relative "courier/models/workspace_preference_replace_request"
84
85
  require_relative "courier/models/workspace_preference_topic_create_request"
85
86
  require_relative "courier/models/workspace_preference_topic_replace_request"
@@ -371,6 +372,11 @@ require_relative "courier/models/translation_update_params"
371
372
  require_relative "courier/models/user_profile"
372
373
  require_relative "courier/models/user_profile_firebase_token"
373
374
  require_relative "courier/models/user_recipient"
375
+ require_relative "courier/models/users/bulk_preference_topic"
376
+ require_relative "courier/models/users/preference_bulk_replace_params"
377
+ require_relative "courier/models/users/preference_bulk_replace_response"
378
+ require_relative "courier/models/users/preference_bulk_update_params"
379
+ require_relative "courier/models/users/preference_bulk_update_response"
374
380
  require_relative "courier/models/users/preference_delete_topic_params"
375
381
  require_relative "courier/models/users/preference_retrieve_params"
376
382
  require_relative "courier/models/users/preference_retrieve_response"
@@ -0,0 +1,58 @@
1
+ # typed: strong
2
+
3
+ module Courier
4
+ module Models
5
+ class PublishPreferencesRequest < Courier::Internal::Type::BaseModel
6
+ OrHash =
7
+ T.type_alias do
8
+ T.any(Courier::PublishPreferencesRequest, Courier::Internal::AnyHash)
9
+ end
10
+
11
+ # Brand for the hosted page - "default" (workspace default brand), "none" (no
12
+ # brand), or a specific brand id. Defaults to "default".
13
+ sig { returns(T.nilable(String)) }
14
+ attr_accessor :brand_id
15
+
16
+ # Description shown under the heading on the hosted preferences page.
17
+ sig { returns(T.nilable(String)) }
18
+ attr_accessor :description
19
+
20
+ # Heading shown at the top of the hosted preferences page.
21
+ sig { returns(T.nilable(String)) }
22
+ attr_accessor :heading
23
+
24
+ # Optional page metadata to apply when publishing the workspace's preferences
25
+ # page. All fields are optional; omitted fields fall back to the page defaults
26
+ # (and the workspace default brand).
27
+ sig do
28
+ params(
29
+ brand_id: T.nilable(String),
30
+ description: T.nilable(String),
31
+ heading: T.nilable(String)
32
+ ).returns(T.attached_class)
33
+ end
34
+ def self.new(
35
+ # Brand for the hosted page - "default" (workspace default brand), "none" (no
36
+ # brand), or a specific brand id. Defaults to "default".
37
+ brand_id: nil,
38
+ # Description shown under the heading on the hosted preferences page.
39
+ description: nil,
40
+ # Heading shown at the top of the hosted preferences page.
41
+ heading: nil
42
+ )
43
+ end
44
+
45
+ sig do
46
+ override.returns(
47
+ {
48
+ brand_id: T.nilable(String),
49
+ description: T.nilable(String),
50
+ heading: T.nilable(String)
51
+ }
52
+ )
53
+ end
54
+ def to_hash
55
+ end
56
+ end
57
+ end
58
+ end
@@ -0,0 +1,99 @@
1
+ # typed: strong
2
+
3
+ module Courier
4
+ module Models
5
+ module Users
6
+ class BulkPreferenceTopic < Courier::Internal::Type::BaseModel
7
+ OrHash =
8
+ T.type_alias do
9
+ T.any(
10
+ Courier::Users::BulkPreferenceTopic,
11
+ Courier::Internal::AnyHash
12
+ )
13
+ end
14
+
15
+ sig { returns(T::Array[Courier::ChannelClassification::TaggedSymbol]) }
16
+ attr_accessor :custom_routing
17
+
18
+ sig { returns(T::Boolean) }
19
+ attr_accessor :has_custom_routing
20
+
21
+ # The applied subscription status. Echoes the requested value, so it is always
22
+ # OPTED_IN or OPTED_OUT.
23
+ sig do
24
+ returns(Courier::Users::BulkPreferenceTopic::Status::TaggedSymbol)
25
+ end
26
+ attr_accessor :status
27
+
28
+ sig { returns(String) }
29
+ attr_accessor :topic_id
30
+
31
+ # A single topic override echoed in a bulk preference response.
32
+ sig do
33
+ params(
34
+ custom_routing: T::Array[Courier::ChannelClassification::OrSymbol],
35
+ has_custom_routing: T::Boolean,
36
+ status: Courier::Users::BulkPreferenceTopic::Status::OrSymbol,
37
+ topic_id: String
38
+ ).returns(T.attached_class)
39
+ end
40
+ def self.new(
41
+ custom_routing:,
42
+ has_custom_routing:,
43
+ # The applied subscription status. Echoes the requested value, so it is always
44
+ # OPTED_IN or OPTED_OUT.
45
+ status:,
46
+ topic_id:
47
+ )
48
+ end
49
+
50
+ sig do
51
+ override.returns(
52
+ {
53
+ custom_routing:
54
+ T::Array[Courier::ChannelClassification::TaggedSymbol],
55
+ has_custom_routing: T::Boolean,
56
+ status: Courier::Users::BulkPreferenceTopic::Status::TaggedSymbol,
57
+ topic_id: String
58
+ }
59
+ )
60
+ end
61
+ def to_hash
62
+ end
63
+
64
+ # The applied subscription status. Echoes the requested value, so it is always
65
+ # OPTED_IN or OPTED_OUT.
66
+ module Status
67
+ extend Courier::Internal::Type::Enum
68
+
69
+ TaggedSymbol =
70
+ T.type_alias do
71
+ T.all(Symbol, Courier::Users::BulkPreferenceTopic::Status)
72
+ end
73
+ OrSymbol = T.type_alias { T.any(Symbol, String) }
74
+
75
+ OPTED_IN =
76
+ T.let(
77
+ :OPTED_IN,
78
+ Courier::Users::BulkPreferenceTopic::Status::TaggedSymbol
79
+ )
80
+ OPTED_OUT =
81
+ T.let(
82
+ :OPTED_OUT,
83
+ Courier::Users::BulkPreferenceTopic::Status::TaggedSymbol
84
+ )
85
+
86
+ sig do
87
+ override.returns(
88
+ T::Array[
89
+ Courier::Users::BulkPreferenceTopic::Status::TaggedSymbol
90
+ ]
91
+ )
92
+ end
93
+ def self.values
94
+ end
95
+ end
96
+ end
97
+ end
98
+ end
99
+ end
@@ -0,0 +1,188 @@
1
+ # typed: strong
2
+
3
+ module Courier
4
+ module Models
5
+ module Users
6
+ class PreferenceBulkReplaceParams < Courier::Internal::Type::BaseModel
7
+ extend Courier::Internal::Type::RequestParameters::Converter
8
+ include Courier::Internal::Type::RequestParameters
9
+
10
+ OrHash =
11
+ T.type_alias do
12
+ T.any(
13
+ Courier::Users::PreferenceBulkReplaceParams,
14
+ Courier::Internal::AnyHash
15
+ )
16
+ end
17
+
18
+ sig { returns(String) }
19
+ attr_accessor :user_id
20
+
21
+ # The complete set of topic overrides for the user. Up to 50 topics may be
22
+ # provided. Any existing override not listed here is reset to its topic default;
23
+ # an empty array resets every existing override.
24
+ sig do
25
+ returns(T::Array[Courier::Users::PreferenceBulkReplaceParams::Topic])
26
+ end
27
+ attr_accessor :topics
28
+
29
+ # Update the preferences of a user for this specific tenant context.
30
+ sig { returns(T.nilable(String)) }
31
+ attr_accessor :tenant_id
32
+
33
+ sig do
34
+ params(
35
+ user_id: String,
36
+ topics:
37
+ T::Array[
38
+ Courier::Users::PreferenceBulkReplaceParams::Topic::OrHash
39
+ ],
40
+ tenant_id: T.nilable(String),
41
+ request_options: Courier::RequestOptions::OrHash
42
+ ).returns(T.attached_class)
43
+ end
44
+ def self.new(
45
+ user_id:,
46
+ # The complete set of topic overrides for the user. Up to 50 topics may be
47
+ # provided. Any existing override not listed here is reset to its topic default;
48
+ # an empty array resets every existing override.
49
+ topics:,
50
+ # Update the preferences of a user for this specific tenant context.
51
+ tenant_id: nil,
52
+ request_options: {}
53
+ )
54
+ end
55
+
56
+ sig do
57
+ override.returns(
58
+ {
59
+ user_id: String,
60
+ topics:
61
+ T::Array[Courier::Users::PreferenceBulkReplaceParams::Topic],
62
+ tenant_id: T.nilable(String),
63
+ request_options: Courier::RequestOptions
64
+ }
65
+ )
66
+ end
67
+ def to_hash
68
+ end
69
+
70
+ class Topic < Courier::Internal::Type::BaseModel
71
+ OrHash =
72
+ T.type_alias do
73
+ T.any(
74
+ Courier::Users::PreferenceBulkReplaceParams::Topic,
75
+ Courier::Internal::AnyHash
76
+ )
77
+ end
78
+
79
+ # The subscription status to apply for this topic.
80
+ sig do
81
+ returns(
82
+ Courier::Users::PreferenceBulkReplaceParams::Topic::Status::OrSymbol
83
+ )
84
+ end
85
+ attr_accessor :status
86
+
87
+ # A unique identifier associated with a subscription topic.
88
+ sig { returns(String) }
89
+ attr_accessor :topic_id
90
+
91
+ # The channels a user has chosen to receive notifications through for this topic.
92
+ sig do
93
+ returns(
94
+ T.nilable(T::Array[Courier::ChannelClassification::OrSymbol])
95
+ )
96
+ end
97
+ attr_reader :custom_routing
98
+
99
+ sig do
100
+ params(
101
+ custom_routing: T::Array[Courier::ChannelClassification::OrSymbol]
102
+ ).void
103
+ end
104
+ attr_writer :custom_routing
105
+
106
+ # Whether the recipient has chosen specific delivery channels for this topic.
107
+ sig { returns(T.nilable(T::Boolean)) }
108
+ attr_reader :has_custom_routing
109
+
110
+ sig { params(has_custom_routing: T::Boolean).void }
111
+ attr_writer :has_custom_routing
112
+
113
+ sig do
114
+ params(
115
+ status:
116
+ Courier::Users::PreferenceBulkReplaceParams::Topic::Status::OrSymbol,
117
+ topic_id: String,
118
+ custom_routing:
119
+ T::Array[Courier::ChannelClassification::OrSymbol],
120
+ has_custom_routing: T::Boolean
121
+ ).returns(T.attached_class)
122
+ end
123
+ def self.new(
124
+ # The subscription status to apply for this topic.
125
+ status:,
126
+ # A unique identifier associated with a subscription topic.
127
+ topic_id:,
128
+ # The channels a user has chosen to receive notifications through for this topic.
129
+ custom_routing: nil,
130
+ # Whether the recipient has chosen specific delivery channels for this topic.
131
+ has_custom_routing: nil
132
+ )
133
+ end
134
+
135
+ sig do
136
+ override.returns(
137
+ {
138
+ status:
139
+ Courier::Users::PreferenceBulkReplaceParams::Topic::Status::OrSymbol,
140
+ topic_id: String,
141
+ custom_routing:
142
+ T::Array[Courier::ChannelClassification::OrSymbol],
143
+ has_custom_routing: T::Boolean
144
+ }
145
+ )
146
+ end
147
+ def to_hash
148
+ end
149
+
150
+ # The subscription status to apply for this topic.
151
+ module Status
152
+ extend Courier::Internal::Type::Enum
153
+
154
+ TaggedSymbol =
155
+ T.type_alias do
156
+ T.all(
157
+ Symbol,
158
+ Courier::Users::PreferenceBulkReplaceParams::Topic::Status
159
+ )
160
+ end
161
+ OrSymbol = T.type_alias { T.any(Symbol, String) }
162
+
163
+ OPTED_IN =
164
+ T.let(
165
+ :OPTED_IN,
166
+ Courier::Users::PreferenceBulkReplaceParams::Topic::Status::TaggedSymbol
167
+ )
168
+ OPTED_OUT =
169
+ T.let(
170
+ :OPTED_OUT,
171
+ Courier::Users::PreferenceBulkReplaceParams::Topic::Status::TaggedSymbol
172
+ )
173
+
174
+ sig do
175
+ override.returns(
176
+ T::Array[
177
+ Courier::Users::PreferenceBulkReplaceParams::Topic::Status::TaggedSymbol
178
+ ]
179
+ )
180
+ end
181
+ def self.values
182
+ end
183
+ end
184
+ end
185
+ end
186
+ end
187
+ end
188
+ end
@@ -0,0 +1,50 @@
1
+ # typed: strong
2
+
3
+ module Courier
4
+ module Models
5
+ module Users
6
+ class PreferenceBulkReplaceResponse < Courier::Internal::Type::BaseModel
7
+ OrHash =
8
+ T.type_alias do
9
+ T.any(
10
+ Courier::Models::Users::PreferenceBulkReplaceResponse,
11
+ Courier::Internal::AnyHash
12
+ )
13
+ end
14
+
15
+ # The ids of the overrides that were reset to their topic default.
16
+ sig { returns(T::Array[String]) }
17
+ attr_accessor :deleted
18
+
19
+ # The complete resulting set of topic overrides for the user.
20
+ sig { returns(T::Array[Courier::Users::BulkPreferenceTopic]) }
21
+ attr_accessor :items
22
+
23
+ sig do
24
+ params(
25
+ deleted: T::Array[String],
26
+ items: T::Array[Courier::Users::BulkPreferenceTopic::OrHash]
27
+ ).returns(T.attached_class)
28
+ end
29
+ def self.new(
30
+ # The ids of the overrides that were reset to their topic default.
31
+ deleted:,
32
+ # The complete resulting set of topic overrides for the user.
33
+ items:
34
+ )
35
+ end
36
+
37
+ sig do
38
+ override.returns(
39
+ {
40
+ deleted: T::Array[String],
41
+ items: T::Array[Courier::Users::BulkPreferenceTopic]
42
+ }
43
+ )
44
+ end
45
+ def to_hash
46
+ end
47
+ end
48
+ end
49
+ end
50
+ end