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,312 @@
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 Page
18
+ attr_accessor :started_date_time
19
+
20
+ attr_accessor :id
21
+
22
+ attr_accessor :title
23
+
24
+ attr_accessor :_verifications
25
+
26
+ attr_accessor :_counters
27
+
28
+ attr_accessor :_errors
29
+
30
+ attr_accessor :page_timings
31
+
32
+ attr_accessor :comment
33
+
34
+ # Attribute mapping from ruby-style variable name to JSON key.
35
+ def self.attribute_map
36
+ {
37
+ :'started_date_time' => :'startedDateTime',
38
+ :'id' => :'id',
39
+ :'title' => :'title',
40
+ :'_verifications' => :'_verifications',
41
+ :'_counters' => :'_counters',
42
+ :'_errors' => :'_errors',
43
+ :'page_timings' => :'pageTimings',
44
+ :'comment' => :'comment'
45
+ }
46
+ end
47
+
48
+ # Returns all the JSON keys this model knows about
49
+ def self.acceptable_attributes
50
+ attribute_map.values
51
+ end
52
+
53
+ # Attribute type mapping.
54
+ def self.openapi_types
55
+ {
56
+ :'started_date_time' => :'Time',
57
+ :'id' => :'String',
58
+ :'title' => :'String',
59
+ :'_verifications' => :'Array<VerifyResult>',
60
+ :'_counters' => :'Array<Counter>',
61
+ :'_errors' => :'Array<Error>',
62
+ :'page_timings' => :'PagePageTimings',
63
+ :'comment' => :'String'
64
+ }
65
+ end
66
+
67
+ # List of attributes with nullable: true
68
+ def self.openapi_nullable
69
+ Set.new([
70
+ ])
71
+ end
72
+
73
+ # Initializes the object
74
+ # @param [Hash] attributes Model attributes in the form of hash
75
+ def initialize(attributes = {})
76
+ if (!attributes.is_a?(Hash))
77
+ fail ArgumentError, "The input argument (attributes) must be a hash in `BrowserupMitmProxy::Page` initialize method"
78
+ end
79
+
80
+ # check to see if the attribute exists and convert string to symbol for hash key
81
+ attributes = attributes.each_with_object({}) { |(k, v), h|
82
+ if (!self.class.attribute_map.key?(k.to_sym))
83
+ fail ArgumentError, "`#{k}` is not a valid attribute in `BrowserupMitmProxy::Page`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
84
+ end
85
+ h[k.to_sym] = v
86
+ }
87
+
88
+ if attributes.key?(:'started_date_time')
89
+ self.started_date_time = attributes[:'started_date_time']
90
+ end
91
+
92
+ if attributes.key?(:'id')
93
+ self.id = attributes[:'id']
94
+ end
95
+
96
+ if attributes.key?(:'title')
97
+ self.title = attributes[:'title']
98
+ end
99
+
100
+ if attributes.key?(:'_verifications')
101
+ if (value = attributes[:'_verifications']).is_a?(Array)
102
+ self._verifications = value
103
+ end
104
+ end
105
+
106
+ if attributes.key?(:'_counters')
107
+ if (value = attributes[:'_counters']).is_a?(Array)
108
+ self._counters = value
109
+ end
110
+ end
111
+
112
+ if attributes.key?(:'_errors')
113
+ if (value = attributes[:'_errors']).is_a?(Array)
114
+ self._errors = value
115
+ end
116
+ end
117
+
118
+ if attributes.key?(:'page_timings')
119
+ self.page_timings = attributes[:'page_timings']
120
+ end
121
+
122
+ if attributes.key?(:'comment')
123
+ self.comment = attributes[:'comment']
124
+ end
125
+ end
126
+
127
+ # Show invalid properties with the reasons. Usually used together with valid?
128
+ # @return Array for valid properties with the reasons
129
+ def list_invalid_properties
130
+ invalid_properties = Array.new
131
+ if @started_date_time.nil?
132
+ invalid_properties.push('invalid value for "started_date_time", started_date_time cannot be nil.')
133
+ end
134
+
135
+ if @id.nil?
136
+ invalid_properties.push('invalid value for "id", id cannot be nil.')
137
+ end
138
+
139
+ if @title.nil?
140
+ invalid_properties.push('invalid value for "title", title cannot be nil.')
141
+ end
142
+
143
+ if @_verifications.nil?
144
+ invalid_properties.push('invalid value for "_verifications", _verifications cannot be nil.')
145
+ end
146
+
147
+ if @page_timings.nil?
148
+ invalid_properties.push('invalid value for "page_timings", page_timings cannot be nil.')
149
+ end
150
+
151
+ invalid_properties
152
+ end
153
+
154
+ # Check to see if the all the properties in the model are valid
155
+ # @return true if the model is valid
156
+ def valid?
157
+ return false if @started_date_time.nil?
158
+ return false if @id.nil?
159
+ return false if @title.nil?
160
+ return false if @_verifications.nil?
161
+ return false if @page_timings.nil?
162
+ true
163
+ end
164
+
165
+ # Checks equality by comparing each attribute.
166
+ # @param [Object] Object to be compared
167
+ def ==(o)
168
+ return true if self.equal?(o)
169
+ self.class == o.class &&
170
+ started_date_time == o.started_date_time &&
171
+ id == o.id &&
172
+ title == o.title &&
173
+ _verifications == o._verifications &&
174
+ _counters == o._counters &&
175
+ _errors == o._errors &&
176
+ page_timings == o.page_timings &&
177
+ comment == o.comment
178
+ end
179
+
180
+ # @see the `==` method
181
+ # @param [Object] Object to be compared
182
+ def eql?(o)
183
+ self == o
184
+ end
185
+
186
+ # Calculates hash code according to all attributes.
187
+ # @return [Integer] Hash code
188
+ def hash
189
+ [started_date_time, id, title, _verifications, _counters, _errors, page_timings, comment].hash
190
+ end
191
+
192
+ # Builds the object from hash
193
+ # @param [Hash] attributes Model attributes in the form of hash
194
+ # @return [Object] Returns the model itself
195
+ def self.build_from_hash(attributes)
196
+ new.build_from_hash(attributes)
197
+ end
198
+
199
+ # Builds the object from hash
200
+ # @param [Hash] attributes Model attributes in the form of hash
201
+ # @return [Object] Returns the model itself
202
+ def build_from_hash(attributes)
203
+ return nil unless attributes.is_a?(Hash)
204
+ self.class.openapi_types.each_pair do |key, type|
205
+ if attributes[self.class.attribute_map[key]].nil? && self.class.openapi_nullable.include?(key)
206
+ self.send("#{key}=", nil)
207
+ elsif type =~ /\AArray<(.*)>/i
208
+ # check to ensure the input is an array given that the attribute
209
+ # is documented as an array but the input is not
210
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
211
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
212
+ end
213
+ elsif !attributes[self.class.attribute_map[key]].nil?
214
+ self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
215
+ end
216
+ end
217
+
218
+ self
219
+ end
220
+
221
+ # Deserializes the data based on type
222
+ # @param string type Data type
223
+ # @param string value Value to be deserialized
224
+ # @return [Object] Deserialized data
225
+ def _deserialize(type, value)
226
+ case type.to_sym
227
+ when :Time
228
+ Time.parse(value)
229
+ when :Date
230
+ Date.parse(value)
231
+ when :String
232
+ value.to_s
233
+ when :Integer
234
+ value.to_i
235
+ when :Float
236
+ value.to_f
237
+ when :Boolean
238
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
239
+ true
240
+ else
241
+ false
242
+ end
243
+ when :Object
244
+ # generic object (usually a Hash), return directly
245
+ value
246
+ when /\AArray<(?<inner_type>.+)>\z/
247
+ inner_type = Regexp.last_match[:inner_type]
248
+ value.map { |v| _deserialize(inner_type, v) }
249
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
250
+ k_type = Regexp.last_match[:k_type]
251
+ v_type = Regexp.last_match[:v_type]
252
+ {}.tap do |hash|
253
+ value.each do |k, v|
254
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
255
+ end
256
+ end
257
+ else # model
258
+ # models (e.g. Pet) or oneOf
259
+ klass = BrowserupMitmProxy.const_get(type)
260
+ klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
261
+ end
262
+ end
263
+
264
+ # Returns the string representation of the object
265
+ # @return [String] String presentation of the object
266
+ def to_s
267
+ to_hash.to_s
268
+ end
269
+
270
+ # to_body is an alias to to_hash (backward compatibility)
271
+ # @return [Hash] Returns the object in the form of hash
272
+ def to_body
273
+ to_hash
274
+ end
275
+
276
+ # Returns the object in the form of hash
277
+ # @return [Hash] Returns the object in the form of hash
278
+ def to_hash
279
+ hash = {}
280
+ self.class.attribute_map.each_pair do |attr, param|
281
+ value = self.send(attr)
282
+ if value.nil?
283
+ is_nullable = self.class.openapi_nullable.include?(attr)
284
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
285
+ end
286
+
287
+ hash[param] = _to_hash(value)
288
+ end
289
+ hash
290
+ end
291
+
292
+ # Outputs non-array value in the form of hash
293
+ # For object, use to_hash. Otherwise, just return the value
294
+ # @param [Object] value Any valid value
295
+ # @return [Hash] Returns the value in the form of hash
296
+ def _to_hash(value)
297
+ if value.is_a?(Array)
298
+ value.compact.map { |v| _to_hash(v) }
299
+ elsif value.is_a?(Hash)
300
+ {}.tap do |hash|
301
+ value.each { |k, v| hash[k] = _to_hash(v) }
302
+ end
303
+ elsif value.respond_to? :to_hash
304
+ value.to_hash
305
+ else
306
+ value
307
+ end
308
+ end
309
+
310
+ end
311
+
312
+ end
@@ -0,0 +1,288 @@
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 PagePageTimings
18
+ attr_accessor :on_content_load
19
+
20
+ attr_accessor :on_load
21
+
22
+ attr_accessor :comment
23
+
24
+ # Attribute mapping from ruby-style variable name to JSON key.
25
+ def self.attribute_map
26
+ {
27
+ :'on_content_load' => :'onContentLoad',
28
+ :'on_load' => :'onLoad',
29
+ :'comment' => :'comment'
30
+ }
31
+ end
32
+
33
+ # Returns all the JSON keys this model knows about
34
+ def self.acceptable_attributes
35
+ attribute_map.values
36
+ end
37
+
38
+ # Attribute type mapping.
39
+ def self.openapi_types
40
+ {
41
+ :'on_content_load' => :'Integer',
42
+ :'on_load' => :'Integer',
43
+ :'comment' => :'String'
44
+ }
45
+ end
46
+
47
+ # List of attributes with nullable: true
48
+ def self.openapi_nullable
49
+ Set.new([
50
+ ])
51
+ end
52
+
53
+ # Initializes the object
54
+ # @param [Hash] attributes Model attributes in the form of hash
55
+ def initialize(attributes = {})
56
+ if (!attributes.is_a?(Hash))
57
+ fail ArgumentError, "The input argument (attributes) must be a hash in `BrowserupMitmProxy::PagePageTimings` initialize method"
58
+ end
59
+
60
+ # check to see if the attribute exists and convert string to symbol for hash key
61
+ attributes = attributes.each_with_object({}) { |(k, v), h|
62
+ if (!self.class.attribute_map.key?(k.to_sym))
63
+ fail ArgumentError, "`#{k}` is not a valid attribute in `BrowserupMitmProxy::PagePageTimings`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
64
+ end
65
+ h[k.to_sym] = v
66
+ }
67
+
68
+ if attributes.key?(:'on_content_load')
69
+ self.on_content_load = attributes[:'on_content_load']
70
+ else
71
+ self.on_content_load = -1
72
+ end
73
+
74
+ if attributes.key?(:'on_load')
75
+ self.on_load = attributes[:'on_load']
76
+ else
77
+ self.on_load = -1
78
+ end
79
+
80
+ if attributes.key?(:'comment')
81
+ self.comment = attributes[:'comment']
82
+ end
83
+ end
84
+
85
+ # Show invalid properties with the reasons. Usually used together with valid?
86
+ # @return Array for valid properties with the reasons
87
+ def list_invalid_properties
88
+ invalid_properties = Array.new
89
+ if @on_content_load.nil?
90
+ invalid_properties.push('invalid value for "on_content_load", on_content_load cannot be nil.')
91
+ end
92
+
93
+ if @on_content_load < -1
94
+ invalid_properties.push('invalid value for "on_content_load", must be greater than or equal to -1.')
95
+ end
96
+
97
+ if @on_load.nil?
98
+ invalid_properties.push('invalid value for "on_load", on_load cannot be nil.')
99
+ end
100
+
101
+ if @on_load < -1
102
+ invalid_properties.push('invalid value for "on_load", must be greater than or equal to -1.')
103
+ end
104
+
105
+ invalid_properties
106
+ end
107
+
108
+ # Check to see if the all the properties in the model are valid
109
+ # @return true if the model is valid
110
+ def valid?
111
+ return false if @on_content_load.nil?
112
+ return false if @on_content_load < -1
113
+ return false if @on_load.nil?
114
+ return false if @on_load < -1
115
+ true
116
+ end
117
+
118
+ # Custom attribute writer method with validation
119
+ # @param [Object] on_content_load Value to be assigned
120
+ def on_content_load=(on_content_load)
121
+ if on_content_load.nil?
122
+ fail ArgumentError, 'on_content_load cannot be nil'
123
+ end
124
+
125
+ if on_content_load < -1
126
+ fail ArgumentError, 'invalid value for "on_content_load", must be greater than or equal to -1.'
127
+ end
128
+
129
+ @on_content_load = on_content_load
130
+ end
131
+
132
+ # Custom attribute writer method with validation
133
+ # @param [Object] on_load Value to be assigned
134
+ def on_load=(on_load)
135
+ if on_load.nil?
136
+ fail ArgumentError, 'on_load cannot be nil'
137
+ end
138
+
139
+ if on_load < -1
140
+ fail ArgumentError, 'invalid value for "on_load", must be greater than or equal to -1.'
141
+ end
142
+
143
+ @on_load = on_load
144
+ end
145
+
146
+ # Checks equality by comparing each attribute.
147
+ # @param [Object] Object to be compared
148
+ def ==(o)
149
+ return true if self.equal?(o)
150
+ self.class == o.class &&
151
+ on_content_load == o.on_content_load &&
152
+ on_load == o.on_load &&
153
+ comment == o.comment
154
+ end
155
+
156
+ # @see the `==` method
157
+ # @param [Object] Object to be compared
158
+ def eql?(o)
159
+ self == o
160
+ end
161
+
162
+ # Calculates hash code according to all attributes.
163
+ # @return [Integer] Hash code
164
+ def hash
165
+ [on_content_load, on_load, comment].hash
166
+ end
167
+
168
+ # Builds the object from hash
169
+ # @param [Hash] attributes Model attributes in the form of hash
170
+ # @return [Object] Returns the model itself
171
+ def self.build_from_hash(attributes)
172
+ new.build_from_hash(attributes)
173
+ end
174
+
175
+ # Builds the object from hash
176
+ # @param [Hash] attributes Model attributes in the form of hash
177
+ # @return [Object] Returns the model itself
178
+ def build_from_hash(attributes)
179
+ return nil unless attributes.is_a?(Hash)
180
+ self.class.openapi_types.each_pair do |key, type|
181
+ if attributes[self.class.attribute_map[key]].nil? && self.class.openapi_nullable.include?(key)
182
+ self.send("#{key}=", nil)
183
+ elsif type =~ /\AArray<(.*)>/i
184
+ # check to ensure the input is an array given that the attribute
185
+ # is documented as an array but the input is not
186
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
187
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
188
+ end
189
+ elsif !attributes[self.class.attribute_map[key]].nil?
190
+ self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
191
+ end
192
+ end
193
+
194
+ self
195
+ end
196
+
197
+ # Deserializes the data based on type
198
+ # @param string type Data type
199
+ # @param string value Value to be deserialized
200
+ # @return [Object] Deserialized data
201
+ def _deserialize(type, value)
202
+ case type.to_sym
203
+ when :Time
204
+ Time.parse(value)
205
+ when :Date
206
+ Date.parse(value)
207
+ when :String
208
+ value.to_s
209
+ when :Integer
210
+ value.to_i
211
+ when :Float
212
+ value.to_f
213
+ when :Boolean
214
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
215
+ true
216
+ else
217
+ false
218
+ end
219
+ when :Object
220
+ # generic object (usually a Hash), return directly
221
+ value
222
+ when /\AArray<(?<inner_type>.+)>\z/
223
+ inner_type = Regexp.last_match[:inner_type]
224
+ value.map { |v| _deserialize(inner_type, v) }
225
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
226
+ k_type = Regexp.last_match[:k_type]
227
+ v_type = Regexp.last_match[:v_type]
228
+ {}.tap do |hash|
229
+ value.each do |k, v|
230
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
231
+ end
232
+ end
233
+ else # model
234
+ # models (e.g. Pet) or oneOf
235
+ klass = BrowserupMitmProxy.const_get(type)
236
+ klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
237
+ end
238
+ end
239
+
240
+ # Returns the string representation of the object
241
+ # @return [String] String presentation of the object
242
+ def to_s
243
+ to_hash.to_s
244
+ end
245
+
246
+ # to_body is an alias to to_hash (backward compatibility)
247
+ # @return [Hash] Returns the object in the form of hash
248
+ def to_body
249
+ to_hash
250
+ end
251
+
252
+ # Returns the object in the form of hash
253
+ # @return [Hash] Returns the object in the form of hash
254
+ def to_hash
255
+ hash = {}
256
+ self.class.attribute_map.each_pair do |attr, param|
257
+ value = self.send(attr)
258
+ if value.nil?
259
+ is_nullable = self.class.openapi_nullable.include?(attr)
260
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
261
+ end
262
+
263
+ hash[param] = _to_hash(value)
264
+ end
265
+ hash
266
+ end
267
+
268
+ # Outputs non-array value in the form of hash
269
+ # For object, use to_hash. Otherwise, just return the value
270
+ # @param [Object] value Any valid value
271
+ # @return [Hash] Returns the value in the form of hash
272
+ def _to_hash(value)
273
+ if value.is_a?(Array)
274
+ value.compact.map { |v| _to_hash(v) }
275
+ elsif value.is_a?(Hash)
276
+ {}.tap do |hash|
277
+ value.each { |k, v| hash[k] = _to_hash(v) }
278
+ end
279
+ elsif value.respond_to? :to_hash
280
+ value.to_hash
281
+ else
282
+ value
283
+ end
284
+ end
285
+
286
+ end
287
+
288
+ end