torii-backend 0.0.5 → 0.0.7

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: 9c6886647e9ed2eb2df0e52390b83826d095808d1cb244d2396176c734a3c842
4
- data.tar.gz: 3eaac288e8d61d3916177c8aa563c6502b74e1f68240dd8bfcb6af4d9ec77aeb
3
+ metadata.gz: b1a96d9687e94f8401fc4e31419692c4bea11899887e219a639b599ac1777d3b
4
+ data.tar.gz: bb12c7757fefb1c2a1c5e9a2b6f189d21670f562f281b2e4e2d6dc2e04eebc1f
5
5
  SHA512:
6
- metadata.gz: 3122cc87ba1fcce90315b8a0520af4203b97556551dc97ffacee3fc002cece54177f08bea88e5b8bf280d7efb179f0978b41f43f68ae8924276f6976550b60bd
7
- data.tar.gz: 9d68a174436b04dccb613fd9080ead4c48f24249bb8853fdbbef43ce0fe4f82ad98de1bbcf0d5b800ffd4ca38d5b4d81a383bee72deb95054414cb66ccfb37b4
6
+ metadata.gz: 6914b54c06238dc1ab1458d684de162816c8162efc418a6b60385a5ce7f95e188be1dcbd935d2135272a3a5e920fe16b2d89ba130625be7d747c3aa2b6a37c7d
7
+ data.tar.gz: 547edf22a7bf9d92640d4f1fc7a11a5463ac6cc490bfa49f352336b418db41a9cf0768bd7b3ececbe0600b0ed44e76fa21c0fe0b69dfaa49e851aaa7efdd1859
@@ -136,17 +136,21 @@ module Torii
136
136
  # JSON keys the server expects (camelCase).
137
137
  def update(user_id, **patches)
138
138
  body = {}
139
+ # Source the snake_case -> camelCase mapping from the generated model's
140
+ # attribute_map, so a new patchable field flows through with zero hand
141
+ # edits (an unknown field still raises).
142
+ attribute_map = ToriiBackendGenerated::UpdateUserRequest.attribute_map
139
143
  patches.each do |field, patch|
140
144
  unless patch.is_a?(Patch)
141
145
  raise ArgumentError, "kwarg #{field} must be a Torii::Backend::Patch (got #{patch.class})"
142
146
  end
143
147
 
144
- json_key = PATCH_FIELD_MAP.fetch(field) do
145
- raise ArgumentError, "unknown PATCH field: #{field}. Valid: #{PATCH_FIELD_MAP.keys.inspect}"
148
+ json_key = attribute_map.fetch(field) do
149
+ raise ArgumentError, "unknown PATCH field: #{field}. Valid: #{attribute_map.keys.inspect}"
146
150
  end
147
151
 
148
152
  # Patch.set(value) emits the key; nil value → JSON null (clear).
149
- body[json_key] = patch.value
153
+ body[json_key.to_s] = patch.value
150
154
  end
151
155
 
152
156
  # +debug_body+ on the generated client is the escape hatch for
@@ -163,16 +167,6 @@ module Torii
163
167
  model_to_hash(result)
164
168
  end
165
169
 
166
- # Map of Ruby snake_case kwargs to the JSON keys the server
167
- # expects on the PATCH body. Centralised so +update+ can validate
168
- # field names with a single +fetch+.
169
- PATCH_FIELD_MAP = {
170
- first_name: 'firstName',
171
- last_name: 'lastName',
172
- locale: 'locale',
173
- unsafe_metadata: 'unsafeMetadata',
174
- }.freeze
175
-
176
170
  def delete(user_id)
177
171
  @api.delete_user(user_id)
178
172
  nil
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Torii
4
4
  module Backend
5
- VERSION = '0.0.5'
5
+ VERSION = '0.0.7'
6
6
  end
7
7
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: torii-backend
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.5
4
+ version: 0.0.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - torii