dyspatch_client 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (76) hide show
  1. checksums.yaml +7 -0
  2. data/Gemfile +7 -0
  3. data/LICENSE +202 -0
  4. data/README.md +130 -0
  5. data/Rakefile +8 -0
  6. data/docs/APIError.md +10 -0
  7. data/docs/CompiledRead.md +12 -0
  8. data/docs/CreatedAt.md +7 -0
  9. data/docs/Cursor.md +9 -0
  10. data/docs/LanguageId.md +7 -0
  11. data/docs/LocalizationId.md +7 -0
  12. data/docs/LocalizationMetaRead.md +11 -0
  13. data/docs/LocalizationName.md +7 -0
  14. data/docs/LocalizationRead.md +15 -0
  15. data/docs/LocalizationUrl.md +7 -0
  16. data/docs/LocalizationsApi.md +66 -0
  17. data/docs/TemplateDescription.md +7 -0
  18. data/docs/TemplateId.md +7 -0
  19. data/docs/TemplateMetaRead.md +14 -0
  20. data/docs/TemplateName.md +7 -0
  21. data/docs/TemplateRead.md +15 -0
  22. data/docs/TemplateUrl.md +7 -0
  23. data/docs/TemplatesApi.md +125 -0
  24. data/docs/TemplatesRead.md +9 -0
  25. data/docs/UpdatedAt.md +7 -0
  26. data/dyspatch_client.gemspec +45 -0
  27. data/git_push.sh +55 -0
  28. data/lib/dyspatch_client.rb +59 -0
  29. data/lib/dyspatch_client/api/localizations_api.rb +83 -0
  30. data/lib/dyspatch_client/api/templates_api.rb +140 -0
  31. data/lib/dyspatch_client/api_client.rb +389 -0
  32. data/lib/dyspatch_client/api_error.rb +38 -0
  33. data/lib/dyspatch_client/configuration.rb +209 -0
  34. data/lib/dyspatch_client/models/api_error.rb +242 -0
  35. data/lib/dyspatch_client/models/compiled_read.rb +277 -0
  36. data/lib/dyspatch_client/models/created_at.rb +179 -0
  37. data/lib/dyspatch_client/models/cursor.rb +199 -0
  38. data/lib/dyspatch_client/models/language_id.rb +179 -0
  39. data/lib/dyspatch_client/models/localization_id.rb +179 -0
  40. data/lib/dyspatch_client/models/localization_meta_read.rb +219 -0
  41. data/lib/dyspatch_client/models/localization_name.rb +179 -0
  42. data/lib/dyspatch_client/models/localization_read.rb +258 -0
  43. data/lib/dyspatch_client/models/localization_url.rb +179 -0
  44. data/lib/dyspatch_client/models/template_description.rb +179 -0
  45. data/lib/dyspatch_client/models/template_id.rb +179 -0
  46. data/lib/dyspatch_client/models/template_meta_read.rb +251 -0
  47. data/lib/dyspatch_client/models/template_name.rb +179 -0
  48. data/lib/dyspatch_client/models/template_read.rb +260 -0
  49. data/lib/dyspatch_client/models/template_url.rb +179 -0
  50. data/lib/dyspatch_client/models/templates_read.rb +200 -0
  51. data/lib/dyspatch_client/models/updated_at.rb +179 -0
  52. data/lib/dyspatch_client/version.rb +15 -0
  53. data/spec/api/localizations_api_spec.rb +48 -0
  54. data/spec/api/templates_api_spec.rb +61 -0
  55. data/spec/api_client_spec.rb +226 -0
  56. data/spec/configuration_spec.rb +42 -0
  57. data/spec/models/api_error_spec.rb +58 -0
  58. data/spec/models/compiled_read_spec.rb +66 -0
  59. data/spec/models/created_at_spec.rb +36 -0
  60. data/spec/models/cursor_spec.rb +48 -0
  61. data/spec/models/language_id_spec.rb +36 -0
  62. data/spec/models/localization_id_spec.rb +36 -0
  63. data/spec/models/localization_meta_read_spec.rb +60 -0
  64. data/spec/models/localization_name_spec.rb +36 -0
  65. data/spec/models/localization_read_spec.rb +84 -0
  66. data/spec/models/localization_url_spec.rb +36 -0
  67. data/spec/models/template_description_spec.rb +36 -0
  68. data/spec/models/template_id_spec.rb +36 -0
  69. data/spec/models/template_meta_read_spec.rb +78 -0
  70. data/spec/models/template_name_spec.rb +36 -0
  71. data/spec/models/template_read_spec.rb +84 -0
  72. data/spec/models/template_url_spec.rb +36 -0
  73. data/spec/models/templates_read_spec.rb +48 -0
  74. data/spec/models/updated_at_spec.rb +36 -0
  75. data/spec/spec_helper.rb +111 -0
  76. metadata +329 -0
@@ -0,0 +1,219 @@
1
+ =begin
2
+ #Dyspatch API
3
+
4
+ ## Introduction The Dyspatch API is based on the REST paradigm, and features resource based URLs with standard HTTP response codes to indicate errors. We use standard HTTP authentication and request verbs, and all responses are JSON formatted. See our [Implementation Guide](https://docs.dyspatch.io/development/implementing_dyspatch/) for more details on how to implement Dyspatch. ## API Client Libraries Dyspatch provides API Clients for popular languages and web frameworks. - [Java](https://github.com/getdyspatch/dyspatch-java) - [Javascript](https://github.com/getdyspatch/dyspatch-javascript) - [Python](https://github.com/getdyspatch/dyspatch-python)
5
+
6
+ OpenAPI spec version: 2018.08
7
+ Contact: support@dyspatch.io
8
+ Generated by: https://github.com/swagger-api/swagger-codegen.git
9
+ Swagger Codegen version: 2.3.1
10
+
11
+ =end
12
+
13
+ require 'date'
14
+
15
+ module DyspatchClient
16
+
17
+ class LocalizationMetaRead
18
+ # An opaque, unique identifier for a localization
19
+ attr_accessor :id
20
+
21
+ # A language identifier comprised of a language and a country identifier. See [supported languages](https://docs.dyspatch.io/localization/supported_languages/).
22
+ attr_accessor :language
23
+
24
+ # The user-specified name of a localization
25
+ attr_accessor :name
26
+
27
+ # The API url for a specific localization
28
+ attr_accessor :url
29
+
30
+
31
+ # Attribute mapping from ruby-style variable name to JSON key.
32
+ def self.attribute_map
33
+ {
34
+ :'id' => :'id',
35
+ :'language' => :'language',
36
+ :'name' => :'name',
37
+ :'url' => :'url'
38
+ }
39
+ end
40
+
41
+ # Attribute type mapping.
42
+ def self.swagger_types
43
+ {
44
+ :'id' => :'String',
45
+ :'language' => :'String',
46
+ :'name' => :'String',
47
+ :'url' => :'String'
48
+ }
49
+ end
50
+
51
+ # Initializes the object
52
+ # @param [Hash] attributes Model attributes in the form of hash
53
+ def initialize(attributes = {})
54
+ return unless attributes.is_a?(Hash)
55
+
56
+ # convert string to symbol for hash key
57
+ attributes = attributes.each_with_object({}){|(k,v), h| h[k.to_sym] = v}
58
+
59
+ if attributes.has_key?(:'id')
60
+ self.id = attributes[:'id']
61
+ end
62
+
63
+ if attributes.has_key?(:'language')
64
+ self.language = attributes[:'language']
65
+ end
66
+
67
+ if attributes.has_key?(:'name')
68
+ self.name = attributes[:'name']
69
+ end
70
+
71
+ if attributes.has_key?(:'url')
72
+ self.url = attributes[:'url']
73
+ end
74
+
75
+ end
76
+
77
+ # Show invalid properties with the reasons. Usually used together with valid?
78
+ # @return Array for valid properties with the reasons
79
+ def list_invalid_properties
80
+ invalid_properties = Array.new
81
+ return invalid_properties
82
+ end
83
+
84
+ # Check to see if the all the properties in the model are valid
85
+ # @return true if the model is valid
86
+ def valid?
87
+ return true
88
+ end
89
+
90
+ # Checks equality by comparing each attribute.
91
+ # @param [Object] Object to be compared
92
+ def ==(o)
93
+ return true if self.equal?(o)
94
+ self.class == o.class &&
95
+ id == o.id &&
96
+ language == o.language &&
97
+ name == o.name &&
98
+ url == o.url
99
+ end
100
+
101
+ # @see the `==` method
102
+ # @param [Object] Object to be compared
103
+ def eql?(o)
104
+ self == o
105
+ end
106
+
107
+ # Calculates hash code according to all attributes.
108
+ # @return [Fixnum] Hash code
109
+ def hash
110
+ [id, language, name, url].hash
111
+ end
112
+
113
+ # Builds the object from hash
114
+ # @param [Hash] attributes Model attributes in the form of hash
115
+ # @return [Object] Returns the model itself
116
+ def build_from_hash(attributes)
117
+ return nil unless attributes.is_a?(Hash)
118
+ self.class.swagger_types.each_pair do |key, type|
119
+ if type =~ /\AArray<(.*)>/i
120
+ # check to ensure the input is an array given that the the attribute
121
+ # is documented as an array but the input is not
122
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
123
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map{ |v| _deserialize($1, v) } )
124
+ end
125
+ elsif !attributes[self.class.attribute_map[key]].nil?
126
+ self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
127
+ end # or else data not found in attributes(hash), not an issue as the data can be optional
128
+ end
129
+
130
+ self
131
+ end
132
+
133
+ # Deserializes the data based on type
134
+ # @param string type Data type
135
+ # @param string value Value to be deserialized
136
+ # @return [Object] Deserialized data
137
+ def _deserialize(type, value)
138
+ case type.to_sym
139
+ when :DateTime
140
+ DateTime.parse(value)
141
+ when :Date
142
+ Date.parse(value)
143
+ when :String
144
+ value.to_s
145
+ when :Integer
146
+ value.to_i
147
+ when :Float
148
+ value.to_f
149
+ when :BOOLEAN
150
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
151
+ true
152
+ else
153
+ false
154
+ end
155
+ when :Object
156
+ # generic object (usually a Hash), return directly
157
+ value
158
+ when /\AArray<(?<inner_type>.+)>\z/
159
+ inner_type = Regexp.last_match[:inner_type]
160
+ value.map { |v| _deserialize(inner_type, v) }
161
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
162
+ k_type = Regexp.last_match[:k_type]
163
+ v_type = Regexp.last_match[:v_type]
164
+ {}.tap do |hash|
165
+ value.each do |k, v|
166
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
167
+ end
168
+ end
169
+ else # model
170
+ temp_model = DyspatchClient.const_get(type).new
171
+ temp_model.build_from_hash(value)
172
+ end
173
+ end
174
+
175
+ # Returns the string representation of the object
176
+ # @return [String] String presentation of the object
177
+ def to_s
178
+ to_hash.to_s
179
+ end
180
+
181
+ # to_body is an alias to to_hash (backward compatibility)
182
+ # @return [Hash] Returns the object in the form of hash
183
+ def to_body
184
+ to_hash
185
+ end
186
+
187
+ # Returns the object in the form of hash
188
+ # @return [Hash] Returns the object in the form of hash
189
+ def to_hash
190
+ hash = {}
191
+ self.class.attribute_map.each_pair do |attr, param|
192
+ value = self.send(attr)
193
+ next if value.nil?
194
+ hash[param] = _to_hash(value)
195
+ end
196
+ hash
197
+ end
198
+
199
+ # Outputs non-array value in the form of hash
200
+ # For object, use to_hash. Otherwise, just return the value
201
+ # @param [Object] value Any valid value
202
+ # @return [Hash] Returns the value in the form of hash
203
+ def _to_hash(value)
204
+ if value.is_a?(Array)
205
+ value.compact.map{ |v| _to_hash(v) }
206
+ elsif value.is_a?(Hash)
207
+ {}.tap do |hash|
208
+ value.each { |k, v| hash[k] = _to_hash(v) }
209
+ end
210
+ elsif value.respond_to? :to_hash
211
+ value.to_hash
212
+ else
213
+ value
214
+ end
215
+ end
216
+
217
+ end
218
+
219
+ end
@@ -0,0 +1,179 @@
1
+ =begin
2
+ #Dyspatch API
3
+
4
+ ## Introduction The Dyspatch API is based on the REST paradigm, and features resource based URLs with standard HTTP response codes to indicate errors. We use standard HTTP authentication and request verbs, and all responses are JSON formatted. See our [Implementation Guide](https://docs.dyspatch.io/development/implementing_dyspatch/) for more details on how to implement Dyspatch. ## API Client Libraries Dyspatch provides API Clients for popular languages and web frameworks. - [Java](https://github.com/getdyspatch/dyspatch-java) - [Javascript](https://github.com/getdyspatch/dyspatch-javascript) - [Python](https://github.com/getdyspatch/dyspatch-python)
5
+
6
+ OpenAPI spec version: 2018.08
7
+ Contact: support@dyspatch.io
8
+ Generated by: https://github.com/swagger-api/swagger-codegen.git
9
+ Swagger Codegen version: 2.3.1
10
+
11
+ =end
12
+
13
+ require 'date'
14
+
15
+ module DyspatchClient
16
+ # The user-specified name of a localization
17
+ class LocalizationName
18
+
19
+ # Attribute mapping from ruby-style variable name to JSON key.
20
+ def self.attribute_map
21
+ {
22
+ }
23
+ end
24
+
25
+ # Attribute type mapping.
26
+ def self.swagger_types
27
+ {
28
+ }
29
+ end
30
+
31
+ # Initializes the object
32
+ # @param [Hash] attributes Model attributes in the form of hash
33
+ def initialize(attributes = {})
34
+ return unless attributes.is_a?(Hash)
35
+
36
+ # convert string to symbol for hash key
37
+ attributes = attributes.each_with_object({}){|(k,v), h| h[k.to_sym] = v}
38
+
39
+ end
40
+
41
+ # Show invalid properties with the reasons. Usually used together with valid?
42
+ # @return Array for valid properties with the reasons
43
+ def list_invalid_properties
44
+ invalid_properties = Array.new
45
+ return invalid_properties
46
+ end
47
+
48
+ # Check to see if the all the properties in the model are valid
49
+ # @return true if the model is valid
50
+ def valid?
51
+ return true
52
+ end
53
+
54
+ # Checks equality by comparing each attribute.
55
+ # @param [Object] Object to be compared
56
+ def ==(o)
57
+ return true if self.equal?(o)
58
+ self.class == o.class
59
+ end
60
+
61
+ # @see the `==` method
62
+ # @param [Object] Object to be compared
63
+ def eql?(o)
64
+ self == o
65
+ end
66
+
67
+ # Calculates hash code according to all attributes.
68
+ # @return [Fixnum] Hash code
69
+ def hash
70
+ [].hash
71
+ end
72
+
73
+ # Builds the object from hash
74
+ # @param [Hash] attributes Model attributes in the form of hash
75
+ # @return [Object] Returns the model itself
76
+ def build_from_hash(attributes)
77
+ return nil unless attributes.is_a?(Hash)
78
+ self.class.swagger_types.each_pair do |key, type|
79
+ if type =~ /\AArray<(.*)>/i
80
+ # check to ensure the input is an array given that the the attribute
81
+ # is documented as an array but the input is not
82
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
83
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map{ |v| _deserialize($1, v) } )
84
+ end
85
+ elsif !attributes[self.class.attribute_map[key]].nil?
86
+ self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
87
+ end # or else data not found in attributes(hash), not an issue as the data can be optional
88
+ end
89
+
90
+ self
91
+ end
92
+
93
+ # Deserializes the data based on type
94
+ # @param string type Data type
95
+ # @param string value Value to be deserialized
96
+ # @return [Object] Deserialized data
97
+ def _deserialize(type, value)
98
+ case type.to_sym
99
+ when :DateTime
100
+ DateTime.parse(value)
101
+ when :Date
102
+ Date.parse(value)
103
+ when :String
104
+ value.to_s
105
+ when :Integer
106
+ value.to_i
107
+ when :Float
108
+ value.to_f
109
+ when :BOOLEAN
110
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
111
+ true
112
+ else
113
+ false
114
+ end
115
+ when :Object
116
+ # generic object (usually a Hash), return directly
117
+ value
118
+ when /\AArray<(?<inner_type>.+)>\z/
119
+ inner_type = Regexp.last_match[:inner_type]
120
+ value.map { |v| _deserialize(inner_type, v) }
121
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
122
+ k_type = Regexp.last_match[:k_type]
123
+ v_type = Regexp.last_match[:v_type]
124
+ {}.tap do |hash|
125
+ value.each do |k, v|
126
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
127
+ end
128
+ end
129
+ else # model
130
+ temp_model = DyspatchClient.const_get(type).new
131
+ temp_model.build_from_hash(value)
132
+ end
133
+ end
134
+
135
+ # Returns the string representation of the object
136
+ # @return [String] String presentation of the object
137
+ def to_s
138
+ to_hash.to_s
139
+ end
140
+
141
+ # to_body is an alias to to_hash (backward compatibility)
142
+ # @return [Hash] Returns the object in the form of hash
143
+ def to_body
144
+ to_hash
145
+ end
146
+
147
+ # Returns the object in the form of hash
148
+ # @return [Hash] Returns the object in the form of hash
149
+ def to_hash
150
+ hash = {}
151
+ self.class.attribute_map.each_pair do |attr, param|
152
+ value = self.send(attr)
153
+ next if value.nil?
154
+ hash[param] = _to_hash(value)
155
+ end
156
+ hash
157
+ end
158
+
159
+ # Outputs non-array value in the form of hash
160
+ # For object, use to_hash. Otherwise, just return the value
161
+ # @param [Object] value Any valid value
162
+ # @return [Hash] Returns the value in the form of hash
163
+ def _to_hash(value)
164
+ if value.is_a?(Array)
165
+ value.compact.map{ |v| _to_hash(v) }
166
+ elsif value.is_a?(Hash)
167
+ {}.tap do |hash|
168
+ value.each { |k, v| hash[k] = _to_hash(v) }
169
+ end
170
+ elsif value.respond_to? :to_hash
171
+ value.to_hash
172
+ else
173
+ value
174
+ end
175
+ end
176
+
177
+ end
178
+
179
+ end
@@ -0,0 +1,258 @@
1
+ =begin
2
+ #Dyspatch API
3
+
4
+ ## Introduction The Dyspatch API is based on the REST paradigm, and features resource based URLs with standard HTTP response codes to indicate errors. We use standard HTTP authentication and request verbs, and all responses are JSON formatted. See our [Implementation Guide](https://docs.dyspatch.io/development/implementing_dyspatch/) for more details on how to implement Dyspatch. ## API Client Libraries Dyspatch provides API Clients for popular languages and web frameworks. - [Java](https://github.com/getdyspatch/dyspatch-java) - [Javascript](https://github.com/getdyspatch/dyspatch-javascript) - [Python](https://github.com/getdyspatch/dyspatch-python)
5
+
6
+ OpenAPI spec version: 2018.08
7
+ Contact: support@dyspatch.io
8
+ Generated by: https://github.com/swagger-api/swagger-codegen.git
9
+ Swagger Codegen version: 2.3.1
10
+
11
+ =end
12
+
13
+ require 'date'
14
+
15
+ module DyspatchClient
16
+
17
+ class LocalizationRead
18
+ # An opaque, unique identifier for a localization
19
+ attr_accessor :id
20
+
21
+ # A language identifier comprised of a language and a country identifier. See [supported languages](https://docs.dyspatch.io/localization/supported_languages/).
22
+ attr_accessor :language
23
+
24
+ # The API url for a specific localization
25
+ attr_accessor :url
26
+
27
+ # An opaque, unique identifier for a template
28
+ attr_accessor :template
29
+
30
+ attr_accessor :compiled
31
+
32
+ # The time of initial creation
33
+ attr_accessor :created_at
34
+
35
+ # The time of last update
36
+ attr_accessor :updated_at
37
+
38
+ # The user-specified name of a localization
39
+ attr_accessor :name
40
+
41
+
42
+ # Attribute mapping from ruby-style variable name to JSON key.
43
+ def self.attribute_map
44
+ {
45
+ :'id' => :'id',
46
+ :'language' => :'language',
47
+ :'url' => :'url',
48
+ :'template' => :'template',
49
+ :'compiled' => :'compiled',
50
+ :'created_at' => :'createdAt',
51
+ :'updated_at' => :'updatedAt',
52
+ :'name' => :'name'
53
+ }
54
+ end
55
+
56
+ # Attribute type mapping.
57
+ def self.swagger_types
58
+ {
59
+ :'id' => :'String',
60
+ :'language' => :'String',
61
+ :'url' => :'String',
62
+ :'template' => :'String',
63
+ :'compiled' => :'CompiledRead',
64
+ :'created_at' => :'DateTime',
65
+ :'updated_at' => :'DateTime',
66
+ :'name' => :'String'
67
+ }
68
+ end
69
+
70
+ # Initializes the object
71
+ # @param [Hash] attributes Model attributes in the form of hash
72
+ def initialize(attributes = {})
73
+ return unless attributes.is_a?(Hash)
74
+
75
+ # convert string to symbol for hash key
76
+ attributes = attributes.each_with_object({}){|(k,v), h| h[k.to_sym] = v}
77
+
78
+ if attributes.has_key?(:'id')
79
+ self.id = attributes[:'id']
80
+ end
81
+
82
+ if attributes.has_key?(:'language')
83
+ self.language = attributes[:'language']
84
+ end
85
+
86
+ if attributes.has_key?(:'url')
87
+ self.url = attributes[:'url']
88
+ end
89
+
90
+ if attributes.has_key?(:'template')
91
+ self.template = attributes[:'template']
92
+ end
93
+
94
+ if attributes.has_key?(:'compiled')
95
+ self.compiled = attributes[:'compiled']
96
+ end
97
+
98
+ if attributes.has_key?(:'createdAt')
99
+ self.created_at = attributes[:'createdAt']
100
+ end
101
+
102
+ if attributes.has_key?(:'updatedAt')
103
+ self.updated_at = attributes[:'updatedAt']
104
+ end
105
+
106
+ if attributes.has_key?(:'name')
107
+ self.name = attributes[:'name']
108
+ end
109
+
110
+ end
111
+
112
+ # Show invalid properties with the reasons. Usually used together with valid?
113
+ # @return Array for valid properties with the reasons
114
+ def list_invalid_properties
115
+ invalid_properties = Array.new
116
+ return invalid_properties
117
+ end
118
+
119
+ # Check to see if the all the properties in the model are valid
120
+ # @return true if the model is valid
121
+ def valid?
122
+ return true
123
+ end
124
+
125
+ # Checks equality by comparing each attribute.
126
+ # @param [Object] Object to be compared
127
+ def ==(o)
128
+ return true if self.equal?(o)
129
+ self.class == o.class &&
130
+ id == o.id &&
131
+ language == o.language &&
132
+ url == o.url &&
133
+ template == o.template &&
134
+ compiled == o.compiled &&
135
+ created_at == o.created_at &&
136
+ updated_at == o.updated_at &&
137
+ name == o.name
138
+ end
139
+
140
+ # @see the `==` method
141
+ # @param [Object] Object to be compared
142
+ def eql?(o)
143
+ self == o
144
+ end
145
+
146
+ # Calculates hash code according to all attributes.
147
+ # @return [Fixnum] Hash code
148
+ def hash
149
+ [id, language, url, template, compiled, created_at, updated_at, name].hash
150
+ end
151
+
152
+ # Builds the object from hash
153
+ # @param [Hash] attributes Model attributes in the form of hash
154
+ # @return [Object] Returns the model itself
155
+ def build_from_hash(attributes)
156
+ return nil unless attributes.is_a?(Hash)
157
+ self.class.swagger_types.each_pair do |key, type|
158
+ if type =~ /\AArray<(.*)>/i
159
+ # check to ensure the input is an array given that the the attribute
160
+ # is documented as an array but the input is not
161
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
162
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map{ |v| _deserialize($1, v) } )
163
+ end
164
+ elsif !attributes[self.class.attribute_map[key]].nil?
165
+ self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
166
+ end # or else data not found in attributes(hash), not an issue as the data can be optional
167
+ end
168
+
169
+ self
170
+ end
171
+
172
+ # Deserializes the data based on type
173
+ # @param string type Data type
174
+ # @param string value Value to be deserialized
175
+ # @return [Object] Deserialized data
176
+ def _deserialize(type, value)
177
+ case type.to_sym
178
+ when :DateTime
179
+ DateTime.parse(value)
180
+ when :Date
181
+ Date.parse(value)
182
+ when :String
183
+ value.to_s
184
+ when :Integer
185
+ value.to_i
186
+ when :Float
187
+ value.to_f
188
+ when :BOOLEAN
189
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
190
+ true
191
+ else
192
+ false
193
+ end
194
+ when :Object
195
+ # generic object (usually a Hash), return directly
196
+ value
197
+ when /\AArray<(?<inner_type>.+)>\z/
198
+ inner_type = Regexp.last_match[:inner_type]
199
+ value.map { |v| _deserialize(inner_type, v) }
200
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
201
+ k_type = Regexp.last_match[:k_type]
202
+ v_type = Regexp.last_match[:v_type]
203
+ {}.tap do |hash|
204
+ value.each do |k, v|
205
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
206
+ end
207
+ end
208
+ else # model
209
+ temp_model = DyspatchClient.const_get(type).new
210
+ temp_model.build_from_hash(value)
211
+ end
212
+ end
213
+
214
+ # Returns the string representation of the object
215
+ # @return [String] String presentation of the object
216
+ def to_s
217
+ to_hash.to_s
218
+ end
219
+
220
+ # to_body is an alias to to_hash (backward compatibility)
221
+ # @return [Hash] Returns the object in the form of hash
222
+ def to_body
223
+ to_hash
224
+ end
225
+
226
+ # Returns the object in the form of hash
227
+ # @return [Hash] Returns the object in the form of hash
228
+ def to_hash
229
+ hash = {}
230
+ self.class.attribute_map.each_pair do |attr, param|
231
+ value = self.send(attr)
232
+ next if value.nil?
233
+ hash[param] = _to_hash(value)
234
+ end
235
+ hash
236
+ end
237
+
238
+ # Outputs non-array value in the form of hash
239
+ # For object, use to_hash. Otherwise, just return the value
240
+ # @param [Object] value Any valid value
241
+ # @return [Hash] Returns the value in the form of hash
242
+ def _to_hash(value)
243
+ if value.is_a?(Array)
244
+ value.compact.map{ |v| _to_hash(v) }
245
+ elsif value.is_a?(Hash)
246
+ {}.tap do |hash|
247
+ value.each { |k, v| hash[k] = _to_hash(v) }
248
+ end
249
+ elsif value.respond_to? :to_hash
250
+ value.to_hash
251
+ else
252
+ value
253
+ end
254
+ end
255
+
256
+ end
257
+
258
+ end