ssrfs-up 0.0.9
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/lib/openapi_client/lib/openapi_client.rb +47 -0
- data/lib/openapi_client/lib/openapi_client/api/default_api.rb +85 -0
- data/lib/openapi_client/lib/openapi_client/api_client.rb +389 -0
- data/lib/openapi_client/lib/openapi_client/api_error.rb +57 -0
- data/lib/openapi_client/lib/openapi_client/configuration.rb +270 -0
- data/lib/openapi_client/lib/openapi_client/models/content_type.rb +40 -0
- data/lib/openapi_client/lib/openapi_client/models/method.rb +40 -0
- data/lib/openapi_client/lib/openapi_client/models/redirect.rb +242 -0
- data/lib/openapi_client/lib/openapi_client/models/request.rb +380 -0
- data/lib/openapi_client/lib/openapi_client/models/response.rb +293 -0
- data/lib/openapi_client/lib/openapi_client/models/response_error.rb +224 -0
- data/lib/openapi_client/lib/openapi_client/models/response_success.rb +270 -0
- data/lib/openapi_client/lib/openapi_client/version.rb +15 -0
- data/lib/ssrfs-up.rb +136 -0
- metadata +117 -0
@@ -0,0 +1,380 @@
|
|
1
|
+
=begin
|
2
|
+
#SSRF Forwarder
|
3
|
+
|
4
|
+
#This is an API that forwards request on behalf of other services.
|
5
|
+
|
6
|
+
The version of the OpenAPI document: 1.0.0-oas3-oas3-oas3
|
7
|
+
Contact: jheath@chanzuckerberg.com
|
8
|
+
Generated by: https://openapi-generator.tech
|
9
|
+
OpenAPI Generator version: 5.0.1
|
10
|
+
|
11
|
+
=end
|
12
|
+
|
13
|
+
require 'date'
|
14
|
+
require 'time'
|
15
|
+
|
16
|
+
module OpenapiClient
|
17
|
+
class Request
|
18
|
+
# the destination host of the request to be made
|
19
|
+
attr_accessor :host
|
20
|
+
|
21
|
+
attr_accessor :method
|
22
|
+
|
23
|
+
# boolean to indicate if the request should be made over HTTPS or not; default is secure
|
24
|
+
attr_accessor :secure
|
25
|
+
|
26
|
+
# any custom headers that should also be forwarded with the request
|
27
|
+
attr_accessor :headers
|
28
|
+
|
29
|
+
# a timeout length in seconds for the HTTP request to return; default is 10 seconds
|
30
|
+
attr_accessor :timeout
|
31
|
+
|
32
|
+
# a JSON object whose key/value pairs will be mapped to URL query parameters
|
33
|
+
attr_accessor :_query_params
|
34
|
+
|
35
|
+
# a string representing the HTTP request or response body
|
36
|
+
attr_accessor :body
|
37
|
+
|
38
|
+
# any sensitive keys that are used in URL parameters or in the HTTP body; keys marked as sensitive will be automatically scubbed
|
39
|
+
attr_accessor :sensitive
|
40
|
+
|
41
|
+
attr_accessor :content_type
|
42
|
+
|
43
|
+
attr_accessor :redirect
|
44
|
+
|
45
|
+
# the path in the URL from the host; query parameters should not be included here
|
46
|
+
attr_accessor :path
|
47
|
+
|
48
|
+
# Attribute mapping from ruby-style variable name to JSON key.
|
49
|
+
def self.attribute_map
|
50
|
+
{
|
51
|
+
:'host' => :'host',
|
52
|
+
:'method' => :'method',
|
53
|
+
:'secure' => :'secure',
|
54
|
+
:'headers' => :'headers',
|
55
|
+
:'timeout' => :'timeout',
|
56
|
+
:'_query_params' => :'query-params',
|
57
|
+
:'body' => :'body',
|
58
|
+
:'sensitive' => :'sensitive',
|
59
|
+
:'content_type' => :'content-type',
|
60
|
+
:'redirect' => :'redirect',
|
61
|
+
:'path' => :'path'
|
62
|
+
}
|
63
|
+
end
|
64
|
+
|
65
|
+
# Returns all the JSON keys this model knows about
|
66
|
+
def self.acceptable_attributes
|
67
|
+
attribute_map.values
|
68
|
+
end
|
69
|
+
|
70
|
+
# Attribute type mapping.
|
71
|
+
def self.openapi_types
|
72
|
+
{
|
73
|
+
:'host' => :'String',
|
74
|
+
:'method' => :'Method',
|
75
|
+
:'secure' => :'Boolean',
|
76
|
+
:'headers' => :'Object',
|
77
|
+
:'timeout' => :'Integer',
|
78
|
+
:'_query_params' => :'Object',
|
79
|
+
:'body' => :'String',
|
80
|
+
:'sensitive' => :'Array<String>',
|
81
|
+
:'content_type' => :'ContentType',
|
82
|
+
:'redirect' => :'Redirect',
|
83
|
+
:'path' => :'String'
|
84
|
+
}
|
85
|
+
end
|
86
|
+
|
87
|
+
# List of attributes with nullable: true
|
88
|
+
def self.openapi_nullable
|
89
|
+
Set.new([
|
90
|
+
])
|
91
|
+
end
|
92
|
+
|
93
|
+
# Initializes the object
|
94
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
95
|
+
def initialize(attributes = {})
|
96
|
+
if (!attributes.is_a?(Hash))
|
97
|
+
fail ArgumentError, "The input argument (attributes) must be a hash in `OpenapiClient::Request` initialize method"
|
98
|
+
end
|
99
|
+
|
100
|
+
# check to see if the attribute exists and convert string to symbol for hash key
|
101
|
+
attributes = attributes.each_with_object({}) { |(k, v), h|
|
102
|
+
if (!self.class.attribute_map.key?(k.to_sym))
|
103
|
+
fail ArgumentError, "`#{k}` is not a valid attribute in `OpenapiClient::Request`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
|
104
|
+
end
|
105
|
+
h[k.to_sym] = v
|
106
|
+
}
|
107
|
+
|
108
|
+
if attributes.key?(:'host')
|
109
|
+
self.host = attributes[:'host']
|
110
|
+
end
|
111
|
+
|
112
|
+
if attributes.key?(:'method')
|
113
|
+
self.method = attributes[:'method']
|
114
|
+
else
|
115
|
+
self.method = 'GET'
|
116
|
+
end
|
117
|
+
|
118
|
+
if attributes.key?(:'secure')
|
119
|
+
self.secure = attributes[:'secure']
|
120
|
+
else
|
121
|
+
self.secure = true
|
122
|
+
end
|
123
|
+
|
124
|
+
if attributes.key?(:'headers')
|
125
|
+
self.headers = attributes[:'headers']
|
126
|
+
end
|
127
|
+
|
128
|
+
if attributes.key?(:'timeout')
|
129
|
+
self.timeout = attributes[:'timeout']
|
130
|
+
else
|
131
|
+
self.timeout = 10
|
132
|
+
end
|
133
|
+
|
134
|
+
if attributes.key?(:'_query_params')
|
135
|
+
self._query_params = attributes[:'_query_params']
|
136
|
+
end
|
137
|
+
|
138
|
+
if attributes.key?(:'body')
|
139
|
+
self.body = attributes[:'body']
|
140
|
+
else
|
141
|
+
self.body = ''
|
142
|
+
end
|
143
|
+
|
144
|
+
if attributes.key?(:'sensitive')
|
145
|
+
if (value = attributes[:'sensitive']).is_a?(Array)
|
146
|
+
self.sensitive = value
|
147
|
+
end
|
148
|
+
end
|
149
|
+
|
150
|
+
if attributes.key?(:'content_type')
|
151
|
+
self.content_type = attributes[:'content_type']
|
152
|
+
else
|
153
|
+
self.content_type = 'application/json'
|
154
|
+
end
|
155
|
+
|
156
|
+
if attributes.key?(:'redirect')
|
157
|
+
self.redirect = attributes[:'redirect']
|
158
|
+
end
|
159
|
+
|
160
|
+
if attributes.key?(:'path')
|
161
|
+
self.path = attributes[:'path']
|
162
|
+
else
|
163
|
+
self.path = '/'
|
164
|
+
end
|
165
|
+
end
|
166
|
+
|
167
|
+
# Show invalid properties with the reasons. Usually used together with valid?
|
168
|
+
# @return Array for valid properties with the reasons
|
169
|
+
def list_invalid_properties
|
170
|
+
invalid_properties = Array.new
|
171
|
+
if @host.nil?
|
172
|
+
invalid_properties.push('invalid value for "host", host cannot be nil.')
|
173
|
+
end
|
174
|
+
|
175
|
+
if @method.nil?
|
176
|
+
invalid_properties.push('invalid value for "method", method cannot be nil.')
|
177
|
+
end
|
178
|
+
|
179
|
+
if @secure.nil?
|
180
|
+
invalid_properties.push('invalid value for "secure", secure cannot be nil.')
|
181
|
+
end
|
182
|
+
|
183
|
+
if @headers.nil?
|
184
|
+
invalid_properties.push('invalid value for "headers", headers cannot be nil.')
|
185
|
+
end
|
186
|
+
|
187
|
+
if @timeout.nil?
|
188
|
+
invalid_properties.push('invalid value for "timeout", timeout cannot be nil.')
|
189
|
+
end
|
190
|
+
|
191
|
+
if @_query_params.nil?
|
192
|
+
invalid_properties.push('invalid value for "_query_params", _query_params cannot be nil.')
|
193
|
+
end
|
194
|
+
|
195
|
+
if @body.nil?
|
196
|
+
invalid_properties.push('invalid value for "body", body cannot be nil.')
|
197
|
+
end
|
198
|
+
|
199
|
+
if @sensitive.nil?
|
200
|
+
invalid_properties.push('invalid value for "sensitive", sensitive cannot be nil.')
|
201
|
+
end
|
202
|
+
|
203
|
+
if @content_type.nil?
|
204
|
+
invalid_properties.push('invalid value for "content_type", content_type cannot be nil.')
|
205
|
+
end
|
206
|
+
|
207
|
+
if @path.nil?
|
208
|
+
invalid_properties.push('invalid value for "path", path cannot be nil.')
|
209
|
+
end
|
210
|
+
|
211
|
+
invalid_properties
|
212
|
+
end
|
213
|
+
|
214
|
+
# Check to see if the all the properties in the model are valid
|
215
|
+
# @return true if the model is valid
|
216
|
+
def valid?
|
217
|
+
return false if @host.nil?
|
218
|
+
return false if @method.nil?
|
219
|
+
return false if @secure.nil?
|
220
|
+
return false if @headers.nil?
|
221
|
+
return false if @timeout.nil?
|
222
|
+
return false if @_query_params.nil?
|
223
|
+
return false if @body.nil?
|
224
|
+
return false if @sensitive.nil?
|
225
|
+
return false if @content_type.nil?
|
226
|
+
return false if @path.nil?
|
227
|
+
true
|
228
|
+
end
|
229
|
+
|
230
|
+
# Checks equality by comparing each attribute.
|
231
|
+
# @param [Object] Object to be compared
|
232
|
+
def ==(o)
|
233
|
+
return true if self.equal?(o)
|
234
|
+
self.class == o.class &&
|
235
|
+
host == o.host &&
|
236
|
+
method == o.method &&
|
237
|
+
secure == o.secure &&
|
238
|
+
headers == o.headers &&
|
239
|
+
timeout == o.timeout &&
|
240
|
+
_query_params == o._query_params &&
|
241
|
+
body == o.body &&
|
242
|
+
sensitive == o.sensitive &&
|
243
|
+
content_type == o.content_type &&
|
244
|
+
redirect == o.redirect &&
|
245
|
+
path == o.path
|
246
|
+
end
|
247
|
+
|
248
|
+
# @see the `==` method
|
249
|
+
# @param [Object] Object to be compared
|
250
|
+
def eql?(o)
|
251
|
+
self == o
|
252
|
+
end
|
253
|
+
|
254
|
+
# Calculates hash code according to all attributes.
|
255
|
+
# @return [Integer] Hash code
|
256
|
+
def hash
|
257
|
+
[host, method, secure, headers, timeout, _query_params, body, sensitive, content_type, redirect, path].hash
|
258
|
+
end
|
259
|
+
|
260
|
+
# Builds the object from hash
|
261
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
262
|
+
# @return [Object] Returns the model itself
|
263
|
+
def self.build_from_hash(attributes)
|
264
|
+
new.build_from_hash(attributes)
|
265
|
+
end
|
266
|
+
|
267
|
+
# Builds the object from hash
|
268
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
269
|
+
# @return [Object] Returns the model itself
|
270
|
+
def build_from_hash(attributes)
|
271
|
+
return nil unless attributes.is_a?(Hash)
|
272
|
+
self.class.openapi_types.each_pair do |key, type|
|
273
|
+
if attributes[self.class.attribute_map[key]].nil? && self.class.openapi_nullable.include?(key)
|
274
|
+
self.send("#{key}=", nil)
|
275
|
+
elsif type =~ /\AArray<(.*)>/i
|
276
|
+
# check to ensure the input is an array given that the attribute
|
277
|
+
# is documented as an array but the input is not
|
278
|
+
if attributes[self.class.attribute_map[key]].is_a?(Array)
|
279
|
+
self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
|
280
|
+
end
|
281
|
+
elsif !attributes[self.class.attribute_map[key]].nil?
|
282
|
+
self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
|
283
|
+
end
|
284
|
+
end
|
285
|
+
|
286
|
+
self
|
287
|
+
end
|
288
|
+
|
289
|
+
# Deserializes the data based on type
|
290
|
+
# @param string type Data type
|
291
|
+
# @param string value Value to be deserialized
|
292
|
+
# @return [Object] Deserialized data
|
293
|
+
def _deserialize(type, value)
|
294
|
+
case type.to_sym
|
295
|
+
when :Time
|
296
|
+
Time.parse(value)
|
297
|
+
when :Date
|
298
|
+
Date.parse(value)
|
299
|
+
when :String
|
300
|
+
value.to_s
|
301
|
+
when :Integer
|
302
|
+
value.to_i
|
303
|
+
when :Float
|
304
|
+
value.to_f
|
305
|
+
when :Boolean
|
306
|
+
if value.to_s =~ /\A(true|t|yes|y|1)\z/i
|
307
|
+
true
|
308
|
+
else
|
309
|
+
false
|
310
|
+
end
|
311
|
+
when :Object
|
312
|
+
# generic object (usually a Hash), return directly
|
313
|
+
value
|
314
|
+
when /\AArray<(?<inner_type>.+)>\z/
|
315
|
+
inner_type = Regexp.last_match[:inner_type]
|
316
|
+
value.map { |v| _deserialize(inner_type, v) }
|
317
|
+
when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
|
318
|
+
k_type = Regexp.last_match[:k_type]
|
319
|
+
v_type = Regexp.last_match[:v_type]
|
320
|
+
{}.tap do |hash|
|
321
|
+
value.each do |k, v|
|
322
|
+
hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
|
323
|
+
end
|
324
|
+
end
|
325
|
+
else # model
|
326
|
+
# models (e.g. Pet) or oneOf
|
327
|
+
klass = OpenapiClient.const_get(type)
|
328
|
+
klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
|
329
|
+
end
|
330
|
+
end
|
331
|
+
|
332
|
+
# Returns the string representation of the object
|
333
|
+
# @return [String] String presentation of the object
|
334
|
+
def to_s
|
335
|
+
to_hash.to_s
|
336
|
+
end
|
337
|
+
|
338
|
+
# to_body is an alias to to_hash (backward compatibility)
|
339
|
+
# @return [Hash] Returns the object in the form of hash
|
340
|
+
def to_body
|
341
|
+
to_hash
|
342
|
+
end
|
343
|
+
|
344
|
+
# Returns the object in the form of hash
|
345
|
+
# @return [Hash] Returns the object in the form of hash
|
346
|
+
def to_hash
|
347
|
+
hash = {}
|
348
|
+
self.class.attribute_map.each_pair do |attr, param|
|
349
|
+
value = self.send(attr)
|
350
|
+
if value.nil?
|
351
|
+
is_nullable = self.class.openapi_nullable.include?(attr)
|
352
|
+
next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
|
353
|
+
end
|
354
|
+
|
355
|
+
hash[param] = _to_hash(value)
|
356
|
+
end
|
357
|
+
hash
|
358
|
+
end
|
359
|
+
|
360
|
+
# Outputs non-array value in the form of hash
|
361
|
+
# For object, use to_hash. Otherwise, just return the value
|
362
|
+
# @param [Object] value Any valid value
|
363
|
+
# @return [Hash] Returns the value in the form of hash
|
364
|
+
def _to_hash(value)
|
365
|
+
if value.is_a?(Array)
|
366
|
+
value.compact.map { |v| _to_hash(v) }
|
367
|
+
elsif value.is_a?(Hash)
|
368
|
+
{}.tap do |hash|
|
369
|
+
value.each { |k, v| hash[k] = _to_hash(v) }
|
370
|
+
end
|
371
|
+
elsif value.respond_to? :to_hash
|
372
|
+
value.to_hash
|
373
|
+
else
|
374
|
+
value
|
375
|
+
end
|
376
|
+
end
|
377
|
+
|
378
|
+
end
|
379
|
+
|
380
|
+
end
|
@@ -0,0 +1,293 @@
|
|
1
|
+
=begin
|
2
|
+
#SSRF Forwarder
|
3
|
+
|
4
|
+
#This is an API that forwards request on behalf of other services.
|
5
|
+
|
6
|
+
The version of the OpenAPI document: 1.0.0-oas3-oas3-oas3
|
7
|
+
Contact: jheath@chanzuckerberg.com
|
8
|
+
Generated by: https://openapi-generator.tech
|
9
|
+
OpenAPI Generator version: 5.0.1
|
10
|
+
|
11
|
+
=end
|
12
|
+
|
13
|
+
require 'date'
|
14
|
+
require 'time'
|
15
|
+
|
16
|
+
module OpenapiClient
|
17
|
+
class Response
|
18
|
+
# the status text string from an HTTP response
|
19
|
+
attr_accessor :status_text
|
20
|
+
|
21
|
+
# the numbered status code from an HTTP response
|
22
|
+
attr_accessor :status_code
|
23
|
+
|
24
|
+
# any custom headers that should also be forwarded with the request
|
25
|
+
attr_accessor :headers
|
26
|
+
|
27
|
+
# a string representing the HTTP request or response body
|
28
|
+
attr_accessor :body
|
29
|
+
|
30
|
+
# error message
|
31
|
+
attr_accessor :error
|
32
|
+
|
33
|
+
# Attribute mapping from ruby-style variable name to JSON key.
|
34
|
+
def self.attribute_map
|
35
|
+
{
|
36
|
+
:'status_text' => :'status-text',
|
37
|
+
:'status_code' => :'status-code',
|
38
|
+
:'headers' => :'headers',
|
39
|
+
:'body' => :'body',
|
40
|
+
:'error' => :'error'
|
41
|
+
}
|
42
|
+
end
|
43
|
+
|
44
|
+
# Returns all the JSON keys this model knows about
|
45
|
+
def self.acceptable_attributes
|
46
|
+
attribute_map.values
|
47
|
+
end
|
48
|
+
|
49
|
+
# Attribute type mapping.
|
50
|
+
def self.openapi_types
|
51
|
+
{
|
52
|
+
:'status_text' => :'String',
|
53
|
+
:'status_code' => :'Integer',
|
54
|
+
:'headers' => :'Object',
|
55
|
+
:'body' => :'String',
|
56
|
+
:'error' => :'String'
|
57
|
+
}
|
58
|
+
end
|
59
|
+
|
60
|
+
# List of attributes with nullable: true
|
61
|
+
def self.openapi_nullable
|
62
|
+
Set.new([
|
63
|
+
])
|
64
|
+
end
|
65
|
+
|
66
|
+
# List of class defined in allOf (OpenAPI v3)
|
67
|
+
def self.openapi_all_of
|
68
|
+
[
|
69
|
+
:'ResponseError',
|
70
|
+
:'ResponseSuccess'
|
71
|
+
]
|
72
|
+
end
|
73
|
+
|
74
|
+
# Initializes the object
|
75
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
76
|
+
def initialize(attributes = {})
|
77
|
+
if (!attributes.is_a?(Hash))
|
78
|
+
fail ArgumentError, "The input argument (attributes) must be a hash in `OpenapiClient::Response` initialize method"
|
79
|
+
end
|
80
|
+
|
81
|
+
# check to see if the attribute exists and convert string to symbol for hash key
|
82
|
+
attributes = attributes.each_with_object({}) { |(k, v), h|
|
83
|
+
if (!self.class.attribute_map.key?(k.to_sym))
|
84
|
+
fail ArgumentError, "`#{k}` is not a valid attribute in `OpenapiClient::Response`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
|
85
|
+
end
|
86
|
+
h[k.to_sym] = v
|
87
|
+
}
|
88
|
+
|
89
|
+
if attributes.key?(:'status_text')
|
90
|
+
self.status_text = attributes[:'status_text']
|
91
|
+
else
|
92
|
+
self.status_text = ''
|
93
|
+
end
|
94
|
+
|
95
|
+
if attributes.key?(:'status_code')
|
96
|
+
self.status_code = attributes[:'status_code']
|
97
|
+
else
|
98
|
+
self.status_code = 200
|
99
|
+
end
|
100
|
+
|
101
|
+
if attributes.key?(:'headers')
|
102
|
+
self.headers = attributes[:'headers']
|
103
|
+
end
|
104
|
+
|
105
|
+
if attributes.key?(:'body')
|
106
|
+
self.body = attributes[:'body']
|
107
|
+
else
|
108
|
+
self.body = ''
|
109
|
+
end
|
110
|
+
|
111
|
+
if attributes.key?(:'error')
|
112
|
+
self.error = attributes[:'error']
|
113
|
+
end
|
114
|
+
end
|
115
|
+
|
116
|
+
# Show invalid properties with the reasons. Usually used together with valid?
|
117
|
+
# @return Array for valid properties with the reasons
|
118
|
+
def list_invalid_properties
|
119
|
+
invalid_properties = Array.new
|
120
|
+
if @status_code.nil?
|
121
|
+
invalid_properties.push('invalid value for "status_code", status_code cannot be nil.')
|
122
|
+
end
|
123
|
+
|
124
|
+
if @headers.nil?
|
125
|
+
invalid_properties.push('invalid value for "headers", headers cannot be nil.')
|
126
|
+
end
|
127
|
+
|
128
|
+
if @body.nil?
|
129
|
+
invalid_properties.push('invalid value for "body", body cannot be nil.')
|
130
|
+
end
|
131
|
+
|
132
|
+
if @error.nil?
|
133
|
+
invalid_properties.push('invalid value for "error", error cannot be nil.')
|
134
|
+
end
|
135
|
+
|
136
|
+
invalid_properties
|
137
|
+
end
|
138
|
+
|
139
|
+
# Check to see if the all the properties in the model are valid
|
140
|
+
# @return true if the model is valid
|
141
|
+
def valid?
|
142
|
+
return false if @status_code.nil?
|
143
|
+
return false if @headers.nil?
|
144
|
+
return false if @body.nil?
|
145
|
+
return false if @error.nil?
|
146
|
+
true
|
147
|
+
end
|
148
|
+
|
149
|
+
# Checks equality by comparing each attribute.
|
150
|
+
# @param [Object] Object to be compared
|
151
|
+
def ==(o)
|
152
|
+
return true if self.equal?(o)
|
153
|
+
self.class == o.class &&
|
154
|
+
status_text == o.status_text &&
|
155
|
+
status_code == o.status_code &&
|
156
|
+
headers == o.headers &&
|
157
|
+
body == o.body &&
|
158
|
+
error == o.error
|
159
|
+
end
|
160
|
+
|
161
|
+
# @see the `==` method
|
162
|
+
# @param [Object] Object to be compared
|
163
|
+
def eql?(o)
|
164
|
+
self == o
|
165
|
+
end
|
166
|
+
|
167
|
+
# Calculates hash code according to all attributes.
|
168
|
+
# @return [Integer] Hash code
|
169
|
+
def hash
|
170
|
+
[status_text, status_code, headers, body, error].hash
|
171
|
+
end
|
172
|
+
|
173
|
+
# Builds the object from hash
|
174
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
175
|
+
# @return [Object] Returns the model itself
|
176
|
+
def self.build_from_hash(attributes)
|
177
|
+
new.build_from_hash(attributes)
|
178
|
+
end
|
179
|
+
|
180
|
+
# Builds the object from hash
|
181
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
182
|
+
# @return [Object] Returns the model itself
|
183
|
+
def build_from_hash(attributes)
|
184
|
+
return nil unless attributes.is_a?(Hash)
|
185
|
+
self.class.openapi_types.each_pair do |key, type|
|
186
|
+
if attributes[self.class.attribute_map[key]].nil? && self.class.openapi_nullable.include?(key)
|
187
|
+
self.send("#{key}=", nil)
|
188
|
+
elsif type =~ /\AArray<(.*)>/i
|
189
|
+
# check to ensure the input is an array given that the attribute
|
190
|
+
# is documented as an array but the input is not
|
191
|
+
if attributes[self.class.attribute_map[key]].is_a?(Array)
|
192
|
+
self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
|
193
|
+
end
|
194
|
+
elsif !attributes[self.class.attribute_map[key]].nil?
|
195
|
+
self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
|
196
|
+
end
|
197
|
+
end
|
198
|
+
|
199
|
+
self
|
200
|
+
end
|
201
|
+
|
202
|
+
# Deserializes the data based on type
|
203
|
+
# @param string type Data type
|
204
|
+
# @param string value Value to be deserialized
|
205
|
+
# @return [Object] Deserialized data
|
206
|
+
def _deserialize(type, value)
|
207
|
+
case type.to_sym
|
208
|
+
when :Time
|
209
|
+
Time.parse(value)
|
210
|
+
when :Date
|
211
|
+
Date.parse(value)
|
212
|
+
when :String
|
213
|
+
value.to_s
|
214
|
+
when :Integer
|
215
|
+
value.to_i
|
216
|
+
when :Float
|
217
|
+
value.to_f
|
218
|
+
when :Boolean
|
219
|
+
if value.to_s =~ /\A(true|t|yes|y|1)\z/i
|
220
|
+
true
|
221
|
+
else
|
222
|
+
false
|
223
|
+
end
|
224
|
+
when :Object
|
225
|
+
# generic object (usually a Hash), return directly
|
226
|
+
value
|
227
|
+
when /\AArray<(?<inner_type>.+)>\z/
|
228
|
+
inner_type = Regexp.last_match[:inner_type]
|
229
|
+
value.map { |v| _deserialize(inner_type, v) }
|
230
|
+
when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
|
231
|
+
k_type = Regexp.last_match[:k_type]
|
232
|
+
v_type = Regexp.last_match[:v_type]
|
233
|
+
{}.tap do |hash|
|
234
|
+
value.each do |k, v|
|
235
|
+
hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
|
236
|
+
end
|
237
|
+
end
|
238
|
+
else # model
|
239
|
+
# models (e.g. Pet) or oneOf
|
240
|
+
klass = OpenapiClient.const_get(type)
|
241
|
+
klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
|
242
|
+
end
|
243
|
+
end
|
244
|
+
|
245
|
+
# Returns the string representation of the object
|
246
|
+
# @return [String] String presentation of the object
|
247
|
+
def to_s
|
248
|
+
to_hash.to_s
|
249
|
+
end
|
250
|
+
|
251
|
+
# to_body is an alias to to_hash (backward compatibility)
|
252
|
+
# @return [Hash] Returns the object in the form of hash
|
253
|
+
def to_body
|
254
|
+
to_hash
|
255
|
+
end
|
256
|
+
|
257
|
+
# Returns the object in the form of hash
|
258
|
+
# @return [Hash] Returns the object in the form of hash
|
259
|
+
def to_hash
|
260
|
+
hash = {}
|
261
|
+
self.class.attribute_map.each_pair do |attr, param|
|
262
|
+
value = self.send(attr)
|
263
|
+
if value.nil?
|
264
|
+
is_nullable = self.class.openapi_nullable.include?(attr)
|
265
|
+
next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
|
266
|
+
end
|
267
|
+
|
268
|
+
hash[param] = _to_hash(value)
|
269
|
+
end
|
270
|
+
hash
|
271
|
+
end
|
272
|
+
|
273
|
+
# Outputs non-array value in the form of hash
|
274
|
+
# For object, use to_hash. Otherwise, just return the value
|
275
|
+
# @param [Object] value Any valid value
|
276
|
+
# @return [Hash] Returns the value in the form of hash
|
277
|
+
def _to_hash(value)
|
278
|
+
if value.is_a?(Array)
|
279
|
+
value.compact.map { |v| _to_hash(v) }
|
280
|
+
elsif value.is_a?(Hash)
|
281
|
+
{}.tap do |hash|
|
282
|
+
value.each { |k, v| hash[k] = _to_hash(v) }
|
283
|
+
end
|
284
|
+
elsif value.respond_to? :to_hash
|
285
|
+
value.to_hash
|
286
|
+
else
|
287
|
+
value
|
288
|
+
end
|
289
|
+
end
|
290
|
+
|
291
|
+
end
|
292
|
+
|
293
|
+
end
|