backscatterio 1.0.0

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