internetdata 2.6.3 → 2.6.4
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/lib/internetdata/transport.rb +45 -2
- data/lib/internetdata/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: afd47ed11a5c7584109ee4cd24d9a80355735d93ab75f34b2e259d00c7bf5a1c
|
|
4
|
+
data.tar.gz: b1e54653b61eecfc115d38f31479419189ceef73892117c392340c07edfd7b7d
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 2103eda9f58619d97eea99a26cba2eabdb00f766a4a2baaa2b71c17f1bffb5bc10f34ea322e5614010d8e8a65d27afb7b9371d2cbe4249187363aabb225e7581
|
|
7
|
+
data.tar.gz: e2997411f2e09d36b335c0c55ad1a2e8a9df52e1b413ad686502c712536d587cd16f50b391b07d7500602e0bfd90733a4148c69109cc6cb5a5798139125ac417
|
|
@@ -90,11 +90,17 @@ module InternetData
|
|
|
90
90
|
# the spec requires. The generated reader raised a RuntimeError, a
|
|
91
91
|
# JSON::ParserError or an ArgumentError for those, none of them retried, and
|
|
92
92
|
# handed an empty or non-object body back as nil, as if it were the answer.
|
|
93
|
+
#
|
|
94
|
+
# Every member present is checked against the type the spec gives it before
|
|
95
|
+
# the answer is handed back: the generated reader converts with `to_i` and
|
|
96
|
+
# `to_s`, so `"version":"x"` came back as version 0 and `"version":"3"` as 3,
|
|
97
|
+
# as if either were the answer (2.6.3, measured 2026-10-16).
|
|
93
98
|
def deserialize(response, return_type)
|
|
94
99
|
data = super
|
|
95
|
-
|
|
100
|
+
raise Error.new(:server_error, "the API answered with no #{return_type}", status: response.code) if data.nil?
|
|
96
101
|
|
|
97
|
-
|
|
102
|
+
check_type!(JSON.parse(response.body, symbolize_names: true), return_type.to_s, 'the answer') if return_type
|
|
103
|
+
data
|
|
98
104
|
rescue Error
|
|
99
105
|
raise
|
|
100
106
|
rescue StandardError => e
|
|
@@ -189,5 +195,42 @@ module InternetData
|
|
|
189
195
|
end
|
|
190
196
|
|
|
191
197
|
private_class_method :transport_failure?, :parse_object, :oauth_refusal
|
|
198
|
+
|
|
199
|
+
private
|
|
200
|
+
|
|
201
|
+
# True when `value` has the generated `type`, a model's members recursively;
|
|
202
|
+
# raises TypeError naming where it does not. A null is left to the models'
|
|
203
|
+
# own required-member checks.
|
|
204
|
+
def check_type!(value, type, where)
|
|
205
|
+
return true if value.nil?
|
|
206
|
+
|
|
207
|
+
typed =
|
|
208
|
+
case type
|
|
209
|
+
when 'String', 'Date', 'Time' then value.is_a?(String)
|
|
210
|
+
when 'Integer' then value.is_a?(Integer)
|
|
211
|
+
when 'Float' then value.is_a?(Numeric)
|
|
212
|
+
when 'Boolean' then [true, false].include?(value)
|
|
213
|
+
when 'Object' then true
|
|
214
|
+
when /\AArray<(?<inner>.+)>\z/
|
|
215
|
+
inner = Regexp.last_match(:inner)
|
|
216
|
+
value.is_a?(Array) && value.each_with_index.all? { |v, i| check_type!(v, inner, "#{where}[#{i}]") }
|
|
217
|
+
when /\AHash<String, ?(?<inner>.+)>\z/
|
|
218
|
+
inner = Regexp.last_match(:inner)
|
|
219
|
+
value.is_a?(Hash) && value.all? { |k, v| check_type!(v, inner, "#{where}.#{k}") }
|
|
220
|
+
else
|
|
221
|
+
model = InternetData.const_get(type)
|
|
222
|
+
if model.respond_to?(:openapi_types)
|
|
223
|
+
value.is_a?(Hash) && model.openapi_types.all? do |attr, member|
|
|
224
|
+
key = model.attribute_map[attr]
|
|
225
|
+
check_type!(value[key], member.to_s, "#{where}.#{key}")
|
|
226
|
+
end
|
|
227
|
+
else
|
|
228
|
+
value.is_a?(String) # an enum
|
|
229
|
+
end
|
|
230
|
+
end
|
|
231
|
+
return true if typed
|
|
232
|
+
|
|
233
|
+
raise TypeError, "#{where} is not a #{type}"
|
|
234
|
+
end
|
|
192
235
|
end
|
|
193
236
|
end
|
data/lib/internetdata/version.rb
CHANGED