browserup_mitmproxy_client 1.1

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.
Files changed (76) hide show
  1. checksums.yaml +7 -0
  2. data/Gemfile +9 -0
  3. data/Gemfile.lock +68 -0
  4. data/README.md +119 -0
  5. data/Rakefile +10 -0
  6. data/browserup_mitmproxy_client.gemspec +38 -0
  7. data/docs/BrowserUpProxyApi.md +657 -0
  8. data/docs/Counter.md +20 -0
  9. data/docs/Entry.md +38 -0
  10. data/docs/EntryRequest.md +36 -0
  11. data/docs/EntryRequestCookies.md +32 -0
  12. data/docs/EntryRequestQueryString.md +22 -0
  13. data/docs/EntryResponse.md +36 -0
  14. data/docs/EntryResponseContent.md +28 -0
  15. data/docs/EntryTimings.md +32 -0
  16. data/docs/Error.md +20 -0
  17. data/docs/Har.md +18 -0
  18. data/docs/HarLog.md +28 -0
  19. data/docs/HarLogCreator.md +22 -0
  20. data/docs/Header.md +22 -0
  21. data/docs/MatchCriteria.md +44 -0
  22. data/docs/NameValuePair.md +20 -0
  23. data/docs/Page.md +32 -0
  24. data/docs/PagePageTimings.md +22 -0
  25. data/docs/VerifyResult.md +22 -0
  26. data/docs/WebSocketMessage.md +24 -0
  27. data/git_push.sh +58 -0
  28. data/lib/browserup_mitmproxy_client/api/browser_up_proxy_api.rb +689 -0
  29. data/lib/browserup_mitmproxy_client/api_client.rb +389 -0
  30. data/lib/browserup_mitmproxy_client/api_error.rb +57 -0
  31. data/lib/browserup_mitmproxy_client/configuration.rb +279 -0
  32. data/lib/browserup_mitmproxy_client/models/counter.rb +239 -0
  33. data/lib/browserup_mitmproxy_client/models/entry.rb +359 -0
  34. data/lib/browserup_mitmproxy_client/models/entry_request.rb +346 -0
  35. data/lib/browserup_mitmproxy_client/models/entry_request_cookies.rb +291 -0
  36. data/lib/browserup_mitmproxy_client/models/entry_request_query_string.rb +246 -0
  37. data/lib/browserup_mitmproxy_client/models/entry_response.rb +348 -0
  38. data/lib/browserup_mitmproxy_client/models/entry_response_content.rb +273 -0
  39. data/lib/browserup_mitmproxy_client/models/entry_timings.rb +463 -0
  40. data/lib/browserup_mitmproxy_client/models/error.rb +229 -0
  41. data/lib/browserup_mitmproxy_client/models/har.rb +223 -0
  42. data/lib/browserup_mitmproxy_client/models/har_log.rb +287 -0
  43. data/lib/browserup_mitmproxy_client/models/har_log_creator.rb +246 -0
  44. data/lib/browserup_mitmproxy_client/models/header.rb +246 -0
  45. data/lib/browserup_mitmproxy_client/models/match_criteria.rb +346 -0
  46. data/lib/browserup_mitmproxy_client/models/name_value_pair.rb +229 -0
  47. data/lib/browserup_mitmproxy_client/models/page.rb +312 -0
  48. data/lib/browserup_mitmproxy_client/models/page_page_timings.rb +288 -0
  49. data/lib/browserup_mitmproxy_client/models/verify_result.rb +254 -0
  50. data/lib/browserup_mitmproxy_client/models/web_socket_message.rb +265 -0
  51. data/lib/browserup_mitmproxy_client/version.rb +15 -0
  52. data/lib/browserup_mitmproxy_client.rb +59 -0
  53. data/spec/api/browser_up_proxy_api_spec.rb +148 -0
  54. data/spec/api_client_spec.rb +226 -0
  55. data/spec/configuration_spec.rb +42 -0
  56. data/spec/models/counter_spec.rb +40 -0
  57. data/spec/models/entry_request_cookies_spec.rb +76 -0
  58. data/spec/models/entry_request_query_string_spec.rb +46 -0
  59. data/spec/models/entry_request_spec.rb +88 -0
  60. data/spec/models/entry_response_content_spec.rb +64 -0
  61. data/spec/models/entry_response_spec.rb +88 -0
  62. data/spec/models/entry_spec.rb +94 -0
  63. data/spec/models/entry_timings_spec.rb +76 -0
  64. data/spec/models/error_spec.rb +40 -0
  65. data/spec/models/har_log_creator_spec.rb +46 -0
  66. data/spec/models/har_log_spec.rb +64 -0
  67. data/spec/models/har_spec.rb +34 -0
  68. data/spec/models/header_spec.rb +46 -0
  69. data/spec/models/match_criteria_spec.rb +112 -0
  70. data/spec/models/name_value_pair_spec.rb +40 -0
  71. data/spec/models/page_page_timings_spec.rb +46 -0
  72. data/spec/models/page_spec.rb +76 -0
  73. data/spec/models/verify_result_spec.rb +46 -0
  74. data/spec/models/web_socket_message_spec.rb +52 -0
  75. data/spec/spec_helper.rb +111 -0
  76. metadata +181 -0
@@ -0,0 +1,359 @@
1
+ =begin
2
+ #BrowserUp MitmProxy
3
+
4
+ #___ This is the REST API for controlling the BrowserUp MitmProxy. The BrowserUp MitmProxy is a swiss army knife for automated testing that captures HTTP traffic in HAR files. It is also useful for Selenium/Cypress tests. ___
5
+
6
+ The version of the OpenAPI document: 1.0.0
7
+
8
+ Generated by: https://openapi-generator.tech
9
+ OpenAPI Generator version: 5.2.0
10
+
11
+ =end
12
+
13
+ require 'date'
14
+ require 'time'
15
+
16
+ module BrowserupMitmProxy
17
+ class Entry
18
+ attr_accessor :pageref
19
+
20
+ attr_accessor :started_date_time
21
+
22
+ attr_accessor :time
23
+
24
+ attr_accessor :request
25
+
26
+ attr_accessor :response
27
+
28
+ attr_accessor :cache
29
+
30
+ attr_accessor :timings
31
+
32
+ attr_accessor :server_ip_address
33
+
34
+ attr_accessor :_web_socket_messages
35
+
36
+ attr_accessor :connection
37
+
38
+ attr_accessor :comment
39
+
40
+ # Attribute mapping from ruby-style variable name to JSON key.
41
+ def self.attribute_map
42
+ {
43
+ :'pageref' => :'pageref',
44
+ :'started_date_time' => :'startedDateTime',
45
+ :'time' => :'time',
46
+ :'request' => :'request',
47
+ :'response' => :'response',
48
+ :'cache' => :'cache',
49
+ :'timings' => :'timings',
50
+ :'server_ip_address' => :'serverIPAddress',
51
+ :'_web_socket_messages' => :'_webSocketMessages',
52
+ :'connection' => :'connection',
53
+ :'comment' => :'comment'
54
+ }
55
+ end
56
+
57
+ # Returns all the JSON keys this model knows about
58
+ def self.acceptable_attributes
59
+ attribute_map.values
60
+ end
61
+
62
+ # Attribute type mapping.
63
+ def self.openapi_types
64
+ {
65
+ :'pageref' => :'String',
66
+ :'started_date_time' => :'Time',
67
+ :'time' => :'Integer',
68
+ :'request' => :'EntryRequest',
69
+ :'response' => :'EntryResponse',
70
+ :'cache' => :'Object',
71
+ :'timings' => :'EntryTimings',
72
+ :'server_ip_address' => :'String',
73
+ :'_web_socket_messages' => :'Array<WebSocketMessage>',
74
+ :'connection' => :'String',
75
+ :'comment' => :'String'
76
+ }
77
+ end
78
+
79
+ # List of attributes with nullable: true
80
+ def self.openapi_nullable
81
+ Set.new([
82
+ ])
83
+ end
84
+
85
+ # Initializes the object
86
+ # @param [Hash] attributes Model attributes in the form of hash
87
+ def initialize(attributes = {})
88
+ if (!attributes.is_a?(Hash))
89
+ fail ArgumentError, "The input argument (attributes) must be a hash in `BrowserupMitmProxy::Entry` initialize method"
90
+ end
91
+
92
+ # check to see if the attribute exists and convert string to symbol for hash key
93
+ attributes = attributes.each_with_object({}) { |(k, v), h|
94
+ if (!self.class.attribute_map.key?(k.to_sym))
95
+ fail ArgumentError, "`#{k}` is not a valid attribute in `BrowserupMitmProxy::Entry`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
96
+ end
97
+ h[k.to_sym] = v
98
+ }
99
+
100
+ if attributes.key?(:'pageref')
101
+ self.pageref = attributes[:'pageref']
102
+ end
103
+
104
+ if attributes.key?(:'started_date_time')
105
+ self.started_date_time = attributes[:'started_date_time']
106
+ end
107
+
108
+ if attributes.key?(:'time')
109
+ self.time = attributes[:'time']
110
+ end
111
+
112
+ if attributes.key?(:'request')
113
+ self.request = attributes[:'request']
114
+ end
115
+
116
+ if attributes.key?(:'response')
117
+ self.response = attributes[:'response']
118
+ end
119
+
120
+ if attributes.key?(:'cache')
121
+ self.cache = attributes[:'cache']
122
+ end
123
+
124
+ if attributes.key?(:'timings')
125
+ self.timings = attributes[:'timings']
126
+ end
127
+
128
+ if attributes.key?(:'server_ip_address')
129
+ self.server_ip_address = attributes[:'server_ip_address']
130
+ end
131
+
132
+ if attributes.key?(:'_web_socket_messages')
133
+ if (value = attributes[:'_web_socket_messages']).is_a?(Array)
134
+ self._web_socket_messages = value
135
+ end
136
+ end
137
+
138
+ if attributes.key?(:'connection')
139
+ self.connection = attributes[:'connection']
140
+ end
141
+
142
+ if attributes.key?(:'comment')
143
+ self.comment = attributes[:'comment']
144
+ end
145
+ end
146
+
147
+ # Show invalid properties with the reasons. Usually used together with valid?
148
+ # @return Array for valid properties with the reasons
149
+ def list_invalid_properties
150
+ invalid_properties = Array.new
151
+ if @started_date_time.nil?
152
+ invalid_properties.push('invalid value for "started_date_time", started_date_time cannot be nil.')
153
+ end
154
+
155
+ if @time.nil?
156
+ invalid_properties.push('invalid value for "time", time cannot be nil.')
157
+ end
158
+
159
+ if @time < 0
160
+ invalid_properties.push('invalid value for "time", must be greater than or equal to 0.')
161
+ end
162
+
163
+ if @request.nil?
164
+ invalid_properties.push('invalid value for "request", request cannot be nil.')
165
+ end
166
+
167
+ if @response.nil?
168
+ invalid_properties.push('invalid value for "response", response cannot be nil.')
169
+ end
170
+
171
+ if @cache.nil?
172
+ invalid_properties.push('invalid value for "cache", cache cannot be nil.')
173
+ end
174
+
175
+ if @timings.nil?
176
+ invalid_properties.push('invalid value for "timings", timings cannot be nil.')
177
+ end
178
+
179
+ invalid_properties
180
+ end
181
+
182
+ # Check to see if the all the properties in the model are valid
183
+ # @return true if the model is valid
184
+ def valid?
185
+ return false if @started_date_time.nil?
186
+ return false if @time.nil?
187
+ return false if @time < 0
188
+ return false if @request.nil?
189
+ return false if @response.nil?
190
+ return false if @cache.nil?
191
+ return false if @timings.nil?
192
+ true
193
+ end
194
+
195
+ # Custom attribute writer method with validation
196
+ # @param [Object] time Value to be assigned
197
+ def time=(time)
198
+ if time.nil?
199
+ fail ArgumentError, 'time cannot be nil'
200
+ end
201
+
202
+ if time < 0
203
+ fail ArgumentError, 'invalid value for "time", must be greater than or equal to 0.'
204
+ end
205
+
206
+ @time = time
207
+ end
208
+
209
+ # Checks equality by comparing each attribute.
210
+ # @param [Object] Object to be compared
211
+ def ==(o)
212
+ return true if self.equal?(o)
213
+ self.class == o.class &&
214
+ pageref == o.pageref &&
215
+ started_date_time == o.started_date_time &&
216
+ time == o.time &&
217
+ request == o.request &&
218
+ response == o.response &&
219
+ cache == o.cache &&
220
+ timings == o.timings &&
221
+ server_ip_address == o.server_ip_address &&
222
+ _web_socket_messages == o._web_socket_messages &&
223
+ connection == o.connection &&
224
+ comment == o.comment
225
+ end
226
+
227
+ # @see the `==` method
228
+ # @param [Object] Object to be compared
229
+ def eql?(o)
230
+ self == o
231
+ end
232
+
233
+ # Calculates hash code according to all attributes.
234
+ # @return [Integer] Hash code
235
+ def hash
236
+ [pageref, started_date_time, time, request, response, cache, timings, server_ip_address, _web_socket_messages, connection, comment].hash
237
+ end
238
+
239
+ # Builds the object from hash
240
+ # @param [Hash] attributes Model attributes in the form of hash
241
+ # @return [Object] Returns the model itself
242
+ def self.build_from_hash(attributes)
243
+ new.build_from_hash(attributes)
244
+ end
245
+
246
+ # Builds the object from hash
247
+ # @param [Hash] attributes Model attributes in the form of hash
248
+ # @return [Object] Returns the model itself
249
+ def build_from_hash(attributes)
250
+ return nil unless attributes.is_a?(Hash)
251
+ self.class.openapi_types.each_pair do |key, type|
252
+ if attributes[self.class.attribute_map[key]].nil? && self.class.openapi_nullable.include?(key)
253
+ self.send("#{key}=", nil)
254
+ elsif type =~ /\AArray<(.*)>/i
255
+ # check to ensure the input is an array given that the attribute
256
+ # is documented as an array but the input is not
257
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
258
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
259
+ end
260
+ elsif !attributes[self.class.attribute_map[key]].nil?
261
+ self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
262
+ end
263
+ end
264
+
265
+ self
266
+ end
267
+
268
+ # Deserializes the data based on type
269
+ # @param string type Data type
270
+ # @param string value Value to be deserialized
271
+ # @return [Object] Deserialized data
272
+ def _deserialize(type, value)
273
+ case type.to_sym
274
+ when :Time
275
+ Time.parse(value)
276
+ when :Date
277
+ Date.parse(value)
278
+ when :String
279
+ value.to_s
280
+ when :Integer
281
+ value.to_i
282
+ when :Float
283
+ value.to_f
284
+ when :Boolean
285
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
286
+ true
287
+ else
288
+ false
289
+ end
290
+ when :Object
291
+ # generic object (usually a Hash), return directly
292
+ value
293
+ when /\AArray<(?<inner_type>.+)>\z/
294
+ inner_type = Regexp.last_match[:inner_type]
295
+ value.map { |v| _deserialize(inner_type, v) }
296
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
297
+ k_type = Regexp.last_match[:k_type]
298
+ v_type = Regexp.last_match[:v_type]
299
+ {}.tap do |hash|
300
+ value.each do |k, v|
301
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
302
+ end
303
+ end
304
+ else # model
305
+ # models (e.g. Pet) or oneOf
306
+ klass = BrowserupMitmProxy.const_get(type)
307
+ klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
308
+ end
309
+ end
310
+
311
+ # Returns the string representation of the object
312
+ # @return [String] String presentation of the object
313
+ def to_s
314
+ to_hash.to_s
315
+ end
316
+
317
+ # to_body is an alias to to_hash (backward compatibility)
318
+ # @return [Hash] Returns the object in the form of hash
319
+ def to_body
320
+ to_hash
321
+ end
322
+
323
+ # Returns the object in the form of hash
324
+ # @return [Hash] Returns the object in the form of hash
325
+ def to_hash
326
+ hash = {}
327
+ self.class.attribute_map.each_pair do |attr, param|
328
+ value = self.send(attr)
329
+ if value.nil?
330
+ is_nullable = self.class.openapi_nullable.include?(attr)
331
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
332
+ end
333
+
334
+ hash[param] = _to_hash(value)
335
+ end
336
+ hash
337
+ end
338
+
339
+ # Outputs non-array value in the form of hash
340
+ # For object, use to_hash. Otherwise, just return the value
341
+ # @param [Object] value Any valid value
342
+ # @return [Hash] Returns the value in the form of hash
343
+ def _to_hash(value)
344
+ if value.is_a?(Array)
345
+ value.compact.map { |v| _to_hash(v) }
346
+ elsif value.is_a?(Hash)
347
+ {}.tap do |hash|
348
+ value.each { |k, v| hash[k] = _to_hash(v) }
349
+ end
350
+ elsif value.respond_to? :to_hash
351
+ value.to_hash
352
+ else
353
+ value
354
+ end
355
+ end
356
+
357
+ end
358
+
359
+ end
@@ -0,0 +1,346 @@
1
+ =begin
2
+ #BrowserUp MitmProxy
3
+
4
+ #___ This is the REST API for controlling the BrowserUp MitmProxy. The BrowserUp MitmProxy is a swiss army knife for automated testing that captures HTTP traffic in HAR files. It is also useful for Selenium/Cypress tests. ___
5
+
6
+ The version of the OpenAPI document: 1.0.0
7
+
8
+ Generated by: https://openapi-generator.tech
9
+ OpenAPI Generator version: 5.2.0
10
+
11
+ =end
12
+
13
+ require 'date'
14
+ require 'time'
15
+
16
+ module BrowserupMitmProxy
17
+ class EntryRequest
18
+ attr_accessor :method
19
+
20
+ attr_accessor :url
21
+
22
+ attr_accessor :http_version
23
+
24
+ attr_accessor :cookies
25
+
26
+ attr_accessor :headers
27
+
28
+ attr_accessor :query_string
29
+
30
+ # Posted data info.
31
+ attr_accessor :post_data
32
+
33
+ attr_accessor :headers_size
34
+
35
+ attr_accessor :body_size
36
+
37
+ attr_accessor :comment
38
+
39
+ # Attribute mapping from ruby-style variable name to JSON key.
40
+ def self.attribute_map
41
+ {
42
+ :'method' => :'method',
43
+ :'url' => :'url',
44
+ :'http_version' => :'httpVersion',
45
+ :'cookies' => :'cookies',
46
+ :'headers' => :'headers',
47
+ :'query_string' => :'queryString',
48
+ :'post_data' => :'postData',
49
+ :'headers_size' => :'headersSize',
50
+ :'body_size' => :'bodySize',
51
+ :'comment' => :'comment'
52
+ }
53
+ end
54
+
55
+ # Returns all the JSON keys this model knows about
56
+ def self.acceptable_attributes
57
+ attribute_map.values
58
+ end
59
+
60
+ # Attribute type mapping.
61
+ def self.openapi_types
62
+ {
63
+ :'method' => :'String',
64
+ :'url' => :'String',
65
+ :'http_version' => :'String',
66
+ :'cookies' => :'Array<EntryRequestCookies>',
67
+ :'headers' => :'Array<Header>',
68
+ :'query_string' => :'Array<EntryRequestQueryString>',
69
+ :'post_data' => :'Object',
70
+ :'headers_size' => :'Integer',
71
+ :'body_size' => :'Integer',
72
+ :'comment' => :'String'
73
+ }
74
+ end
75
+
76
+ # List of attributes with nullable: true
77
+ def self.openapi_nullable
78
+ Set.new([
79
+ ])
80
+ end
81
+
82
+ # Initializes the object
83
+ # @param [Hash] attributes Model attributes in the form of hash
84
+ def initialize(attributes = {})
85
+ if (!attributes.is_a?(Hash))
86
+ fail ArgumentError, "The input argument (attributes) must be a hash in `BrowserupMitmProxy::EntryRequest` initialize method"
87
+ end
88
+
89
+ # check to see if the attribute exists and convert string to symbol for hash key
90
+ attributes = attributes.each_with_object({}) { |(k, v), h|
91
+ if (!self.class.attribute_map.key?(k.to_sym))
92
+ fail ArgumentError, "`#{k}` is not a valid attribute in `BrowserupMitmProxy::EntryRequest`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
93
+ end
94
+ h[k.to_sym] = v
95
+ }
96
+
97
+ if attributes.key?(:'method')
98
+ self.method = attributes[:'method']
99
+ end
100
+
101
+ if attributes.key?(:'url')
102
+ self.url = attributes[:'url']
103
+ end
104
+
105
+ if attributes.key?(:'http_version')
106
+ self.http_version = attributes[:'http_version']
107
+ end
108
+
109
+ if attributes.key?(:'cookies')
110
+ if (value = attributes[:'cookies']).is_a?(Array)
111
+ self.cookies = value
112
+ end
113
+ end
114
+
115
+ if attributes.key?(:'headers')
116
+ if (value = attributes[:'headers']).is_a?(Array)
117
+ self.headers = value
118
+ end
119
+ end
120
+
121
+ if attributes.key?(:'query_string')
122
+ if (value = attributes[:'query_string']).is_a?(Array)
123
+ self.query_string = value
124
+ end
125
+ end
126
+
127
+ if attributes.key?(:'post_data')
128
+ self.post_data = attributes[:'post_data']
129
+ end
130
+
131
+ if attributes.key?(:'headers_size')
132
+ self.headers_size = attributes[:'headers_size']
133
+ end
134
+
135
+ if attributes.key?(:'body_size')
136
+ self.body_size = attributes[:'body_size']
137
+ end
138
+
139
+ if attributes.key?(:'comment')
140
+ self.comment = attributes[:'comment']
141
+ end
142
+ end
143
+
144
+ # Show invalid properties with the reasons. Usually used together with valid?
145
+ # @return Array for valid properties with the reasons
146
+ def list_invalid_properties
147
+ invalid_properties = Array.new
148
+ if @method.nil?
149
+ invalid_properties.push('invalid value for "method", method cannot be nil.')
150
+ end
151
+
152
+ if @url.nil?
153
+ invalid_properties.push('invalid value for "url", url cannot be nil.')
154
+ end
155
+
156
+ if @http_version.nil?
157
+ invalid_properties.push('invalid value for "http_version", http_version cannot be nil.')
158
+ end
159
+
160
+ if @cookies.nil?
161
+ invalid_properties.push('invalid value for "cookies", cookies cannot be nil.')
162
+ end
163
+
164
+ if @headers.nil?
165
+ invalid_properties.push('invalid value for "headers", headers cannot be nil.')
166
+ end
167
+
168
+ if @query_string.nil?
169
+ invalid_properties.push('invalid value for "query_string", query_string cannot be nil.')
170
+ end
171
+
172
+ if @headers_size.nil?
173
+ invalid_properties.push('invalid value for "headers_size", headers_size cannot be nil.')
174
+ end
175
+
176
+ if @body_size.nil?
177
+ invalid_properties.push('invalid value for "body_size", body_size cannot be nil.')
178
+ end
179
+
180
+ invalid_properties
181
+ end
182
+
183
+ # Check to see if the all the properties in the model are valid
184
+ # @return true if the model is valid
185
+ def valid?
186
+ return false if @method.nil?
187
+ return false if @url.nil?
188
+ return false if @http_version.nil?
189
+ return false if @cookies.nil?
190
+ return false if @headers.nil?
191
+ return false if @query_string.nil?
192
+ return false if @headers_size.nil?
193
+ return false if @body_size.nil?
194
+ true
195
+ end
196
+
197
+ # Checks equality by comparing each attribute.
198
+ # @param [Object] Object to be compared
199
+ def ==(o)
200
+ return true if self.equal?(o)
201
+ self.class == o.class &&
202
+ method == o.method &&
203
+ url == o.url &&
204
+ http_version == o.http_version &&
205
+ cookies == o.cookies &&
206
+ headers == o.headers &&
207
+ query_string == o.query_string &&
208
+ post_data == o.post_data &&
209
+ headers_size == o.headers_size &&
210
+ body_size == o.body_size &&
211
+ comment == o.comment
212
+ end
213
+
214
+ # @see the `==` method
215
+ # @param [Object] Object to be compared
216
+ def eql?(o)
217
+ self == o
218
+ end
219
+
220
+ # Calculates hash code according to all attributes.
221
+ # @return [Integer] Hash code
222
+ def hash
223
+ [method, url, http_version, cookies, headers, query_string, post_data, headers_size, body_size, comment].hash
224
+ end
225
+
226
+ # Builds the object from hash
227
+ # @param [Hash] attributes Model attributes in the form of hash
228
+ # @return [Object] Returns the model itself
229
+ def self.build_from_hash(attributes)
230
+ new.build_from_hash(attributes)
231
+ end
232
+
233
+ # Builds the object from hash
234
+ # @param [Hash] attributes Model attributes in the form of hash
235
+ # @return [Object] Returns the model itself
236
+ def build_from_hash(attributes)
237
+ return nil unless attributes.is_a?(Hash)
238
+ self.class.openapi_types.each_pair do |key, type|
239
+ if attributes[self.class.attribute_map[key]].nil? && self.class.openapi_nullable.include?(key)
240
+ self.send("#{key}=", nil)
241
+ elsif type =~ /\AArray<(.*)>/i
242
+ # check to ensure the input is an array given that the attribute
243
+ # is documented as an array but the input is not
244
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
245
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
246
+ end
247
+ elsif !attributes[self.class.attribute_map[key]].nil?
248
+ self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
249
+ end
250
+ end
251
+
252
+ self
253
+ end
254
+
255
+ # Deserializes the data based on type
256
+ # @param string type Data type
257
+ # @param string value Value to be deserialized
258
+ # @return [Object] Deserialized data
259
+ def _deserialize(type, value)
260
+ case type.to_sym
261
+ when :Time
262
+ Time.parse(value)
263
+ when :Date
264
+ Date.parse(value)
265
+ when :String
266
+ value.to_s
267
+ when :Integer
268
+ value.to_i
269
+ when :Float
270
+ value.to_f
271
+ when :Boolean
272
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
273
+ true
274
+ else
275
+ false
276
+ end
277
+ when :Object
278
+ # generic object (usually a Hash), return directly
279
+ value
280
+ when /\AArray<(?<inner_type>.+)>\z/
281
+ inner_type = Regexp.last_match[:inner_type]
282
+ value.map { |v| _deserialize(inner_type, v) }
283
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
284
+ k_type = Regexp.last_match[:k_type]
285
+ v_type = Regexp.last_match[:v_type]
286
+ {}.tap do |hash|
287
+ value.each do |k, v|
288
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
289
+ end
290
+ end
291
+ else # model
292
+ # models (e.g. Pet) or oneOf
293
+ klass = BrowserupMitmProxy.const_get(type)
294
+ klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
295
+ end
296
+ end
297
+
298
+ # Returns the string representation of the object
299
+ # @return [String] String presentation of the object
300
+ def to_s
301
+ to_hash.to_s
302
+ end
303
+
304
+ # to_body is an alias to to_hash (backward compatibility)
305
+ # @return [Hash] Returns the object in the form of hash
306
+ def to_body
307
+ to_hash
308
+ end
309
+
310
+ # Returns the object in the form of hash
311
+ # @return [Hash] Returns the object in the form of hash
312
+ def to_hash
313
+ hash = {}
314
+ self.class.attribute_map.each_pair do |attr, param|
315
+ value = self.send(attr)
316
+ if value.nil?
317
+ is_nullable = self.class.openapi_nullable.include?(attr)
318
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
319
+ end
320
+
321
+ hash[param] = _to_hash(value)
322
+ end
323
+ hash
324
+ end
325
+
326
+ # Outputs non-array value in the form of hash
327
+ # For object, use to_hash. Otherwise, just return the value
328
+ # @param [Object] value Any valid value
329
+ # @return [Hash] Returns the value in the form of hash
330
+ def _to_hash(value)
331
+ if value.is_a?(Array)
332
+ value.compact.map { |v| _to_hash(v) }
333
+ elsif value.is_a?(Hash)
334
+ {}.tap do |hash|
335
+ value.each { |k, v| hash[k] = _to_hash(v) }
336
+ end
337
+ elsif value.respond_to? :to_hash
338
+ value.to_hash
339
+ else
340
+ value
341
+ end
342
+ end
343
+
344
+ end
345
+
346
+ end