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 +4 -4
- data/src/torii/backend/client.rb +7 -13
- data/src/torii/backend/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: b1a96d9687e94f8401fc4e31419692c4bea11899887e219a639b599ac1777d3b
|
|
4
|
+
data.tar.gz: bb12c7757fefb1c2a1c5e9a2b6f189d21670f562f281b2e4e2d6dc2e04eebc1f
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 6914b54c06238dc1ab1458d684de162816c8162efc418a6b60385a5ce7f95e188be1dcbd935d2135272a3a5e920fe16b2d89ba130625be7d747c3aa2b6a37c7d
|
|
7
|
+
data.tar.gz: 547edf22a7bf9d92640d4f1fc7a11a5463ac6cc490bfa49f352336b418db41a9cf0768bd7b3ececbe0600b0ed44e76fa21c0fe0b69dfaa49e851aaa7efdd1859
|
data/src/torii/backend/client.rb
CHANGED
|
@@ -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 =
|
|
145
|
-
raise ArgumentError, "unknown PATCH field: #{field}. Valid: #{
|
|
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
|