backscatterio 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/Gemfile +7 -0
- data/LICENSE +201 -0
- data/README.md +120 -0
- data/Rakefile +8 -0
- data/backscatterio.gemspec +45 -0
- data/docs/ASNEnrichment.md +9 -0
- data/docs/ASNEnrichmentResults.md +11 -0
- data/docs/Api.md +339 -0
- data/docs/Hello.md +9 -0
- data/docs/IPEnrichment.md +9 -0
- data/docs/IPEnrichmentResults.md +25 -0
- data/docs/NetworkEnrichment.md +9 -0
- data/docs/NetworkEnrichmentResults.md +10 -0
- data/docs/Observation.md +21 -0
- data/docs/Observations.md +10 -0
- data/docs/Query.md +11 -0
- data/docs/Results.md +10 -0
- data/docs/Summary.md +15 -0
- data/docs/Trends.md +10 -0
- data/docs/Unique.md +13 -0
- data/git_push.sh +55 -0
- data/lib/backscatterio.rb +54 -0
- data/lib/backscatterio/api/default_api.rb +349 -0
- data/lib/backscatterio/api_client.rb +389 -0
- data/lib/backscatterio/api_error.rb +38 -0
- data/lib/backscatterio/configuration.rb +209 -0
- data/lib/backscatterio/models/asn_enrichment.rb +192 -0
- data/lib/backscatterio/models/asn_enrichment_results.rb +212 -0
- data/lib/backscatterio/models/hello.rb +192 -0
- data/lib/backscatterio/models/ip_enrichment.rb +192 -0
- data/lib/backscatterio/models/ip_enrichment_results.rb +336 -0
- data/lib/backscatterio/models/network_enrichment.rb +192 -0
- data/lib/backscatterio/models/network_enrichment_results.rb +203 -0
- data/lib/backscatterio/models/observation.rb +300 -0
- data/lib/backscatterio/models/observations.rb +201 -0
- data/lib/backscatterio/models/query.rb +244 -0
- data/lib/backscatterio/models/results.rb +203 -0
- data/lib/backscatterio/models/summary.rb +248 -0
- data/lib/backscatterio/models/trends.rb +201 -0
- data/lib/backscatterio/models/unique.rb +240 -0
- data/lib/backscatterio/version.rb +15 -0
- data/spec/api/default_api_spec.rb +107 -0
- data/spec/api_client_spec.rb +226 -0
- data/spec/configuration_spec.rb +42 -0
- data/spec/models/asn_enrichment_results_spec.rb +59 -0
- data/spec/models/asn_enrichment_spec.rb +47 -0
- data/spec/models/hello_spec.rb +47 -0
- data/spec/models/ip_enrichment_results_spec.rb +143 -0
- data/spec/models/ip_enrichment_spec.rb +47 -0
- data/spec/models/network_enrichment_results_spec.rb +53 -0
- data/spec/models/network_enrichment_spec.rb +47 -0
- data/spec/models/observation_spec.rb +119 -0
- data/spec/models/observations_spec.rb +53 -0
- data/spec/models/query_spec.rb +63 -0
- data/spec/models/results_spec.rb +53 -0
- data/spec/models/summary_spec.rb +83 -0
- data/spec/models/trends_spec.rb +53 -0
- data/spec/models/unique_spec.rb +71 -0
- data/spec/spec_helper.rb +111 -0
- metadata +301 -0
@@ -0,0 +1,192 @@
|
|
1
|
+
=begin
|
2
|
+
#Backscatter.io
|
3
|
+
|
4
|
+
#[This is the Backscatter.io API.](https://backscatter.io/developers)
|
5
|
+
|
6
|
+
OpenAPI spec version: 1.0.0
|
7
|
+
Contact: info@backscatter.io
|
8
|
+
Generated by: https://github.com/swagger-api/swagger-codegen.git
|
9
|
+
Swagger Codegen version: 2.4.0
|
10
|
+
|
11
|
+
=end
|
12
|
+
|
13
|
+
require 'date'
|
14
|
+
|
15
|
+
module BackscatterIO
|
16
|
+
class IPEnrichment
|
17
|
+
attr_accessor :results
|
18
|
+
|
19
|
+
attr_accessor :success
|
20
|
+
|
21
|
+
# Attribute mapping from ruby-style variable name to JSON key.
|
22
|
+
def self.attribute_map
|
23
|
+
{
|
24
|
+
:'results' => :'results',
|
25
|
+
:'success' => :'success'
|
26
|
+
}
|
27
|
+
end
|
28
|
+
|
29
|
+
# Attribute type mapping.
|
30
|
+
def self.swagger_types
|
31
|
+
{
|
32
|
+
:'results' => :'IPEnrichmentResults',
|
33
|
+
:'success' => :'BOOLEAN'
|
34
|
+
}
|
35
|
+
end
|
36
|
+
|
37
|
+
# Initializes the object
|
38
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
39
|
+
def initialize(attributes = {})
|
40
|
+
return unless attributes.is_a?(Hash)
|
41
|
+
|
42
|
+
# convert string to symbol for hash key
|
43
|
+
attributes = attributes.each_with_object({}) { |(k, v), h| h[k.to_sym] = v }
|
44
|
+
|
45
|
+
if attributes.has_key?(:'results')
|
46
|
+
self.results = attributes[:'results']
|
47
|
+
end
|
48
|
+
|
49
|
+
if attributes.has_key?(:'success')
|
50
|
+
self.success = attributes[:'success']
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
54
|
+
# Show invalid properties with the reasons. Usually used together with valid?
|
55
|
+
# @return Array for valid properties with the reasons
|
56
|
+
def list_invalid_properties
|
57
|
+
invalid_properties = Array.new
|
58
|
+
invalid_properties
|
59
|
+
end
|
60
|
+
|
61
|
+
# Check to see if the all the properties in the model are valid
|
62
|
+
# @return true if the model is valid
|
63
|
+
def valid?
|
64
|
+
true
|
65
|
+
end
|
66
|
+
|
67
|
+
# Checks equality by comparing each attribute.
|
68
|
+
# @param [Object] Object to be compared
|
69
|
+
def ==(o)
|
70
|
+
return true if self.equal?(o)
|
71
|
+
self.class == o.class &&
|
72
|
+
results == o.results &&
|
73
|
+
success == o.success
|
74
|
+
end
|
75
|
+
|
76
|
+
# @see the `==` method
|
77
|
+
# @param [Object] Object to be compared
|
78
|
+
def eql?(o)
|
79
|
+
self == o
|
80
|
+
end
|
81
|
+
|
82
|
+
# Calculates hash code according to all attributes.
|
83
|
+
# @return [Fixnum] Hash code
|
84
|
+
def hash
|
85
|
+
[results, success].hash
|
86
|
+
end
|
87
|
+
|
88
|
+
# Builds the object from hash
|
89
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
90
|
+
# @return [Object] Returns the model itself
|
91
|
+
def build_from_hash(attributes)
|
92
|
+
return nil unless attributes.is_a?(Hash)
|
93
|
+
self.class.swagger_types.each_pair do |key, type|
|
94
|
+
if type =~ /\AArray<(.*)>/i
|
95
|
+
# check to ensure the input is an array given that the the attribute
|
96
|
+
# is documented as an array but the input is not
|
97
|
+
if attributes[self.class.attribute_map[key]].is_a?(Array)
|
98
|
+
self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
|
99
|
+
end
|
100
|
+
elsif !attributes[self.class.attribute_map[key]].nil?
|
101
|
+
self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
|
102
|
+
end # or else data not found in attributes(hash), not an issue as the data can be optional
|
103
|
+
end
|
104
|
+
|
105
|
+
self
|
106
|
+
end
|
107
|
+
|
108
|
+
# Deserializes the data based on type
|
109
|
+
# @param string type Data type
|
110
|
+
# @param string value Value to be deserialized
|
111
|
+
# @return [Object] Deserialized data
|
112
|
+
def _deserialize(type, value)
|
113
|
+
case type.to_sym
|
114
|
+
when :DateTime
|
115
|
+
DateTime.parse(value)
|
116
|
+
when :Date
|
117
|
+
Date.parse(value)
|
118
|
+
when :String
|
119
|
+
value.to_s
|
120
|
+
when :Integer
|
121
|
+
value.to_i
|
122
|
+
when :Float
|
123
|
+
value.to_f
|
124
|
+
when :BOOLEAN
|
125
|
+
if value.to_s =~ /\A(true|t|yes|y|1)\z/i
|
126
|
+
true
|
127
|
+
else
|
128
|
+
false
|
129
|
+
end
|
130
|
+
when :Object
|
131
|
+
# generic object (usually a Hash), return directly
|
132
|
+
value
|
133
|
+
when /\AArray<(?<inner_type>.+)>\z/
|
134
|
+
inner_type = Regexp.last_match[:inner_type]
|
135
|
+
value.map { |v| _deserialize(inner_type, v) }
|
136
|
+
when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
|
137
|
+
k_type = Regexp.last_match[:k_type]
|
138
|
+
v_type = Regexp.last_match[:v_type]
|
139
|
+
{}.tap do |hash|
|
140
|
+
value.each do |k, v|
|
141
|
+
hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
|
142
|
+
end
|
143
|
+
end
|
144
|
+
else # model
|
145
|
+
temp_model = BackscatterIO.const_get(type).new
|
146
|
+
temp_model.build_from_hash(value)
|
147
|
+
end
|
148
|
+
end
|
149
|
+
|
150
|
+
# Returns the string representation of the object
|
151
|
+
# @return [String] String presentation of the object
|
152
|
+
def to_s
|
153
|
+
to_hash.to_s
|
154
|
+
end
|
155
|
+
|
156
|
+
# to_body is an alias to to_hash (backward compatibility)
|
157
|
+
# @return [Hash] Returns the object in the form of hash
|
158
|
+
def to_body
|
159
|
+
to_hash
|
160
|
+
end
|
161
|
+
|
162
|
+
# Returns the object in the form of hash
|
163
|
+
# @return [Hash] Returns the object in the form of hash
|
164
|
+
def to_hash
|
165
|
+
hash = {}
|
166
|
+
self.class.attribute_map.each_pair do |attr, param|
|
167
|
+
value = self.send(attr)
|
168
|
+
next if value.nil?
|
169
|
+
hash[param] = _to_hash(value)
|
170
|
+
end
|
171
|
+
hash
|
172
|
+
end
|
173
|
+
|
174
|
+
# Outputs non-array value in the form of hash
|
175
|
+
# For object, use to_hash. Otherwise, just return the value
|
176
|
+
# @param [Object] value Any valid value
|
177
|
+
# @return [Hash] Returns the value in the form of hash
|
178
|
+
def _to_hash(value)
|
179
|
+
if value.is_a?(Array)
|
180
|
+
value.compact.map { |v| _to_hash(v) }
|
181
|
+
elsif value.is_a?(Hash)
|
182
|
+
{}.tap do |hash|
|
183
|
+
value.each { |k, v| hash[k] = _to_hash(v) }
|
184
|
+
end
|
185
|
+
elsif value.respond_to? :to_hash
|
186
|
+
value.to_hash
|
187
|
+
else
|
188
|
+
value
|
189
|
+
end
|
190
|
+
end
|
191
|
+
end
|
192
|
+
end
|
@@ -0,0 +1,336 @@
|
|
1
|
+
=begin
|
2
|
+
#Backscatter.io
|
3
|
+
|
4
|
+
#[This is the Backscatter.io API.](https://backscatter.io/developers)
|
5
|
+
|
6
|
+
OpenAPI spec version: 1.0.0
|
7
|
+
Contact: info@backscatter.io
|
8
|
+
Generated by: https://github.com/swagger-api/swagger-codegen.git
|
9
|
+
Swagger Codegen version: 2.4.0
|
10
|
+
|
11
|
+
=end
|
12
|
+
|
13
|
+
require 'date'
|
14
|
+
|
15
|
+
module BackscatterIO
|
16
|
+
class IPEnrichmentResults
|
17
|
+
attr_accessor :as_name
|
18
|
+
|
19
|
+
attr_accessor :as_num
|
20
|
+
|
21
|
+
attr_accessor :city
|
22
|
+
|
23
|
+
attr_accessor :country_iso
|
24
|
+
|
25
|
+
attr_accessor :country_name
|
26
|
+
|
27
|
+
attr_accessor :ip
|
28
|
+
|
29
|
+
attr_accessor :ip_hex
|
30
|
+
|
31
|
+
attr_accessor :ip_version
|
32
|
+
|
33
|
+
attr_accessor :latitude
|
34
|
+
|
35
|
+
attr_accessor :longitude
|
36
|
+
|
37
|
+
attr_accessor :network
|
38
|
+
|
39
|
+
attr_accessor :network_broadcast
|
40
|
+
|
41
|
+
attr_accessor :network_hostmask
|
42
|
+
|
43
|
+
attr_accessor :network_netmask
|
44
|
+
|
45
|
+
attr_accessor :network_size
|
46
|
+
|
47
|
+
attr_accessor :postal_code
|
48
|
+
|
49
|
+
attr_accessor :region_iso
|
50
|
+
|
51
|
+
attr_accessor :region_name
|
52
|
+
|
53
|
+
# Attribute mapping from ruby-style variable name to JSON key.
|
54
|
+
def self.attribute_map
|
55
|
+
{
|
56
|
+
:'as_name' => :'as_name',
|
57
|
+
:'as_num' => :'as_num',
|
58
|
+
:'city' => :'city',
|
59
|
+
:'country_iso' => :'country_iso',
|
60
|
+
:'country_name' => :'country_name',
|
61
|
+
:'ip' => :'ip',
|
62
|
+
:'ip_hex' => :'ip_hex',
|
63
|
+
:'ip_version' => :'ip_version',
|
64
|
+
:'latitude' => :'latitude',
|
65
|
+
:'longitude' => :'longitude',
|
66
|
+
:'network' => :'network',
|
67
|
+
:'network_broadcast' => :'network_broadcast',
|
68
|
+
:'network_hostmask' => :'network_hostmask',
|
69
|
+
:'network_netmask' => :'network_netmask',
|
70
|
+
:'network_size' => :'network_size',
|
71
|
+
:'postal_code' => :'postal_code',
|
72
|
+
:'region_iso' => :'region_iso',
|
73
|
+
:'region_name' => :'region_name'
|
74
|
+
}
|
75
|
+
end
|
76
|
+
|
77
|
+
# Attribute type mapping.
|
78
|
+
def self.swagger_types
|
79
|
+
{
|
80
|
+
:'as_name' => :'String',
|
81
|
+
:'as_num' => :'Integer',
|
82
|
+
:'city' => :'String',
|
83
|
+
:'country_iso' => :'String',
|
84
|
+
:'country_name' => :'String',
|
85
|
+
:'ip' => :'String',
|
86
|
+
:'ip_hex' => :'String',
|
87
|
+
:'ip_version' => :'Integer',
|
88
|
+
:'latitude' => :'Float',
|
89
|
+
:'longitude' => :'Float',
|
90
|
+
:'network' => :'String',
|
91
|
+
:'network_broadcast' => :'String',
|
92
|
+
:'network_hostmask' => :'String',
|
93
|
+
:'network_netmask' => :'String',
|
94
|
+
:'network_size' => :'Integer',
|
95
|
+
:'postal_code' => :'String',
|
96
|
+
:'region_iso' => :'String',
|
97
|
+
:'region_name' => :'String'
|
98
|
+
}
|
99
|
+
end
|
100
|
+
|
101
|
+
# Initializes the object
|
102
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
103
|
+
def initialize(attributes = {})
|
104
|
+
return unless attributes.is_a?(Hash)
|
105
|
+
|
106
|
+
# convert string to symbol for hash key
|
107
|
+
attributes = attributes.each_with_object({}) { |(k, v), h| h[k.to_sym] = v }
|
108
|
+
|
109
|
+
if attributes.has_key?(:'as_name')
|
110
|
+
self.as_name = attributes[:'as_name']
|
111
|
+
end
|
112
|
+
|
113
|
+
if attributes.has_key?(:'as_num')
|
114
|
+
self.as_num = attributes[:'as_num']
|
115
|
+
end
|
116
|
+
|
117
|
+
if attributes.has_key?(:'city')
|
118
|
+
self.city = attributes[:'city']
|
119
|
+
end
|
120
|
+
|
121
|
+
if attributes.has_key?(:'country_iso')
|
122
|
+
self.country_iso = attributes[:'country_iso']
|
123
|
+
end
|
124
|
+
|
125
|
+
if attributes.has_key?(:'country_name')
|
126
|
+
self.country_name = attributes[:'country_name']
|
127
|
+
end
|
128
|
+
|
129
|
+
if attributes.has_key?(:'ip')
|
130
|
+
self.ip = attributes[:'ip']
|
131
|
+
end
|
132
|
+
|
133
|
+
if attributes.has_key?(:'ip_hex')
|
134
|
+
self.ip_hex = attributes[:'ip_hex']
|
135
|
+
end
|
136
|
+
|
137
|
+
if attributes.has_key?(:'ip_version')
|
138
|
+
self.ip_version = attributes[:'ip_version']
|
139
|
+
end
|
140
|
+
|
141
|
+
if attributes.has_key?(:'latitude')
|
142
|
+
self.latitude = attributes[:'latitude']
|
143
|
+
end
|
144
|
+
|
145
|
+
if attributes.has_key?(:'longitude')
|
146
|
+
self.longitude = attributes[:'longitude']
|
147
|
+
end
|
148
|
+
|
149
|
+
if attributes.has_key?(:'network')
|
150
|
+
self.network = attributes[:'network']
|
151
|
+
end
|
152
|
+
|
153
|
+
if attributes.has_key?(:'network_broadcast')
|
154
|
+
self.network_broadcast = attributes[:'network_broadcast']
|
155
|
+
end
|
156
|
+
|
157
|
+
if attributes.has_key?(:'network_hostmask')
|
158
|
+
self.network_hostmask = attributes[:'network_hostmask']
|
159
|
+
end
|
160
|
+
|
161
|
+
if attributes.has_key?(:'network_netmask')
|
162
|
+
self.network_netmask = attributes[:'network_netmask']
|
163
|
+
end
|
164
|
+
|
165
|
+
if attributes.has_key?(:'network_size')
|
166
|
+
self.network_size = attributes[:'network_size']
|
167
|
+
end
|
168
|
+
|
169
|
+
if attributes.has_key?(:'postal_code')
|
170
|
+
self.postal_code = attributes[:'postal_code']
|
171
|
+
end
|
172
|
+
|
173
|
+
if attributes.has_key?(:'region_iso')
|
174
|
+
self.region_iso = attributes[:'region_iso']
|
175
|
+
end
|
176
|
+
|
177
|
+
if attributes.has_key?(:'region_name')
|
178
|
+
self.region_name = attributes[:'region_name']
|
179
|
+
end
|
180
|
+
end
|
181
|
+
|
182
|
+
# Show invalid properties with the reasons. Usually used together with valid?
|
183
|
+
# @return Array for valid properties with the reasons
|
184
|
+
def list_invalid_properties
|
185
|
+
invalid_properties = Array.new
|
186
|
+
invalid_properties
|
187
|
+
end
|
188
|
+
|
189
|
+
# Check to see if the all the properties in the model are valid
|
190
|
+
# @return true if the model is valid
|
191
|
+
def valid?
|
192
|
+
true
|
193
|
+
end
|
194
|
+
|
195
|
+
# Checks equality by comparing each attribute.
|
196
|
+
# @param [Object] Object to be compared
|
197
|
+
def ==(o)
|
198
|
+
return true if self.equal?(o)
|
199
|
+
self.class == o.class &&
|
200
|
+
as_name == o.as_name &&
|
201
|
+
as_num == o.as_num &&
|
202
|
+
city == o.city &&
|
203
|
+
country_iso == o.country_iso &&
|
204
|
+
country_name == o.country_name &&
|
205
|
+
ip == o.ip &&
|
206
|
+
ip_hex == o.ip_hex &&
|
207
|
+
ip_version == o.ip_version &&
|
208
|
+
latitude == o.latitude &&
|
209
|
+
longitude == o.longitude &&
|
210
|
+
network == o.network &&
|
211
|
+
network_broadcast == o.network_broadcast &&
|
212
|
+
network_hostmask == o.network_hostmask &&
|
213
|
+
network_netmask == o.network_netmask &&
|
214
|
+
network_size == o.network_size &&
|
215
|
+
postal_code == o.postal_code &&
|
216
|
+
region_iso == o.region_iso &&
|
217
|
+
region_name == o.region_name
|
218
|
+
end
|
219
|
+
|
220
|
+
# @see the `==` method
|
221
|
+
# @param [Object] Object to be compared
|
222
|
+
def eql?(o)
|
223
|
+
self == o
|
224
|
+
end
|
225
|
+
|
226
|
+
# Calculates hash code according to all attributes.
|
227
|
+
# @return [Fixnum] Hash code
|
228
|
+
def hash
|
229
|
+
[as_name, as_num, city, country_iso, country_name, ip, ip_hex, ip_version, latitude, longitude, network, network_broadcast, network_hostmask, network_netmask, network_size, postal_code, region_iso, region_name].hash
|
230
|
+
end
|
231
|
+
|
232
|
+
# Builds the object from hash
|
233
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
234
|
+
# @return [Object] Returns the model itself
|
235
|
+
def build_from_hash(attributes)
|
236
|
+
return nil unless attributes.is_a?(Hash)
|
237
|
+
self.class.swagger_types.each_pair do |key, type|
|
238
|
+
if type =~ /\AArray<(.*)>/i
|
239
|
+
# check to ensure the input is an array given that the the attribute
|
240
|
+
# is documented as an array but the input is not
|
241
|
+
if attributes[self.class.attribute_map[key]].is_a?(Array)
|
242
|
+
self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
|
243
|
+
end
|
244
|
+
elsif !attributes[self.class.attribute_map[key]].nil?
|
245
|
+
self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
|
246
|
+
end # or else data not found in attributes(hash), not an issue as the data can be optional
|
247
|
+
end
|
248
|
+
|
249
|
+
self
|
250
|
+
end
|
251
|
+
|
252
|
+
# Deserializes the data based on type
|
253
|
+
# @param string type Data type
|
254
|
+
# @param string value Value to be deserialized
|
255
|
+
# @return [Object] Deserialized data
|
256
|
+
def _deserialize(type, value)
|
257
|
+
case type.to_sym
|
258
|
+
when :DateTime
|
259
|
+
DateTime.parse(value)
|
260
|
+
when :Date
|
261
|
+
Date.parse(value)
|
262
|
+
when :String
|
263
|
+
value.to_s
|
264
|
+
when :Integer
|
265
|
+
value.to_i
|
266
|
+
when :Float
|
267
|
+
value.to_f
|
268
|
+
when :BOOLEAN
|
269
|
+
if value.to_s =~ /\A(true|t|yes|y|1)\z/i
|
270
|
+
true
|
271
|
+
else
|
272
|
+
false
|
273
|
+
end
|
274
|
+
when :Object
|
275
|
+
# generic object (usually a Hash), return directly
|
276
|
+
value
|
277
|
+
when /\AArray<(?<inner_type>.+)>\z/
|
278
|
+
inner_type = Regexp.last_match[:inner_type]
|
279
|
+
value.map { |v| _deserialize(inner_type, v) }
|
280
|
+
when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
|
281
|
+
k_type = Regexp.last_match[:k_type]
|
282
|
+
v_type = Regexp.last_match[:v_type]
|
283
|
+
{}.tap do |hash|
|
284
|
+
value.each do |k, v|
|
285
|
+
hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
|
286
|
+
end
|
287
|
+
end
|
288
|
+
else # model
|
289
|
+
temp_model = BackscatterIO.const_get(type).new
|
290
|
+
temp_model.build_from_hash(value)
|
291
|
+
end
|
292
|
+
end
|
293
|
+
|
294
|
+
# Returns the string representation of the object
|
295
|
+
# @return [String] String presentation of the object
|
296
|
+
def to_s
|
297
|
+
to_hash.to_s
|
298
|
+
end
|
299
|
+
|
300
|
+
# to_body is an alias to to_hash (backward compatibility)
|
301
|
+
# @return [Hash] Returns the object in the form of hash
|
302
|
+
def to_body
|
303
|
+
to_hash
|
304
|
+
end
|
305
|
+
|
306
|
+
# Returns the object in the form of hash
|
307
|
+
# @return [Hash] Returns the object in the form of hash
|
308
|
+
def to_hash
|
309
|
+
hash = {}
|
310
|
+
self.class.attribute_map.each_pair do |attr, param|
|
311
|
+
value = self.send(attr)
|
312
|
+
next if value.nil?
|
313
|
+
hash[param] = _to_hash(value)
|
314
|
+
end
|
315
|
+
hash
|
316
|
+
end
|
317
|
+
|
318
|
+
# Outputs non-array value in the form of hash
|
319
|
+
# For object, use to_hash. Otherwise, just return the value
|
320
|
+
# @param [Object] value Any valid value
|
321
|
+
# @return [Hash] Returns the value in the form of hash
|
322
|
+
def _to_hash(value)
|
323
|
+
if value.is_a?(Array)
|
324
|
+
value.compact.map { |v| _to_hash(v) }
|
325
|
+
elsif value.is_a?(Hash)
|
326
|
+
{}.tap do |hash|
|
327
|
+
value.each { |k, v| hash[k] = _to_hash(v) }
|
328
|
+
end
|
329
|
+
elsif value.respond_to? :to_hash
|
330
|
+
value.to_hash
|
331
|
+
else
|
332
|
+
value
|
333
|
+
end
|
334
|
+
end
|
335
|
+
end
|
336
|
+
end
|