trakerr_client 1.0.0r

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 (53) hide show
  1. data/.gitignore +5 -0
  2. data/README.md +148 -0
  3. data/generated/.gitignore +50 -0
  4. data/generated/.rspec +2 -0
  5. data/generated/.swagger-codegen-ignore +23 -0
  6. data/generated/LICENSE +201 -0
  7. data/generated/README.md +97 -0
  8. data/generated/docs/AppEvent.md +30 -0
  9. data/generated/docs/CustomData.md +9 -0
  10. data/generated/docs/CustomDoubleData.md +17 -0
  11. data/generated/docs/CustomStringData.md +17 -0
  12. data/generated/docs/Error.md +10 -0
  13. data/generated/docs/EventsApi.md +55 -0
  14. data/generated/docs/InnerStackTrace.md +10 -0
  15. data/generated/docs/StackTraceLine.md +10 -0
  16. data/generated/docs/StackTraceLines.md +7 -0
  17. data/generated/docs/Stacktrace.md +7 -0
  18. data/generated/git_push.sh +67 -0
  19. data/generated/lib/trakerr_client/api/events_api.rb +90 -0
  20. data/generated/lib/trakerr_client/api_client.rb +378 -0
  21. data/generated/lib/trakerr_client/api_error.rb +47 -0
  22. data/generated/lib/trakerr_client/configuration.rb +207 -0
  23. data/generated/lib/trakerr_client/models/app_event.rb +454 -0
  24. data/generated/lib/trakerr_client/models/custom_data.rb +208 -0
  25. data/generated/lib/trakerr_client/models/custom_double_data.rb +280 -0
  26. data/generated/lib/trakerr_client/models/custom_string_data.rb +280 -0
  27. data/generated/lib/trakerr_client/models/error.rb +217 -0
  28. data/generated/lib/trakerr_client/models/inner_stack_trace.rb +217 -0
  29. data/generated/lib/trakerr_client/models/stack_trace_line.rb +217 -0
  30. data/generated/lib/trakerr_client/models/stack_trace_lines.rb +190 -0
  31. data/generated/lib/trakerr_client/models/stacktrace.rb +190 -0
  32. data/generated/lib/trakerr_client/version.rb +26 -0
  33. data/generated/lib/trakerr_client.rb +60 -0
  34. data/generated/spec/api/events_api_spec.rb +58 -0
  35. data/generated/spec/api_client_spec.rb +237 -0
  36. data/generated/spec/configuration_spec.rb +53 -0
  37. data/generated/spec/models/app_event_spec.rb +167 -0
  38. data/generated/spec/models/custom_data_spec.rb +59 -0
  39. data/generated/spec/models/custom_double_data_spec.rb +107 -0
  40. data/generated/spec/models/custom_string_data_spec.rb +107 -0
  41. data/generated/spec/models/error_spec.rb +65 -0
  42. data/generated/spec/models/inner_stack_trace_spec.rb +65 -0
  43. data/generated/spec/models/stack_trace_line_spec.rb +65 -0
  44. data/generated/spec/models/stack_trace_lines_spec.rb +47 -0
  45. data/generated/spec/models/stacktrace_spec.rb +47 -0
  46. data/generated/spec/spec_helper.rb +122 -0
  47. data/generated/trakerr_client.gemspec +55 -0
  48. data/mkgem.sh +6 -0
  49. data/test_app.rb +40 -0
  50. data/trakerr/lib/event_trace_builder.rb +163 -0
  51. data/trakerr/lib/trakerr.rb +235 -0
  52. data/trakerr_client.gemspec +58 -0
  53. metadata +313 -0
@@ -0,0 +1,280 @@
1
+ =begin
2
+ #Trakerr API
3
+
4
+ #Get your application events and errors to Trakerr via the *Trakerr API*.
5
+
6
+ OpenAPI spec version: 1.0.0
7
+
8
+ Generated by: https://github.com/swagger-api/swagger-codegen.git
9
+
10
+ Licensed under the Apache License, Version 2.0 (the "License");
11
+ you may not use this file except in compliance with the License.
12
+ You may obtain a copy of the License at
13
+
14
+ http://www.apache.org/licenses/LICENSE-2.0
15
+
16
+ Unless required by applicable law or agreed to in writing, software
17
+ distributed under the License is distributed on an "AS IS" BASIS,
18
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
19
+ See the License for the specific language governing permissions and
20
+ limitations under the License.
21
+
22
+ =end
23
+
24
+ require 'date'
25
+
26
+ module Trakerr
27
+
28
+ class CustomStringData
29
+ attr_accessor :custom_data1
30
+
31
+ attr_accessor :custom_data2
32
+
33
+ attr_accessor :custom_data3
34
+
35
+ attr_accessor :custom_data4
36
+
37
+ attr_accessor :custom_data5
38
+
39
+ attr_accessor :custom_data6
40
+
41
+ attr_accessor :custom_data7
42
+
43
+ attr_accessor :custom_data8
44
+
45
+ attr_accessor :custom_data9
46
+
47
+ attr_accessor :custom_data10
48
+
49
+
50
+ # Attribute mapping from ruby-style variable name to JSON key.
51
+ def self.attribute_map
52
+ {
53
+ :'custom_data1' => :'customData1',
54
+ :'custom_data2' => :'customData2',
55
+ :'custom_data3' => :'customData3',
56
+ :'custom_data4' => :'customData4',
57
+ :'custom_data5' => :'customData5',
58
+ :'custom_data6' => :'customData6',
59
+ :'custom_data7' => :'customData7',
60
+ :'custom_data8' => :'customData8',
61
+ :'custom_data9' => :'customData9',
62
+ :'custom_data10' => :'customData10'
63
+ }
64
+ end
65
+
66
+ # Attribute type mapping.
67
+ def self.swagger_types
68
+ {
69
+ :'custom_data1' => :'String',
70
+ :'custom_data2' => :'String',
71
+ :'custom_data3' => :'String',
72
+ :'custom_data4' => :'String',
73
+ :'custom_data5' => :'String',
74
+ :'custom_data6' => :'String',
75
+ :'custom_data7' => :'String',
76
+ :'custom_data8' => :'String',
77
+ :'custom_data9' => :'String',
78
+ :'custom_data10' => :'String'
79
+ }
80
+ end
81
+
82
+ # Initializes the object
83
+ # @param [Hash] attributes Model attributes in the form of hash
84
+ def initialize(attributes = {})
85
+ return unless attributes.is_a?(Hash)
86
+
87
+ # convert string to symbol for hash key
88
+ attributes = attributes.each_with_object({}){|(k,v), h| h[k.to_sym] = v}
89
+
90
+ if attributes.has_key?(:'customData1')
91
+ self.custom_data1 = attributes[:'customData1']
92
+ end
93
+
94
+ if attributes.has_key?(:'customData2')
95
+ self.custom_data2 = attributes[:'customData2']
96
+ end
97
+
98
+ if attributes.has_key?(:'customData3')
99
+ self.custom_data3 = attributes[:'customData3']
100
+ end
101
+
102
+ if attributes.has_key?(:'customData4')
103
+ self.custom_data4 = attributes[:'customData4']
104
+ end
105
+
106
+ if attributes.has_key?(:'customData5')
107
+ self.custom_data5 = attributes[:'customData5']
108
+ end
109
+
110
+ if attributes.has_key?(:'customData6')
111
+ self.custom_data6 = attributes[:'customData6']
112
+ end
113
+
114
+ if attributes.has_key?(:'customData7')
115
+ self.custom_data7 = attributes[:'customData7']
116
+ end
117
+
118
+ if attributes.has_key?(:'customData8')
119
+ self.custom_data8 = attributes[:'customData8']
120
+ end
121
+
122
+ if attributes.has_key?(:'customData9')
123
+ self.custom_data9 = attributes[:'customData9']
124
+ end
125
+
126
+ if attributes.has_key?(:'customData10')
127
+ self.custom_data10 = attributes[:'customData10']
128
+ end
129
+
130
+ end
131
+
132
+ # Show invalid properties with the reasons. Usually used together with valid?
133
+ # @return Array for valid properies with the reasons
134
+ def list_invalid_properties
135
+ invalid_properties = Array.new
136
+ return 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 true
143
+ end
144
+
145
+ # Checks equality by comparing each attribute.
146
+ # @param [Object] Object to be compared
147
+ def ==(o)
148
+ return true if self.equal?(o)
149
+ self.class == o.class &&
150
+ custom_data1 == o.custom_data1 &&
151
+ custom_data2 == o.custom_data2 &&
152
+ custom_data3 == o.custom_data3 &&
153
+ custom_data4 == o.custom_data4 &&
154
+ custom_data5 == o.custom_data5 &&
155
+ custom_data6 == o.custom_data6 &&
156
+ custom_data7 == o.custom_data7 &&
157
+ custom_data8 == o.custom_data8 &&
158
+ custom_data9 == o.custom_data9 &&
159
+ custom_data10 == o.custom_data10
160
+ end
161
+
162
+ # @see the `==` method
163
+ # @param [Object] Object to be compared
164
+ def eql?(o)
165
+ self == o
166
+ end
167
+
168
+ # Calculates hash code according to all attributes.
169
+ # @return [Fixnum] Hash code
170
+ def hash
171
+ [custom_data1, custom_data2, custom_data3, custom_data4, custom_data5, custom_data6, custom_data7, custom_data8, custom_data9, custom_data10].hash
172
+ end
173
+
174
+ # Builds the object from hash
175
+ # @param [Hash] attributes Model attributes in the form of hash
176
+ # @return [Object] Returns the model itself
177
+ def build_from_hash(attributes)
178
+ return nil unless attributes.is_a?(Hash)
179
+ self.class.swagger_types.each_pair do |key, type|
180
+ if type =~ /^Array<(.*)>/i
181
+ # check to ensure the input is an array given that the the attribute
182
+ # is documented as an array but the input is not
183
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
184
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map{ |v| _deserialize($1, v) } )
185
+ end
186
+ elsif !attributes[self.class.attribute_map[key]].nil?
187
+ self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
188
+ end # or else data not found in attributes(hash), not an issue as the data can be optional
189
+ end
190
+
191
+ self
192
+ end
193
+
194
+ # Deserializes the data based on type
195
+ # @param string type Data type
196
+ # @param string value Value to be deserialized
197
+ # @return [Object] Deserialized data
198
+ def _deserialize(type, value)
199
+ case type.to_sym
200
+ when :DateTime
201
+ DateTime.parse(value)
202
+ when :Date
203
+ Date.parse(value)
204
+ when :String
205
+ value.to_s
206
+ when :Integer
207
+ value.to_i
208
+ when :Float
209
+ value.to_f
210
+ when :BOOLEAN
211
+ if value.to_s =~ /^(true|t|yes|y|1)$/i
212
+ true
213
+ else
214
+ false
215
+ end
216
+ when :Object
217
+ # generic object (usually a Hash), return directly
218
+ value
219
+ when /\AArray<(?<inner_type>.+)>\z/
220
+ inner_type = Regexp.last_match[:inner_type]
221
+ value.map { |v| _deserialize(inner_type, v) }
222
+ when /\AHash<(?<k_type>.+), (?<v_type>.+)>\z/
223
+ k_type = Regexp.last_match[:k_type]
224
+ v_type = Regexp.last_match[:v_type]
225
+ {}.tap do |hash|
226
+ value.each do |k, v|
227
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
228
+ end
229
+ end
230
+ else # model
231
+ temp_model = Trakerr.const_get(type).new
232
+ temp_model.build_from_hash(value)
233
+ end
234
+ end
235
+
236
+ # Returns the string representation of the object
237
+ # @return [String] String presentation of the object
238
+ def to_s
239
+ to_hash.to_s
240
+ end
241
+
242
+ # to_body is an alias to to_hash (backward compatibility)
243
+ # @return [Hash] Returns the object in the form of hash
244
+ def to_body
245
+ to_hash
246
+ end
247
+
248
+ # Returns the object in the form of hash
249
+ # @return [Hash] Returns the object in the form of hash
250
+ def to_hash
251
+ hash = {}
252
+ self.class.attribute_map.each_pair do |attr, param|
253
+ value = self.send(attr)
254
+ next if value.nil?
255
+ hash[param] = _to_hash(value)
256
+ end
257
+ hash
258
+ end
259
+
260
+ # Outputs non-array value in the form of hash
261
+ # For object, use to_hash. Otherwise, just return the value
262
+ # @param [Object] value Any valid value
263
+ # @return [Hash] Returns the value in the form of hash
264
+ def _to_hash(value)
265
+ if value.is_a?(Array)
266
+ value.compact.map{ |v| _to_hash(v) }
267
+ elsif value.is_a?(Hash)
268
+ {}.tap do |hash|
269
+ value.each { |k, v| hash[k] = _to_hash(v) }
270
+ end
271
+ elsif value.respond_to? :to_hash
272
+ value.to_hash
273
+ else
274
+ value
275
+ end
276
+ end
277
+
278
+ end
279
+
280
+ end
@@ -0,0 +1,217 @@
1
+ =begin
2
+ #Trakerr API
3
+
4
+ #Get your application events and errors to Trakerr via the *Trakerr API*.
5
+
6
+ OpenAPI spec version: 1.0.0
7
+
8
+ Generated by: https://github.com/swagger-api/swagger-codegen.git
9
+
10
+ Licensed under the Apache License, Version 2.0 (the "License");
11
+ you may not use this file except in compliance with the License.
12
+ You may obtain a copy of the License at
13
+
14
+ http://www.apache.org/licenses/LICENSE-2.0
15
+
16
+ Unless required by applicable law or agreed to in writing, software
17
+ distributed under the License is distributed on an "AS IS" BASIS,
18
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
19
+ See the License for the specific language governing permissions and
20
+ limitations under the License.
21
+
22
+ =end
23
+
24
+ require 'date'
25
+
26
+ module Trakerr
27
+
28
+ class Error
29
+ attr_accessor :code
30
+
31
+ attr_accessor :message
32
+
33
+ attr_accessor :fields
34
+
35
+
36
+ # Attribute mapping from ruby-style variable name to JSON key.
37
+ def self.attribute_map
38
+ {
39
+ :'code' => :'code',
40
+ :'message' => :'message',
41
+ :'fields' => :'fields'
42
+ }
43
+ end
44
+
45
+ # Attribute type mapping.
46
+ def self.swagger_types
47
+ {
48
+ :'code' => :'Integer',
49
+ :'message' => :'String',
50
+ :'fields' => :'String'
51
+ }
52
+ end
53
+
54
+ # Initializes the object
55
+ # @param [Hash] attributes Model attributes in the form of hash
56
+ def initialize(attributes = {})
57
+ return unless attributes.is_a?(Hash)
58
+
59
+ # convert string to symbol for hash key
60
+ attributes = attributes.each_with_object({}){|(k,v), h| h[k.to_sym] = v}
61
+
62
+ if attributes.has_key?(:'code')
63
+ self.code = attributes[:'code']
64
+ end
65
+
66
+ if attributes.has_key?(:'message')
67
+ self.message = attributes[:'message']
68
+ end
69
+
70
+ if attributes.has_key?(:'fields')
71
+ self.fields = attributes[:'fields']
72
+ end
73
+
74
+ end
75
+
76
+ # Show invalid properties with the reasons. Usually used together with valid?
77
+ # @return Array for valid properies with the reasons
78
+ def list_invalid_properties
79
+ invalid_properties = Array.new
80
+ return invalid_properties
81
+ end
82
+
83
+ # Check to see if the all the properties in the model are valid
84
+ # @return true if the model is valid
85
+ def valid?
86
+ return true
87
+ end
88
+
89
+ # Checks equality by comparing each attribute.
90
+ # @param [Object] Object to be compared
91
+ def ==(o)
92
+ return true if self.equal?(o)
93
+ self.class == o.class &&
94
+ code == o.code &&
95
+ message == o.message &&
96
+ fields == o.fields
97
+ end
98
+
99
+ # @see the `==` method
100
+ # @param [Object] Object to be compared
101
+ def eql?(o)
102
+ self == o
103
+ end
104
+
105
+ # Calculates hash code according to all attributes.
106
+ # @return [Fixnum] Hash code
107
+ def hash
108
+ [code, message, fields].hash
109
+ end
110
+
111
+ # Builds the object from hash
112
+ # @param [Hash] attributes Model attributes in the form of hash
113
+ # @return [Object] Returns the model itself
114
+ def build_from_hash(attributes)
115
+ return nil unless attributes.is_a?(Hash)
116
+ self.class.swagger_types.each_pair do |key, type|
117
+ if type =~ /^Array<(.*)>/i
118
+ # check to ensure the input is an array given that the the attribute
119
+ # is documented as an array but the input is not
120
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
121
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map{ |v| _deserialize($1, v) } )
122
+ end
123
+ elsif !attributes[self.class.attribute_map[key]].nil?
124
+ self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
125
+ end # or else data not found in attributes(hash), not an issue as the data can be optional
126
+ end
127
+
128
+ self
129
+ end
130
+
131
+ # Deserializes the data based on type
132
+ # @param string type Data type
133
+ # @param string value Value to be deserialized
134
+ # @return [Object] Deserialized data
135
+ def _deserialize(type, value)
136
+ case type.to_sym
137
+ when :DateTime
138
+ DateTime.parse(value)
139
+ when :Date
140
+ Date.parse(value)
141
+ when :String
142
+ value.to_s
143
+ when :Integer
144
+ value.to_i
145
+ when :Float
146
+ value.to_f
147
+ when :BOOLEAN
148
+ if value.to_s =~ /^(true|t|yes|y|1)$/i
149
+ true
150
+ else
151
+ false
152
+ end
153
+ when :Object
154
+ # generic object (usually a Hash), return directly
155
+ value
156
+ when /\AArray<(?<inner_type>.+)>\z/
157
+ inner_type = Regexp.last_match[:inner_type]
158
+ value.map { |v| _deserialize(inner_type, v) }
159
+ when /\AHash<(?<k_type>.+), (?<v_type>.+)>\z/
160
+ k_type = Regexp.last_match[:k_type]
161
+ v_type = Regexp.last_match[:v_type]
162
+ {}.tap do |hash|
163
+ value.each do |k, v|
164
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
165
+ end
166
+ end
167
+ else # model
168
+ temp_model = Trakerr.const_get(type).new
169
+ temp_model.build_from_hash(value)
170
+ end
171
+ end
172
+
173
+ # Returns the string representation of the object
174
+ # @return [String] String presentation of the object
175
+ def to_s
176
+ to_hash.to_s
177
+ end
178
+
179
+ # to_body is an alias to to_hash (backward compatibility)
180
+ # @return [Hash] Returns the object in the form of hash
181
+ def to_body
182
+ to_hash
183
+ end
184
+
185
+ # Returns the object in the form of hash
186
+ # @return [Hash] Returns the object in the form of hash
187
+ def to_hash
188
+ hash = {}
189
+ self.class.attribute_map.each_pair do |attr, param|
190
+ value = self.send(attr)
191
+ next if value.nil?
192
+ hash[param] = _to_hash(value)
193
+ end
194
+ hash
195
+ end
196
+
197
+ # Outputs non-array value in the form of hash
198
+ # For object, use to_hash. Otherwise, just return the value
199
+ # @param [Object] value Any valid value
200
+ # @return [Hash] Returns the value in the form of hash
201
+ def _to_hash(value)
202
+ if value.is_a?(Array)
203
+ value.compact.map{ |v| _to_hash(v) }
204
+ elsif value.is_a?(Hash)
205
+ {}.tap do |hash|
206
+ value.each { |k, v| hash[k] = _to_hash(v) }
207
+ end
208
+ elsif value.respond_to? :to_hash
209
+ value.to_hash
210
+ else
211
+ value
212
+ end
213
+ end
214
+
215
+ end
216
+
217
+ end
@@ -0,0 +1,217 @@
1
+ =begin
2
+ #Trakerr API
3
+
4
+ #Get your application events and errors to Trakerr via the *Trakerr API*.
5
+
6
+ OpenAPI spec version: 1.0.0
7
+
8
+ Generated by: https://github.com/swagger-api/swagger-codegen.git
9
+
10
+ Licensed under the Apache License, Version 2.0 (the "License");
11
+ you may not use this file except in compliance with the License.
12
+ You may obtain a copy of the License at
13
+
14
+ http://www.apache.org/licenses/LICENSE-2.0
15
+
16
+ Unless required by applicable law or agreed to in writing, software
17
+ distributed under the License is distributed on an "AS IS" BASIS,
18
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
19
+ See the License for the specific language governing permissions and
20
+ limitations under the License.
21
+
22
+ =end
23
+
24
+ require 'date'
25
+
26
+ module Trakerr
27
+
28
+ class InnerStackTrace
29
+ attr_accessor :type
30
+
31
+ attr_accessor :message
32
+
33
+ attr_accessor :trace_lines
34
+
35
+
36
+ # Attribute mapping from ruby-style variable name to JSON key.
37
+ def self.attribute_map
38
+ {
39
+ :'type' => :'type',
40
+ :'message' => :'message',
41
+ :'trace_lines' => :'traceLines'
42
+ }
43
+ end
44
+
45
+ # Attribute type mapping.
46
+ def self.swagger_types
47
+ {
48
+ :'type' => :'String',
49
+ :'message' => :'String',
50
+ :'trace_lines' => :'StackTraceLines'
51
+ }
52
+ end
53
+
54
+ # Initializes the object
55
+ # @param [Hash] attributes Model attributes in the form of hash
56
+ def initialize(attributes = {})
57
+ return unless attributes.is_a?(Hash)
58
+
59
+ # convert string to symbol for hash key
60
+ attributes = attributes.each_with_object({}){|(k,v), h| h[k.to_sym] = v}
61
+
62
+ if attributes.has_key?(:'type')
63
+ self.type = attributes[:'type']
64
+ end
65
+
66
+ if attributes.has_key?(:'message')
67
+ self.message = attributes[:'message']
68
+ end
69
+
70
+ if attributes.has_key?(:'traceLines')
71
+ self.trace_lines = attributes[:'traceLines']
72
+ end
73
+
74
+ end
75
+
76
+ # Show invalid properties with the reasons. Usually used together with valid?
77
+ # @return Array for valid properies with the reasons
78
+ def list_invalid_properties
79
+ invalid_properties = Array.new
80
+ return invalid_properties
81
+ end
82
+
83
+ # Check to see if the all the properties in the model are valid
84
+ # @return true if the model is valid
85
+ def valid?
86
+ return true
87
+ end
88
+
89
+ # Checks equality by comparing each attribute.
90
+ # @param [Object] Object to be compared
91
+ def ==(o)
92
+ return true if self.equal?(o)
93
+ self.class == o.class &&
94
+ type == o.type &&
95
+ message == o.message &&
96
+ trace_lines == o.trace_lines
97
+ end
98
+
99
+ # @see the `==` method
100
+ # @param [Object] Object to be compared
101
+ def eql?(o)
102
+ self == o
103
+ end
104
+
105
+ # Calculates hash code according to all attributes.
106
+ # @return [Fixnum] Hash code
107
+ def hash
108
+ [type, message, trace_lines].hash
109
+ end
110
+
111
+ # Builds the object from hash
112
+ # @param [Hash] attributes Model attributes in the form of hash
113
+ # @return [Object] Returns the model itself
114
+ def build_from_hash(attributes)
115
+ return nil unless attributes.is_a?(Hash)
116
+ self.class.swagger_types.each_pair do |key, type|
117
+ if type =~ /^Array<(.*)>/i
118
+ # check to ensure the input is an array given that the the attribute
119
+ # is documented as an array but the input is not
120
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
121
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map{ |v| _deserialize($1, v) } )
122
+ end
123
+ elsif !attributes[self.class.attribute_map[key]].nil?
124
+ self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
125
+ end # or else data not found in attributes(hash), not an issue as the data can be optional
126
+ end
127
+
128
+ self
129
+ end
130
+
131
+ # Deserializes the data based on type
132
+ # @param string type Data type
133
+ # @param string value Value to be deserialized
134
+ # @return [Object] Deserialized data
135
+ def _deserialize(type, value)
136
+ case type.to_sym
137
+ when :DateTime
138
+ DateTime.parse(value)
139
+ when :Date
140
+ Date.parse(value)
141
+ when :String
142
+ value.to_s
143
+ when :Integer
144
+ value.to_i
145
+ when :Float
146
+ value.to_f
147
+ when :BOOLEAN
148
+ if value.to_s =~ /^(true|t|yes|y|1)$/i
149
+ true
150
+ else
151
+ false
152
+ end
153
+ when :Object
154
+ # generic object (usually a Hash), return directly
155
+ value
156
+ when /\AArray<(?<inner_type>.+)>\z/
157
+ inner_type = Regexp.last_match[:inner_type]
158
+ value.map { |v| _deserialize(inner_type, v) }
159
+ when /\AHash<(?<k_type>.+), (?<v_type>.+)>\z/
160
+ k_type = Regexp.last_match[:k_type]
161
+ v_type = Regexp.last_match[:v_type]
162
+ {}.tap do |hash|
163
+ value.each do |k, v|
164
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
165
+ end
166
+ end
167
+ else # model
168
+ temp_model = Trakerr.const_get(type).new
169
+ temp_model.build_from_hash(value)
170
+ end
171
+ end
172
+
173
+ # Returns the string representation of the object
174
+ # @return [String] String presentation of the object
175
+ def to_s
176
+ to_hash.to_s
177
+ end
178
+
179
+ # to_body is an alias to to_hash (backward compatibility)
180
+ # @return [Hash] Returns the object in the form of hash
181
+ def to_body
182
+ to_hash
183
+ end
184
+
185
+ # Returns the object in the form of hash
186
+ # @return [Hash] Returns the object in the form of hash
187
+ def to_hash
188
+ hash = {}
189
+ self.class.attribute_map.each_pair do |attr, param|
190
+ value = self.send(attr)
191
+ next if value.nil?
192
+ hash[param] = _to_hash(value)
193
+ end
194
+ hash
195
+ end
196
+
197
+ # Outputs non-array value in the form of hash
198
+ # For object, use to_hash. Otherwise, just return the value
199
+ # @param [Object] value Any valid value
200
+ # @return [Hash] Returns the value in the form of hash
201
+ def _to_hash(value)
202
+ if value.is_a?(Array)
203
+ value.compact.map{ |v| _to_hash(v) }
204
+ elsif value.is_a?(Hash)
205
+ {}.tap do |hash|
206
+ value.each { |k, v| hash[k] = _to_hash(v) }
207
+ end
208
+ elsif value.respond_to? :to_hash
209
+ value.to_hash
210
+ else
211
+ value
212
+ end
213
+ end
214
+
215
+ end
216
+
217
+ end