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,207 @@
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 'uri'
25
+
26
+ module Trakerr
27
+ class Configuration
28
+ # Defines url scheme
29
+ attr_accessor :scheme
30
+
31
+ # Defines url host
32
+ attr_accessor :host
33
+
34
+ # Defines url base path
35
+ attr_accessor :base_path
36
+
37
+ # Defines API keys used with API Key authentications.
38
+ #
39
+ # @return [Hash] key: parameter name, value: parameter value (API key)
40
+ #
41
+ # @example parameter name is "api_key", API key is "xxx" (e.g. "api_key=xxx" in query string)
42
+ # config.api_key['api_key'] = 'xxx'
43
+ attr_accessor :api_key
44
+
45
+ # Defines API key prefixes used with API Key authentications.
46
+ #
47
+ # @return [Hash] key: parameter name, value: API key prefix
48
+ #
49
+ # @example parameter name is "Authorization", API key prefix is "Token" (e.g. "Authorization: Token xxx" in headers)
50
+ # config.api_key_prefix['api_key'] = 'Token'
51
+ attr_accessor :api_key_prefix
52
+
53
+ # Defines the username used with HTTP basic authentication.
54
+ #
55
+ # @return [String]
56
+ attr_accessor :username
57
+
58
+ # Defines the password used with HTTP basic authentication.
59
+ #
60
+ # @return [String]
61
+ attr_accessor :password
62
+
63
+ # Defines the access token (Bearer) used with OAuth2.
64
+ attr_accessor :access_token
65
+
66
+ # Set this to enable/disable debugging. When enabled (set to true), HTTP request/response
67
+ # details will be logged with `logger.debug` (see the `logger` attribute).
68
+ # Default to false.
69
+ #
70
+ # @return [true, false]
71
+ attr_accessor :debugging
72
+
73
+ # Defines the logger used for debugging.
74
+ # Default to `Rails.logger` (when in Rails) or logging to STDOUT.
75
+ #
76
+ # @return [#debug]
77
+ attr_accessor :logger
78
+
79
+ # Defines the temporary folder to store downloaded files
80
+ # (for API endpoints that have file response).
81
+ # Default to use `Tempfile`.
82
+ #
83
+ # @return [String]
84
+ attr_accessor :temp_folder_path
85
+
86
+ # The time limit for HTTP request in seconds.
87
+ # Default to 0 (never times out).
88
+ attr_accessor :timeout
89
+
90
+ ### TLS/SSL setting
91
+ # Set this to false to skip verifying SSL certificate when calling API from https server.
92
+ # Default to true.
93
+ #
94
+ # @note Do NOT set it to false in production code, otherwise you would face multiple types of cryptographic attacks.
95
+ #
96
+ # @return [true, false]
97
+ attr_accessor :verify_ssl
98
+
99
+ ### TLS/SSL setting
100
+ # Set this to false to skip verifying SSL host name
101
+ # Default to true.
102
+ #
103
+ # @note Do NOT set it to false in production code, otherwise you would face multiple types of cryptographic attacks.
104
+ #
105
+ # @return [true, false]
106
+ attr_accessor :verify_ssl_host
107
+
108
+ ### TLS/SSL setting
109
+ # Set this to customize the certificate file to verify the peer.
110
+ #
111
+ # @return [String] the path to the certificate file
112
+ #
113
+ # @see The `cainfo` option of Typhoeus, `--cert` option of libcurl. Related source code:
114
+ # https://github.com/typhoeus/typhoeus/blob/master/lib/typhoeus/easy_factory.rb#L145
115
+ attr_accessor :ssl_ca_cert
116
+
117
+ ### TLS/SSL setting
118
+ # Client certificate file (for client certificate)
119
+ attr_accessor :cert_file
120
+
121
+ ### TLS/SSL setting
122
+ # Client private key file (for client certificate)
123
+ attr_accessor :key_file
124
+
125
+ # Set this to customize parameters encoding of array parameter with multi collectionFormat.
126
+ # Default to nil.
127
+ #
128
+ # @see The params_encoding option of Ethon. Related source code:
129
+ # https://github.com/typhoeus/ethon/blob/master/lib/ethon/easy/queryable.rb#L96
130
+ attr_accessor :params_encoding
131
+
132
+ attr_accessor :inject_format
133
+
134
+ attr_accessor :force_ending_format
135
+
136
+ def initialize
137
+ @scheme = 'https'
138
+ @host = 'www.trakerr.io'
139
+ @base_path = '/api/v1'
140
+ @api_key = {}
141
+ @api_key_prefix = {}
142
+ @timeout = 0
143
+ @verify_ssl = true
144
+ @verify_ssl_host = true
145
+ @params_encoding = nil
146
+ @cert_file = nil
147
+ @key_file = nil
148
+ @debugging = false
149
+ @inject_format = false
150
+ @force_ending_format = false
151
+ @logger = defined?(Rails) ? Rails.logger : Logger.new(STDOUT)
152
+
153
+ yield(self) if block_given?
154
+ end
155
+
156
+ # The default Configuration object.
157
+ def self.default
158
+ @@default ||= Configuration.new
159
+ end
160
+
161
+ def configure
162
+ yield(self) if block_given?
163
+ end
164
+
165
+ def scheme=(scheme)
166
+ # remove :// from scheme
167
+ @scheme = scheme.sub(/:\/\//, '')
168
+ end
169
+
170
+ def host=(host)
171
+ # remove http(s):// and anything after a slash
172
+ @host = host.sub(/https?:\/\//, '').split('/').first
173
+ end
174
+
175
+ def base_path=(base_path)
176
+ # Add leading and trailing slashes to base_path
177
+ @base_path = "/#{base_path}".gsub(/\/+/, '/')
178
+ @base_path = "" if @base_path == "/"
179
+ end
180
+
181
+ def base_url
182
+ url = "#{scheme}://#{[host, base_path].join('/').gsub(/\/+/, '/')}".sub(/\/+\z/, '')
183
+ URI.encode(url)
184
+ end
185
+
186
+ # Gets API key (with prefix if set).
187
+ # @param [String] param_name the parameter name of API key auth
188
+ def api_key_with_prefix(param_name)
189
+ if @api_key_prefix[param_name]
190
+ "#{@api_key_prefix[param_name]} #{@api_key[param_name]}"
191
+ else
192
+ @api_key[param_name]
193
+ end
194
+ end
195
+
196
+ # Gets Basic Auth token string
197
+ def basic_auth_token
198
+ 'Basic ' + ["#{username}:#{password}"].pack('m').delete("\r\n")
199
+ end
200
+
201
+ # Returns Auth Settings hash for api client.
202
+ def auth_settings
203
+ {
204
+ }
205
+ end
206
+ end
207
+ end
@@ -0,0 +1,454 @@
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 AppEvent
29
+ # API key generated for the application
30
+ attr_accessor :api_key
31
+
32
+ # (optional) Logging level, one of 'debug','info','warning','error', 'fatal', defaults to 'error'
33
+ attr_accessor :log_level
34
+
35
+ # (optional) one of 'error' or a custom string for non-errors, defaults to 'error'
36
+ attr_accessor :classification
37
+
38
+ # type of the event or error (eg. NullPointerException)
39
+ attr_accessor :event_type
40
+
41
+ # message containing details of the event or error
42
+ attr_accessor :event_message
43
+
44
+ # (optional) event time in ms since epoch
45
+ attr_accessor :event_time
46
+
47
+ attr_accessor :event_stacktrace
48
+
49
+ # (optional) event user identifying a user
50
+ attr_accessor :event_user
51
+
52
+ # (optional) session identification
53
+ attr_accessor :event_session
54
+
55
+ # (optional) application version information
56
+ attr_accessor :context_app_version
57
+
58
+ # (optional) deployment stage, one of 'development','staging','production' or a custom string
59
+ attr_accessor :deployment_stage
60
+
61
+ # (optional) environment name (like 'cpython' or 'ironpython' etc.)
62
+ attr_accessor :context_env_name
63
+
64
+ # (optional) language (like 'python' or 'c#' etc.)
65
+ attr_accessor :context_env_language
66
+
67
+ # (optional) version of environment
68
+ attr_accessor :context_env_version
69
+
70
+ # (optional) hostname or ID of environment
71
+ attr_accessor :context_env_hostname
72
+
73
+ # (optional) browser name if running in a browser (eg. Chrome)
74
+ attr_accessor :context_app_browser
75
+
76
+ # (optional) browser version if running in a browser
77
+ attr_accessor :context_app_browser_version
78
+
79
+ # (optional) OS the application is running on
80
+ attr_accessor :context_app_os
81
+
82
+ # (optional) OS version the application is running on
83
+ attr_accessor :context_app_os_version
84
+
85
+ # (optional) Data center the application is running on or connected to
86
+ attr_accessor :context_data_center
87
+
88
+ # (optional) Data center region
89
+ attr_accessor :context_data_center_region
90
+
91
+ attr_accessor :custom_properties
92
+
93
+ attr_accessor :custom_segments
94
+
95
+ class EnumAttributeValidator
96
+ attr_reader :datatype
97
+ attr_reader :allowable_values
98
+
99
+ def initialize(datatype, allowable_values)
100
+ @allowable_values = allowable_values.map do |value|
101
+ case datatype.to_s
102
+ when /Integer/i
103
+ value.to_i
104
+ when /Float/i
105
+ value.to_f
106
+ else
107
+ value
108
+ end
109
+ end
110
+ end
111
+
112
+ def valid?(value)
113
+ !value || allowable_values.include?(value)
114
+ end
115
+ end
116
+
117
+ # Attribute mapping from ruby-style variable name to JSON key.
118
+ def self.attribute_map
119
+ {
120
+ :'api_key' => :'apiKey',
121
+ :'log_level' => :'logLevel',
122
+ :'classification' => :'classification',
123
+ :'event_type' => :'eventType',
124
+ :'event_message' => :'eventMessage',
125
+ :'event_time' => :'eventTime',
126
+ :'event_stacktrace' => :'eventStacktrace',
127
+ :'event_user' => :'eventUser',
128
+ :'event_session' => :'eventSession',
129
+ :'context_app_version' => :'contextAppVersion',
130
+ :'deployment_stage' => :'deploymentStage',
131
+ :'context_env_name' => :'contextEnvName',
132
+ :'context_env_language' => :'contextEnvLanguage',
133
+ :'context_env_version' => :'contextEnvVersion',
134
+ :'context_env_hostname' => :'contextEnvHostname',
135
+ :'context_app_browser' => :'contextAppBrowser',
136
+ :'context_app_browser_version' => :'contextAppBrowserVersion',
137
+ :'context_app_os' => :'contextAppOS',
138
+ :'context_app_os_version' => :'contextAppOSVersion',
139
+ :'context_data_center' => :'contextDataCenter',
140
+ :'context_data_center_region' => :'contextDataCenterRegion',
141
+ :'custom_properties' => :'customProperties',
142
+ :'custom_segments' => :'customSegments'
143
+ }
144
+ end
145
+
146
+ # Attribute type mapping.
147
+ def self.swagger_types
148
+ {
149
+ :'api_key' => :'String',
150
+ :'log_level' => :'String',
151
+ :'classification' => :'String',
152
+ :'event_type' => :'String',
153
+ :'event_message' => :'String',
154
+ :'event_time' => :'Integer',
155
+ :'event_stacktrace' => :'Stacktrace',
156
+ :'event_user' => :'String',
157
+ :'event_session' => :'String',
158
+ :'context_app_version' => :'String',
159
+ :'deployment_stage' => :'String',
160
+ :'context_env_name' => :'String',
161
+ :'context_env_language' => :'String',
162
+ :'context_env_version' => :'String',
163
+ :'context_env_hostname' => :'String',
164
+ :'context_app_browser' => :'String',
165
+ :'context_app_browser_version' => :'String',
166
+ :'context_app_os' => :'String',
167
+ :'context_app_os_version' => :'String',
168
+ :'context_data_center' => :'String',
169
+ :'context_data_center_region' => :'String',
170
+ :'custom_properties' => :'CustomData',
171
+ :'custom_segments' => :'CustomData'
172
+ }
173
+ end
174
+
175
+ # Initializes the object
176
+ # @param [Hash] attributes Model attributes in the form of hash
177
+ def initialize(attributes = {})
178
+ return unless attributes.is_a?(Hash)
179
+
180
+ # convert string to symbol for hash key
181
+ attributes = attributes.each_with_object({}){|(k,v), h| h[k.to_sym] = v}
182
+
183
+ if attributes.has_key?(:'apiKey')
184
+ self.api_key = attributes[:'apiKey']
185
+ end
186
+
187
+ if attributes.has_key?(:'logLevel')
188
+ self.log_level = attributes[:'logLevel']
189
+ end
190
+
191
+ if attributes.has_key?(:'classification')
192
+ self.classification = attributes[:'classification']
193
+ end
194
+
195
+ if attributes.has_key?(:'eventType')
196
+ self.event_type = attributes[:'eventType']
197
+ end
198
+
199
+ if attributes.has_key?(:'eventMessage')
200
+ self.event_message = attributes[:'eventMessage']
201
+ end
202
+
203
+ if attributes.has_key?(:'eventTime')
204
+ self.event_time = attributes[:'eventTime']
205
+ end
206
+
207
+ if attributes.has_key?(:'eventStacktrace')
208
+ self.event_stacktrace = attributes[:'eventStacktrace']
209
+ end
210
+
211
+ if attributes.has_key?(:'eventUser')
212
+ self.event_user = attributes[:'eventUser']
213
+ end
214
+
215
+ if attributes.has_key?(:'eventSession')
216
+ self.event_session = attributes[:'eventSession']
217
+ end
218
+
219
+ if attributes.has_key?(:'contextAppVersion')
220
+ self.context_app_version = attributes[:'contextAppVersion']
221
+ end
222
+
223
+ if attributes.has_key?(:'deploymentStage')
224
+ self.deployment_stage = attributes[:'deploymentStage']
225
+ end
226
+
227
+ if attributes.has_key?(:'contextEnvName')
228
+ self.context_env_name = attributes[:'contextEnvName']
229
+ end
230
+
231
+ if attributes.has_key?(:'contextEnvLanguage')
232
+ self.context_env_language = attributes[:'contextEnvLanguage']
233
+ end
234
+
235
+ if attributes.has_key?(:'contextEnvVersion')
236
+ self.context_env_version = attributes[:'contextEnvVersion']
237
+ end
238
+
239
+ if attributes.has_key?(:'contextEnvHostname')
240
+ self.context_env_hostname = attributes[:'contextEnvHostname']
241
+ end
242
+
243
+ if attributes.has_key?(:'contextAppBrowser')
244
+ self.context_app_browser = attributes[:'contextAppBrowser']
245
+ end
246
+
247
+ if attributes.has_key?(:'contextAppBrowserVersion')
248
+ self.context_app_browser_version = attributes[:'contextAppBrowserVersion']
249
+ end
250
+
251
+ if attributes.has_key?(:'contextAppOS')
252
+ self.context_app_os = attributes[:'contextAppOS']
253
+ end
254
+
255
+ if attributes.has_key?(:'contextAppOSVersion')
256
+ self.context_app_os_version = attributes[:'contextAppOSVersion']
257
+ end
258
+
259
+ if attributes.has_key?(:'contextDataCenter')
260
+ self.context_data_center = attributes[:'contextDataCenter']
261
+ end
262
+
263
+ if attributes.has_key?(:'contextDataCenterRegion')
264
+ self.context_data_center_region = attributes[:'contextDataCenterRegion']
265
+ end
266
+
267
+ if attributes.has_key?(:'customProperties')
268
+ self.custom_properties = attributes[:'customProperties']
269
+ end
270
+
271
+ if attributes.has_key?(:'customSegments')
272
+ self.custom_segments = attributes[:'customSegments']
273
+ end
274
+
275
+ end
276
+
277
+ # Show invalid properties with the reasons. Usually used together with valid?
278
+ # @return Array for valid properies with the reasons
279
+ def list_invalid_properties
280
+ invalid_properties = Array.new
281
+ return invalid_properties
282
+ end
283
+
284
+ # Check to see if the all the properties in the model are valid
285
+ # @return true if the model is valid
286
+ def valid?
287
+ return false if @api_key.nil?
288
+ log_level_validator = EnumAttributeValidator.new('String', ["debug", "info", "warning", "error", "fatal"])
289
+ return false unless log_level_validator.valid?(@log_level)
290
+ return false if @classification.nil?
291
+ return false if @event_type.nil?
292
+ return false if @event_message.nil?
293
+ return true
294
+ end
295
+
296
+ # Custom attribute writer method checking allowed values (enum).
297
+ # @param [Object] log_level Object to be assigned
298
+ def log_level=(log_level)
299
+ validator = EnumAttributeValidator.new('String', ["debug", "info", "warning", "error", "fatal"])
300
+ unless validator.valid?(log_level)
301
+ fail ArgumentError, "invalid value for 'log_level', must be one of #{validator.allowable_values}."
302
+ end
303
+ @log_level = log_level
304
+ end
305
+
306
+ # Checks equality by comparing each attribute.
307
+ # @param [Object] Object to be compared
308
+ def ==(o)
309
+ return true if self.equal?(o)
310
+ self.class == o.class &&
311
+ api_key == o.api_key &&
312
+ log_level == o.log_level &&
313
+ classification == o.classification &&
314
+ event_type == o.event_type &&
315
+ event_message == o.event_message &&
316
+ event_time == o.event_time &&
317
+ event_stacktrace == o.event_stacktrace &&
318
+ event_user == o.event_user &&
319
+ event_session == o.event_session &&
320
+ context_app_version == o.context_app_version &&
321
+ deployment_stage == o.deployment_stage &&
322
+ context_env_name == o.context_env_name &&
323
+ context_env_language == o.context_env_language &&
324
+ context_env_version == o.context_env_version &&
325
+ context_env_hostname == o.context_env_hostname &&
326
+ context_app_browser == o.context_app_browser &&
327
+ context_app_browser_version == o.context_app_browser_version &&
328
+ context_app_os == o.context_app_os &&
329
+ context_app_os_version == o.context_app_os_version &&
330
+ context_data_center == o.context_data_center &&
331
+ context_data_center_region == o.context_data_center_region &&
332
+ custom_properties == o.custom_properties &&
333
+ custom_segments == o.custom_segments
334
+ end
335
+
336
+ # @see the `==` method
337
+ # @param [Object] Object to be compared
338
+ def eql?(o)
339
+ self == o
340
+ end
341
+
342
+ # Calculates hash code according to all attributes.
343
+ # @return [Fixnum] Hash code
344
+ def hash
345
+ [api_key, log_level, classification, event_type, event_message, event_time, event_stacktrace, event_user, event_session, context_app_version, deployment_stage, context_env_name, context_env_language, context_env_version, context_env_hostname, context_app_browser, context_app_browser_version, context_app_os, context_app_os_version, context_data_center, context_data_center_region, custom_properties, custom_segments].hash
346
+ end
347
+
348
+ # Builds the object from hash
349
+ # @param [Hash] attributes Model attributes in the form of hash
350
+ # @return [Object] Returns the model itself
351
+ def build_from_hash(attributes)
352
+ return nil unless attributes.is_a?(Hash)
353
+ self.class.swagger_types.each_pair do |key, type|
354
+ if type =~ /^Array<(.*)>/i
355
+ # check to ensure the input is an array given that the the attribute
356
+ # is documented as an array but the input is not
357
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
358
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map{ |v| _deserialize($1, v) } )
359
+ end
360
+ elsif !attributes[self.class.attribute_map[key]].nil?
361
+ self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
362
+ end # or else data not found in attributes(hash), not an issue as the data can be optional
363
+ end
364
+
365
+ self
366
+ end
367
+
368
+ # Deserializes the data based on type
369
+ # @param string type Data type
370
+ # @param string value Value to be deserialized
371
+ # @return [Object] Deserialized data
372
+ def _deserialize(type, value)
373
+ case type.to_sym
374
+ when :DateTime
375
+ DateTime.parse(value)
376
+ when :Date
377
+ Date.parse(value)
378
+ when :String
379
+ value.to_s
380
+ when :Integer
381
+ value.to_i
382
+ when :Float
383
+ value.to_f
384
+ when :BOOLEAN
385
+ if value.to_s =~ /^(true|t|yes|y|1)$/i
386
+ true
387
+ else
388
+ false
389
+ end
390
+ when :Object
391
+ # generic object (usually a Hash), return directly
392
+ value
393
+ when /\AArray<(?<inner_type>.+)>\z/
394
+ inner_type = Regexp.last_match[:inner_type]
395
+ value.map { |v| _deserialize(inner_type, v) }
396
+ when /\AHash<(?<k_type>.+), (?<v_type>.+)>\z/
397
+ k_type = Regexp.last_match[:k_type]
398
+ v_type = Regexp.last_match[:v_type]
399
+ {}.tap do |hash|
400
+ value.each do |k, v|
401
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
402
+ end
403
+ end
404
+ else # model
405
+ temp_model = Trakerr.const_get(type).new
406
+ temp_model.build_from_hash(value)
407
+ end
408
+ end
409
+
410
+ # Returns the string representation of the object
411
+ # @return [String] String presentation of the object
412
+ def to_s
413
+ to_hash.to_s
414
+ end
415
+
416
+ # to_body is an alias to to_hash (backward compatibility)
417
+ # @return [Hash] Returns the object in the form of hash
418
+ def to_body
419
+ to_hash
420
+ end
421
+
422
+ # Returns the object in the form of hash
423
+ # @return [Hash] Returns the object in the form of hash
424
+ def to_hash
425
+ hash = {}
426
+ self.class.attribute_map.each_pair do |attr, param|
427
+ value = self.send(attr)
428
+ next if value.nil?
429
+ hash[param] = _to_hash(value)
430
+ end
431
+ hash
432
+ end
433
+
434
+ # Outputs non-array value in the form of hash
435
+ # For object, use to_hash. Otherwise, just return the value
436
+ # @param [Object] value Any valid value
437
+ # @return [Hash] Returns the value in the form of hash
438
+ def _to_hash(value)
439
+ if value.is_a?(Array)
440
+ value.compact.map{ |v| _to_hash(v) }
441
+ elsif value.is_a?(Hash)
442
+ {}.tap do |hash|
443
+ value.each { |k, v| hash[k] = _to_hash(v) }
444
+ end
445
+ elsif value.respond_to? :to_hash
446
+ value.to_hash
447
+ else
448
+ value
449
+ end
450
+ end
451
+
452
+ end
453
+
454
+ end