knockapi 1.10.2 → 1.11.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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: bf2e78c4a3a157b67ee21c310416f1832ae93d7d3dca66ca5182a4073f718783
4
- data.tar.gz: d27105eb023f08041b9323215af94b5253682a6e6aaa9fb7bc80709d70eb4efb
3
+ metadata.gz: fb73648101e7d2bd451a7d998eb5ded40adcd662a9ca06e29ec4f2f1b4c479dc
4
+ data.tar.gz: 47715ed958cb260beff0d347ea7e8783a05181e1d34c4394656ba6ac50c3d33a
5
5
  SHA512:
6
- metadata.gz: 1283a238f41312d15ace45d032f1a66b0a51469d5af2e18370723133b532ae64ff837e9e24fab55e72e7f043c2aad8ee747dab6c0e8cf895d2d8155a83924266
7
- data.tar.gz: 25636a8cbf6be36f1f89f80f5735311555cefa8336a81e27d5e75a40489e7c05d30eba79ea135d06fb8dd5066b2bb8e1e61a9a0965b074553905fd04a41c8926
6
+ metadata.gz: 94968e7c435833897b9d5c574f1f2f81556c937661eeaf1f6854802379fddc9bf4e4f70ebb3096fdc84656361b29e70540956ae6c30d355fdd533102c777f559
7
+ data.tar.gz: 708aaf055317502fea383da4f0e3350ac35bd08eb07734beffabf71439d46666c67b334eaa5d83afc75f79c83bae241aa949b8d8e8f086257406828f4e352cfa
data/CHANGELOG.md CHANGED
@@ -1,5 +1,31 @@
1
1
  # Changelog
2
2
 
3
+ ## 1.11.0 (2025-08-15)
4
+
5
+ Full Changelog: [v1.10.3...v1.11.0](https://github.com/knocklabs/knock-ruby/compare/v1.10.3...v1.11.0)
6
+
7
+ ### Features
8
+
9
+ * **api:** api update ([d0ce3fe](https://github.com/knocklabs/knock-ruby/commit/d0ce3fe4004f9f5b663d88f6eea02c1def7a26fa))
10
+
11
+ ## 1.10.3 (2025-08-12)
12
+
13
+ Full Changelog: [v1.10.2...v1.10.3](https://github.com/knocklabs/knock-ruby/compare/v1.10.2...v1.10.3)
14
+
15
+ ### Bug Fixes
16
+
17
+ * **internal:** ensure sorbet test always runs serially ([66f6791](https://github.com/knocklabs/knock-ruby/commit/66f67914b8f2c811e98c1a7806fd361463614271))
18
+
19
+
20
+ ### Chores
21
+
22
+ * collect metadata from type DSL ([7221a47](https://github.com/knocklabs/knock-ruby/commit/7221a470e5604d56b1e1a91b3504f3400a8e62d2))
23
+ * **internal:** codegen related update ([83d9236](https://github.com/knocklabs/knock-ruby/commit/83d9236dedfc1d4dae46e0b1abed22206461df80))
24
+ * **internal:** increase visibility of internal helper method ([18a3bc1](https://github.com/knocklabs/knock-ruby/commit/18a3bc1e07170a0c0e2595ac17c8a0e74a4855ff))
25
+ * **internal:** update comment in script ([c0a5fc6](https://github.com/knocklabs/knock-ruby/commit/c0a5fc6a4760bb057e222e490700e702f54480fe))
26
+ * update @stainless-api/prism-cli to v5.15.0 ([f92c3e6](https://github.com/knocklabs/knock-ruby/commit/f92c3e6157c76770e840c6c8363bd57565e3e465))
27
+ * update contribute.md ([3ff1a87](https://github.com/knocklabs/knock-ruby/commit/3ff1a87c6bb8111da0f6127d38cc19c2fa5d54fa))
28
+
3
29
  ## 1.10.2 (2025-07-21)
4
30
 
5
31
  Full Changelog: [v1.10.1...v1.10.2](https://github.com/knocklabs/knock-ruby/compare/v1.10.1...v1.10.2)
data/README.md CHANGED
@@ -17,7 +17,7 @@ To use this gem, install via Bundler by adding the following to your application
17
17
  <!-- x-release-please-start-version -->
18
18
 
19
19
  ```ruby
20
- gem "knockapi", "~> 1.10.2"
20
+ gem "knockapi", "~> 1.11.0"
21
21
  ```
22
22
 
23
23
  <!-- x-release-please-end -->
@@ -225,25 +225,25 @@ knock.workflows.trigger("dinosaurs-loose", **params)
225
225
  Since this library does not depend on `sorbet-runtime`, it cannot provide [`T::Enum`](https://sorbet.org/docs/tenum) instances. Instead, we provide "tagged symbols" instead, which is always a primitive at runtime:
226
226
 
227
227
  ```ruby
228
- # :exclude
229
- puts(Knockapi::Users::FeedListItemsParams::Archived::EXCLUDE)
228
+ # :merge
229
+ puts(Knockapi::Recipients::PreferenceSetRequest::PersistenceStrategy::MERGE)
230
230
 
231
- # Revealed type: `T.all(Knockapi::Users::FeedListItemsParams::Archived, Symbol)`
232
- T.reveal_type(Knockapi::Users::FeedListItemsParams::Archived::EXCLUDE)
231
+ # Revealed type: `T.all(Knockapi::Recipients::PreferenceSetRequest::PersistenceStrategy, Symbol)`
232
+ T.reveal_type(Knockapi::Recipients::PreferenceSetRequest::PersistenceStrategy::MERGE)
233
233
  ```
234
234
 
235
235
  Enum parameters have a "relaxed" type, so you can either pass in enum constants or their literal value:
236
236
 
237
237
  ```ruby
238
238
  # Using the enum constants preserves the tagged type information:
239
- knock.users.feeds.list_items(
240
- archived: Knockapi::Users::FeedListItemsParams::Archived::EXCLUDE,
239
+ knock.users.set_preferences(
240
+ _persistence_strategy: Knockapi::Recipients::PreferenceSetRequest::PersistenceStrategy::MERGE,
241
241
  # …
242
242
  )
243
243
 
244
244
  # Literal values are also permissible:
245
- knock.users.feeds.list_items(
246
- archived: :exclude,
245
+ knock.users.set_preferences(
246
+ _persistence_strategy: :merge,
247
247
  # …
248
248
  )
249
249
  ```
@@ -365,7 +365,7 @@ module Knockapi
365
365
  #
366
366
  # @raise [Knockapi::Errors::APIError]
367
367
  # @return [Array(Integer, Net::HTTPResponse, Enumerable<String>)]
368
- private def send_request(request, redirect_count:, retry_count:, send_retry_header:)
368
+ def send_request(request, redirect_count:, retry_count:, send_retry_header:)
369
369
  url, headers, max_retries, timeout = request.fetch_values(:url, :headers, :max_retries, :timeout)
370
370
  input = {**request.except(:timeout), deadline: Knockapi::Internal::Util.monotonic_secs + timeout}
371
371
 
@@ -148,6 +148,7 @@ module Knockapi
148
148
  # @option spec [Boolean] :"nil?"
149
149
  def initialize(type_info, spec = {})
150
150
  @item_type_fn = Knockapi::Internal::Type::Converter.type_info(type_info || spec)
151
+ @meta = Knockapi::Internal::Type::Converter.meta_info(type_info, spec)
151
152
  @nilable = spec.fetch(:nil?, false)
152
153
  end
153
154
 
@@ -52,6 +52,7 @@ module Knockapi
52
52
  #
53
53
  # @option spec [Boolean] :"nil?"
54
54
  private def add_field(name_sym, required:, type_info:, spec:)
55
+ meta = Knockapi::Internal::Type::Converter.meta_info(type_info, spec)
55
56
  type_fn, info =
56
57
  case type_info
57
58
  in Proc | Knockapi::Internal::Type::Converter | Class
@@ -81,7 +82,8 @@ module Knockapi
81
82
  required: required,
82
83
  nilable: nilable,
83
84
  const: const,
84
- type_fn: type_fn
85
+ type_fn: type_fn,
86
+ meta: meta
85
87
  }
86
88
 
87
89
  define_method(setter) do |value|
@@ -98,6 +98,33 @@ module Knockapi
98
98
  end
99
99
  end
100
100
 
101
+ # @api private
102
+ #
103
+ # @param type_info [Hash{Symbol=>Object}, Proc, Knockapi::Internal::Type::Converter, Class] .
104
+ #
105
+ # @option type_info [NilClass, TrueClass, FalseClass, Integer, Float, Symbol] :const
106
+ #
107
+ # @option type_info [Proc] :enum
108
+ #
109
+ # @option type_info [Proc] :union
110
+ #
111
+ # @option type_info [Boolean] :"nil?"
112
+ #
113
+ # @param spec [Hash{Symbol=>Object}, Proc, Knockapi::Internal::Type::Converter, Class] .
114
+ #
115
+ # @option spec [NilClass, TrueClass, FalseClass, Integer, Float, Symbol] :const
116
+ #
117
+ # @option spec [Proc] :enum
118
+ #
119
+ # @option spec [Proc] :union
120
+ #
121
+ # @option spec [Boolean] :"nil?"
122
+ #
123
+ # @return [Hash{Symbol=>Object}]
124
+ def meta_info(type_info, spec)
125
+ [spec, type_info].grep(Hash).first.to_h.except(:const, :enum, :union, :nil?)
126
+ end
127
+
101
128
  # @api private
102
129
  #
103
130
  # @param translate_names [Boolean]
@@ -168,6 +168,7 @@ module Knockapi
168
168
  # @option spec [Boolean] :"nil?"
169
169
  def initialize(type_info, spec = {})
170
170
  @item_type_fn = Knockapi::Internal::Type::Converter.type_info(type_info || spec)
171
+ @meta = Knockapi::Internal::Type::Converter.meta_info(type_info, spec)
171
172
  @nilable = spec.fetch(:nil?, false)
172
173
  end
173
174
 
@@ -23,20 +23,20 @@ module Knockapi
23
23
  #
24
24
  # All of the specified variant info for this union.
25
25
  #
26
- # @return [Array<Array(Symbol, Proc)>]
26
+ # @return [Array<Array(Symbol, Proc, Hash{Symbol=>Object})>]
27
27
  private def known_variants = (@known_variants ||= [])
28
28
 
29
29
  # @api private
30
30
  #
31
- # @return [Array<Array(Symbol, Object)>]
31
+ # @return [Array<Array(Symbol, Object, Hash{Symbol=>Object})>]
32
32
  protected def derefed_variants
33
- known_variants.map { |key, variant_fn| [key, variant_fn.call] }
33
+ known_variants.map { |key, variant_fn, meta| [key, variant_fn.call, meta] }
34
34
  end
35
35
 
36
36
  # All of the specified variants for this union.
37
37
  #
38
38
  # @return [Array<Object>]
39
- def variants = derefed_variants.map(&:last)
39
+ def variants = derefed_variants.map { _2 }
40
40
 
41
41
  # @api private
42
42
  #
@@ -62,12 +62,13 @@ module Knockapi
62
62
  #
63
63
  # @option spec [Boolean] :"nil?"
64
64
  private def variant(key, spec = nil)
65
+ meta = Knockapi::Internal::Type::Converter.meta_info(nil, spec)
65
66
  variant_info =
66
67
  case key
67
68
  in Symbol
68
- [key, Knockapi::Internal::Type::Converter.type_info(spec)]
69
+ [key, Knockapi::Internal::Type::Converter.type_info(spec), meta]
69
70
  in Proc | Knockapi::Internal::Type::Converter | Class | Hash
70
- [nil, Knockapi::Internal::Type::Converter.type_info(key)]
71
+ [nil, Knockapi::Internal::Type::Converter.type_info(key), meta]
71
72
  end
72
73
 
73
74
  known_variants << variant_info
@@ -90,7 +91,8 @@ module Knockapi
90
91
  return nil if key == Knockapi::Internal::OMIT
91
92
 
92
93
  key = key.to_sym if key.is_a?(String)
93
- known_variants.find { |k,| k == key }&.last&.call
94
+ _, found = known_variants.find { |k,| k == key }
95
+ found&.call
94
96
  else
95
97
  nil
96
98
  end
@@ -4,6 +4,15 @@ module Knockapi
4
4
  module Models
5
5
  module Recipients
6
6
  class PreferenceSetRequest < Knockapi::Internal::Type::BaseModel
7
+ # @!attribute _persistence_strategy
8
+ # Controls how the preference set is persisted. 'replace' will completely replace
9
+ # the preference set, 'merge' will merge with existing preferences.
10
+ #
11
+ # @return [Symbol, Knockapi::Models::Recipients::PreferenceSetRequest::PersistenceStrategy, nil]
12
+ optional :_persistence_strategy,
13
+ enum: -> { Knockapi::Recipients::PreferenceSetRequest::PersistenceStrategy },
14
+ api_name: :__persistence_strategy__
15
+
7
16
  # @!attribute categories
8
17
  # An object where the key is the category and the values are the preference
9
18
  # settings for that category.
@@ -32,18 +41,34 @@ module Knockapi
32
41
  },
33
42
  nil?: true
34
43
 
35
- # @!method initialize(categories: nil, channel_types: nil, workflows: nil)
44
+ # @!method initialize(_persistence_strategy: nil, categories: nil, channel_types: nil, workflows: nil)
36
45
  # Some parameter documentations has been truncated, see
37
46
  # {Knockapi::Models::Recipients::PreferenceSetRequest} for more details.
38
47
  #
39
48
  # A request to set a preference set for a recipient.
40
49
  #
50
+ # @param _persistence_strategy [Symbol, Knockapi::Models::Recipients::PreferenceSetRequest::PersistenceStrategy] Controls how the preference set is persisted. 'replace' will completely replace
51
+ #
41
52
  # @param categories [Hash{Symbol=>Boolean, Knockapi::Models::Recipients::PreferenceSetRequest::Category::PreferenceSetWorkflowCategorySettingObject}, nil] An object where the key is the category and the values are the preference settin
42
53
  #
43
54
  # @param channel_types [Knockapi::Models::Recipients::PreferenceSetChannelTypes, nil] Channel type preferences.
44
55
  #
45
56
  # @param workflows [Hash{Symbol=>Boolean, Knockapi::Models::Recipients::PreferenceSetRequest::Workflow::PreferenceSetWorkflowCategorySettingObject}, nil] An object where the key is the workflow key and the values are the preference se
46
57
 
58
+ # Controls how the preference set is persisted. 'replace' will completely replace
59
+ # the preference set, 'merge' will merge with existing preferences.
60
+ #
61
+ # @see Knockapi::Models::Recipients::PreferenceSetRequest#_persistence_strategy
62
+ module PersistenceStrategy
63
+ extend Knockapi::Internal::Type::Enum
64
+
65
+ MERGE = :merge
66
+ REPLACE = :replace
67
+
68
+ # @!method self.values
69
+ # @return [Array<Symbol>]
70
+ end
71
+
47
72
  # Workflow or category preferences within a preference set
48
73
  module Category
49
74
  extend Knockapi::Internal::Type::Union
@@ -425,14 +425,16 @@ module Knockapi
425
425
  # Some parameter documentations has been truncated, see
426
426
  # {Knockapi::Models::ObjectSetPreferencesParams} for more details.
427
427
  #
428
- # Sets preferences within the given preference set. This is a destructive
429
- # operation and will replace any existing preferences with the preferences given.
430
- # If no object exists in the current environment for the given `:collection` and
431
- # `:object_id`, Knock will create the object as part of this request. The
432
- # preference set `:id` can be either `default` or a `tenant.id`. Learn more about
428
+ # Sets preferences within the given preference set. By default, this is a
429
+ # destructive operation and will replace any existing preferences with the
430
+ # preferences given. Use '\_\_persistence_strategy': 'merge' to merge with
431
+ # existing preferences instead. If no object exists in the current environment for
432
+ # the given `:collection` and `:object_id`, Knock will create the object as part
433
+ # of this request. The preference set `:id` can be either `default` or a
434
+ # `tenant.id`. Learn more about
433
435
  # [per-tenant preferences](/preferences/tenant-preferences).
434
436
  #
435
- # @overload set_preferences(collection, object_id_, id, categories: nil, channel_types: nil, workflows: nil, request_options: {})
437
+ # @overload set_preferences(collection, object_id_, id, _persistence_strategy: nil, categories: nil, channel_types: nil, workflows: nil, request_options: {})
436
438
  #
437
439
  # @param collection [String] The collection this object belongs to.
438
440
  #
@@ -440,6 +442,8 @@ module Knockapi
440
442
  #
441
443
  # @param id [String] Unique identifier for the preference set.
442
444
  #
445
+ # @param _persistence_strategy [Symbol, Knockapi::Models::Recipients::PreferenceSetRequest::PersistenceStrategy] Controls how the preference set is persisted. 'replace' will completely replace
446
+ #
443
447
  # @param categories [Hash{Symbol=>Boolean, Knockapi::Models::Recipients::PreferenceSetRequest::Category::PreferenceSetWorkflowCategorySettingObject}, nil] An object where the key is the category and the values are the preference settin
444
448
  #
445
449
  # @param channel_types [Knockapi::Models::Recipients::PreferenceSetChannelTypes, nil] Channel type preferences.
@@ -375,15 +375,19 @@ module Knockapi
375
375
  # Some parameter documentations has been truncated, see
376
376
  # {Knockapi::Models::UserSetPreferencesParams} for more details.
377
377
  #
378
- # Updates a complete preference set for a user. This is a destructive operation
379
- # that will replace the existing preference set for the user.
378
+ # Updates a complete preference set for a user. By default, this is a destructive
379
+ # operation and will replace any existing preferences with the preferences given.
380
+ # Use '**persistence_strategy**': 'merge' to merge with existing preferences
381
+ # instead.
380
382
  #
381
- # @overload set_preferences(user_id, id, categories: nil, channel_types: nil, workflows: nil, request_options: {})
383
+ # @overload set_preferences(user_id, id, _persistence_strategy: nil, categories: nil, channel_types: nil, workflows: nil, request_options: {})
382
384
  #
383
385
  # @param user_id [String] The unique identifier of the user.
384
386
  #
385
387
  # @param id [String] Unique identifier for the preference set.
386
388
  #
389
+ # @param _persistence_strategy [Symbol, Knockapi::Models::Recipients::PreferenceSetRequest::PersistenceStrategy] Controls how the preference set is persisted. 'replace' will completely replace
390
+ #
387
391
  # @param categories [Hash{Symbol=>Boolean, Knockapi::Models::Recipients::PreferenceSetRequest::Category::PreferenceSetWorkflowCategorySettingObject}, nil] An object where the key is the category and the values are the preference settin
388
392
  #
389
393
  # @param channel_types [Knockapi::Models::Recipients::PreferenceSetChannelTypes, nil] Channel type preferences.
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Knockapi
4
- VERSION = "1.10.2"
4
+ VERSION = "1.11.0"
5
5
  end
@@ -213,7 +213,7 @@ module Knockapi
213
213
  send_retry_header: T::Boolean
214
214
  ).returns([Integer, Net::HTTPResponse, T::Enumerable[String]])
215
215
  end
216
- private def send_request(
216
+ def send_request(
217
217
  request,
218
218
  redirect_count:,
219
219
  retry_count:,
@@ -90,6 +90,60 @@ module Knockapi
90
90
  def self.type_info(spec)
91
91
  end
92
92
 
93
+ # @api private
94
+ sig do
95
+ params(
96
+ type_info:
97
+ T.any(
98
+ {
99
+ const:
100
+ T.nilable(
101
+ T.any(NilClass, T::Boolean, Integer, Float, Symbol)
102
+ ),
103
+ enum:
104
+ T.nilable(
105
+ T.proc.returns(
106
+ Knockapi::Internal::Type::Converter::Input
107
+ )
108
+ ),
109
+ union:
110
+ T.nilable(
111
+ T.proc.returns(
112
+ Knockapi::Internal::Type::Converter::Input
113
+ )
114
+ )
115
+ },
116
+ T.proc.returns(Knockapi::Internal::Type::Converter::Input),
117
+ Knockapi::Internal::Type::Converter::Input
118
+ ),
119
+ spec:
120
+ T.any(
121
+ {
122
+ const:
123
+ T.nilable(
124
+ T.any(NilClass, T::Boolean, Integer, Float, Symbol)
125
+ ),
126
+ enum:
127
+ T.nilable(
128
+ T.proc.returns(
129
+ Knockapi::Internal::Type::Converter::Input
130
+ )
131
+ ),
132
+ union:
133
+ T.nilable(
134
+ T.proc.returns(
135
+ Knockapi::Internal::Type::Converter::Input
136
+ )
137
+ )
138
+ },
139
+ T.proc.returns(Knockapi::Internal::Type::Converter::Input),
140
+ Knockapi::Internal::Type::Converter::Input
141
+ )
142
+ ).returns(Knockapi::Internal::AnyHash)
143
+ end
144
+ def self.meta_info(type_info, spec)
145
+ end
146
+
93
147
  # @api private
94
148
  sig do
95
149
  params(translate_names: T::Boolean).returns(
@@ -16,7 +16,8 @@ module Knockapi
16
16
  T::Array[
17
17
  [
18
18
  T.nilable(Symbol),
19
- T.proc.returns(Knockapi::Internal::Type::Converter::Input)
19
+ T.proc.returns(Knockapi::Internal::Type::Converter::Input),
20
+ Knockapi::Internal::AnyHash
20
21
  ]
21
22
  ]
22
23
  )
@@ -25,7 +26,13 @@ module Knockapi
25
26
  end
26
27
 
27
28
  # @api private
28
- sig { returns(T::Array[[T.nilable(Symbol), T.anything]]) }
29
+ sig do
30
+ returns(
31
+ T::Array[
32
+ [T.nilable(Symbol), T.anything, Knockapi::Internal::AnyHash]
33
+ ]
34
+ )
35
+ end
29
36
  protected def derefed_variants
30
37
  end
31
38
 
@@ -12,6 +12,25 @@ module Knockapi
12
12
  )
13
13
  end
14
14
 
15
+ # Controls how the preference set is persisted. 'replace' will completely replace
16
+ # the preference set, 'merge' will merge with existing preferences.
17
+ sig do
18
+ returns(
19
+ T.nilable(
20
+ Knockapi::Recipients::PreferenceSetRequest::PersistenceStrategy::OrSymbol
21
+ )
22
+ )
23
+ end
24
+ attr_reader :_persistence_strategy
25
+
26
+ sig do
27
+ params(
28
+ _persistence_strategy:
29
+ Knockapi::Recipients::PreferenceSetRequest::PersistenceStrategy::OrSymbol
30
+ ).void
31
+ end
32
+ attr_writer :_persistence_strategy
33
+
15
34
  # An object where the key is the category and the values are the preference
16
35
  # settings for that category.
17
36
  sig do
@@ -63,6 +82,8 @@ module Knockapi
63
82
  # A request to set a preference set for a recipient.
64
83
  sig do
65
84
  params(
85
+ _persistence_strategy:
86
+ Knockapi::Recipients::PreferenceSetRequest::PersistenceStrategy::OrSymbol,
66
87
  categories:
67
88
  T.nilable(
68
89
  T::Hash[
@@ -90,6 +111,9 @@ module Knockapi
90
111
  ).returns(T.attached_class)
91
112
  end
92
113
  def self.new(
114
+ # Controls how the preference set is persisted. 'replace' will completely replace
115
+ # the preference set, 'merge' will merge with existing preferences.
116
+ _persistence_strategy: nil,
93
117
  # An object where the key is the category and the values are the preference
94
118
  # settings for that category.
95
119
  categories: nil,
@@ -104,6 +128,8 @@ module Knockapi
104
128
  sig do
105
129
  override.returns(
106
130
  {
131
+ _persistence_strategy:
132
+ Knockapi::Recipients::PreferenceSetRequest::PersistenceStrategy::OrSymbol,
107
133
  categories:
108
134
  T.nilable(
109
135
  T::Hash[
@@ -132,6 +158,42 @@ module Knockapi
132
158
  def to_hash
133
159
  end
134
160
 
161
+ # Controls how the preference set is persisted. 'replace' will completely replace
162
+ # the preference set, 'merge' will merge with existing preferences.
163
+ module PersistenceStrategy
164
+ extend Knockapi::Internal::Type::Enum
165
+
166
+ TaggedSymbol =
167
+ T.type_alias do
168
+ T.all(
169
+ Symbol,
170
+ Knockapi::Recipients::PreferenceSetRequest::PersistenceStrategy
171
+ )
172
+ end
173
+ OrSymbol = T.type_alias { T.any(Symbol, String) }
174
+
175
+ MERGE =
176
+ T.let(
177
+ :merge,
178
+ Knockapi::Recipients::PreferenceSetRequest::PersistenceStrategy::TaggedSymbol
179
+ )
180
+ REPLACE =
181
+ T.let(
182
+ :replace,
183
+ Knockapi::Recipients::PreferenceSetRequest::PersistenceStrategy::TaggedSymbol
184
+ )
185
+
186
+ sig do
187
+ override.returns(
188
+ T::Array[
189
+ Knockapi::Recipients::PreferenceSetRequest::PersistenceStrategy::TaggedSymbol
190
+ ]
191
+ )
192
+ end
193
+ def self.values
194
+ end
195
+ end
196
+
135
197
  # Workflow or category preferences within a preference set
136
198
  module Category
137
199
  extend Knockapi::Internal::Type::Union
@@ -422,17 +422,21 @@ module Knockapi
422
422
  )
423
423
  end
424
424
 
425
- # Sets preferences within the given preference set. This is a destructive
426
- # operation and will replace any existing preferences with the preferences given.
427
- # If no object exists in the current environment for the given `:collection` and
428
- # `:object_id`, Knock will create the object as part of this request. The
429
- # preference set `:id` can be either `default` or a `tenant.id`. Learn more about
425
+ # Sets preferences within the given preference set. By default, this is a
426
+ # destructive operation and will replace any existing preferences with the
427
+ # preferences given. Use '\_\_persistence_strategy': 'merge' to merge with
428
+ # existing preferences instead. If no object exists in the current environment for
429
+ # the given `:collection` and `:object_id`, Knock will create the object as part
430
+ # of this request. The preference set `:id` can be either `default` or a
431
+ # `tenant.id`. Learn more about
430
432
  # [per-tenant preferences](/preferences/tenant-preferences).
431
433
  sig do
432
434
  params(
433
435
  collection: String,
434
436
  object_id_: String,
435
437
  id: String,
438
+ _persistence_strategy:
439
+ Knockapi::Recipients::PreferenceSetRequest::PersistenceStrategy::OrSymbol,
436
440
  categories:
437
441
  T.nilable(
438
442
  T::Hash[
@@ -465,6 +469,9 @@ module Knockapi
465
469
  object_id_,
466
470
  # Unique identifier for the preference set.
467
471
  id,
472
+ # Controls how the preference set is persisted. 'replace' will completely replace
473
+ # the preference set, 'merge' will merge with existing preferences.
474
+ _persistence_strategy: nil,
468
475
  # An object where the key is the category and the values are the preference
469
476
  # settings for that category.
470
477
  categories: nil,
@@ -362,12 +362,16 @@ module Knockapi
362
362
  )
363
363
  end
364
364
 
365
- # Updates a complete preference set for a user. This is a destructive operation
366
- # that will replace the existing preference set for the user.
365
+ # Updates a complete preference set for a user. By default, this is a destructive
366
+ # operation and will replace any existing preferences with the preferences given.
367
+ # Use '**persistence_strategy**': 'merge' to merge with existing preferences
368
+ # instead.
367
369
  sig do
368
370
  params(
369
371
  user_id: String,
370
372
  id: String,
373
+ _persistence_strategy:
374
+ Knockapi::Recipients::PreferenceSetRequest::PersistenceStrategy::OrSymbol,
371
375
  categories:
372
376
  T.nilable(
373
377
  T::Hash[
@@ -398,6 +402,9 @@ module Knockapi
398
402
  user_id,
399
403
  # Unique identifier for the preference set.
400
404
  id,
405
+ # Controls how the preference set is persisted. 'replace' will completely replace
406
+ # the preference set, 'merge' will merge with existing preferences.
407
+ _persistence_strategy: nil,
401
408
  # An object where the key is the category and the values are the preference
402
409
  # settings for that category.
403
410
  categories: nil,
@@ -99,7 +99,7 @@ module Knockapi
99
99
  retry_count: Integer
100
100
  ) -> Float
101
101
 
102
- private def send_request: (
102
+ def send_request: (
103
103
  Knockapi::Internal::Transport::BaseClient::request_input request,
104
104
  redirect_count: Integer,
105
105
  retry_count: Integer,
@@ -39,6 +39,23 @@ module Knockapi
39
39
  | Knockapi::Internal::Type::Converter::input spec
40
40
  ) -> (^-> top)
41
41
 
42
+ def self.meta_info: (
43
+ {
44
+ const: (nil | bool | Integer | Float | Symbol)?,
45
+ enum: ^-> Knockapi::Internal::Type::Converter::input?,
46
+ union: ^-> Knockapi::Internal::Type::Converter::input?
47
+ }
48
+ | ^-> Knockapi::Internal::Type::Converter::input
49
+ | Knockapi::Internal::Type::Converter::input type_info,
50
+ {
51
+ const: (nil | bool | Integer | Float | Symbol)?,
52
+ enum: ^-> Knockapi::Internal::Type::Converter::input?,
53
+ union: ^-> Knockapi::Internal::Type::Converter::input?
54
+ }
55
+ | ^-> Knockapi::Internal::Type::Converter::input
56
+ | Knockapi::Internal::Type::Converter::input spec
57
+ ) -> ::Hash[Symbol, top]
58
+
42
59
  def self.new_coerce_state: (
43
60
  ?translate_names: bool
44
61
  ) -> Knockapi::Internal::Type::Converter::coerce_state
@@ -5,9 +5,9 @@ module Knockapi
5
5
  include Knockapi::Internal::Type::Converter
6
6
  include Knockapi::Internal::Util::SorbetRuntimeSupport
7
7
 
8
- private def self.known_variants: -> ::Array[[Symbol?, (^-> Knockapi::Internal::Type::Converter::input)]]
8
+ private def self.known_variants: -> ::Array[[Symbol?, (^-> Knockapi::Internal::Type::Converter::input), ::Hash[Symbol, top]]]
9
9
 
10
- def self.derefed_variants: -> ::Array[[Symbol?, top]]
10
+ def self.derefed_variants: -> ::Array[[Symbol?, top, ::Hash[Symbol, top]]]
11
11
 
12
12
  def self.variants: -> ::Array[top]
13
13
 
@@ -3,12 +3,19 @@ module Knockapi
3
3
  module Recipients
4
4
  type preference_set_request =
5
5
  {
6
+ _persistence_strategy: Knockapi::Models::Recipients::PreferenceSetRequest::persistence_strategy,
6
7
  categories: ::Hash[Symbol, Knockapi::Models::Recipients::PreferenceSetRequest::category]?,
7
8
  channel_types: Knockapi::Recipients::PreferenceSetChannelTypes?,
8
9
  workflows: ::Hash[Symbol, Knockapi::Models::Recipients::PreferenceSetRequest::workflow]?
9
10
  }
10
11
 
11
12
  class PreferenceSetRequest < Knockapi::Internal::Type::BaseModel
13
+ attr_reader _persistence_strategy: Knockapi::Models::Recipients::PreferenceSetRequest::persistence_strategy?
14
+
15
+ def _persistence_strategy=: (
16
+ Knockapi::Models::Recipients::PreferenceSetRequest::persistence_strategy
17
+ ) -> Knockapi::Models::Recipients::PreferenceSetRequest::persistence_strategy
18
+
12
19
  attr_accessor categories: ::Hash[Symbol, Knockapi::Models::Recipients::PreferenceSetRequest::category]?
13
20
 
14
21
  attr_accessor channel_types: Knockapi::Recipients::PreferenceSetChannelTypes?
@@ -16,17 +23,30 @@ module Knockapi
16
23
  attr_accessor workflows: ::Hash[Symbol, Knockapi::Models::Recipients::PreferenceSetRequest::workflow]?
17
24
 
18
25
  def initialize: (
26
+ ?_persistence_strategy: Knockapi::Models::Recipients::PreferenceSetRequest::persistence_strategy,
19
27
  ?categories: ::Hash[Symbol, Knockapi::Models::Recipients::PreferenceSetRequest::category]?,
20
28
  ?channel_types: Knockapi::Recipients::PreferenceSetChannelTypes?,
21
29
  ?workflows: ::Hash[Symbol, Knockapi::Models::Recipients::PreferenceSetRequest::workflow]?
22
30
  ) -> void
23
31
 
24
32
  def to_hash: -> {
33
+ _persistence_strategy: Knockapi::Models::Recipients::PreferenceSetRequest::persistence_strategy,
25
34
  categories: ::Hash[Symbol, Knockapi::Models::Recipients::PreferenceSetRequest::category]?,
26
35
  channel_types: Knockapi::Recipients::PreferenceSetChannelTypes?,
27
36
  workflows: ::Hash[Symbol, Knockapi::Models::Recipients::PreferenceSetRequest::workflow]?
28
37
  }
29
38
 
39
+ type persistence_strategy = :merge | :replace
40
+
41
+ module PersistenceStrategy
42
+ extend Knockapi::Internal::Type::Enum
43
+
44
+ MERGE: :merge
45
+ REPLACE: :replace
46
+
47
+ def self?.values: -> ::Array[Knockapi::Models::Recipients::PreferenceSetRequest::persistence_strategy]
48
+ end
49
+
30
50
  type category =
31
51
  bool
32
52
  | Knockapi::Recipients::PreferenceSetRequest::Category::PreferenceSetWorkflowCategorySettingObject
@@ -125,6 +125,7 @@ module Knockapi
125
125
  String collection,
126
126
  String object_id_,
127
127
  String id,
128
+ ?_persistence_strategy: Knockapi::Models::Recipients::PreferenceSetRequest::persistence_strategy,
128
129
  ?categories: ::Hash[Symbol, Knockapi::Models::Recipients::PreferenceSetRequest::category]?,
129
130
  ?channel_types: Knockapi::Recipients::PreferenceSetChannelTypes?,
130
131
  ?workflows: ::Hash[Symbol, Knockapi::Models::Recipients::PreferenceSetRequest::workflow]?,
@@ -112,6 +112,7 @@ module Knockapi
112
112
  def set_preferences: (
113
113
  String user_id,
114
114
  String id,
115
+ ?_persistence_strategy: Knockapi::Models::Recipients::PreferenceSetRequest::persistence_strategy,
115
116
  ?categories: ::Hash[Symbol, Knockapi::Models::Recipients::PreferenceSetRequest::category]?,
116
117
  ?channel_types: Knockapi::Recipients::PreferenceSetChannelTypes?,
117
118
  ?workflows: ::Hash[Symbol, Knockapi::Models::Recipients::PreferenceSetRequest::workflow]?,
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: knockapi
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.10.2
4
+ version: 1.11.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Knock
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2025-07-21 00:00:00.000000000 Z
11
+ date: 2025-08-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: connection_pool