simplyrets 2.0.0 → 2.0.1

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 (93) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile.lock +6 -3
  3. data/Makefile +1 -2
  4. data/README.org +2 -0
  5. data/lib/simplyrets.rb +12 -1
  6. data/lib/simplyrets/api/default_api.rb +132 -128
  7. data/lib/simplyrets/api_client.rb +48 -9
  8. data/lib/simplyrets/api_client.rb.orig +373 -0
  9. data/lib/simplyrets/api_error.rb +12 -1
  10. data/lib/simplyrets/configuration.rb +23 -0
  11. data/lib/simplyrets/models/agent.rb +61 -27
  12. data/lib/simplyrets/models/broker.rb +57 -20
  13. data/lib/simplyrets/models/contact_information.rb +62 -27
  14. data/lib/simplyrets/models/error.rb +59 -23
  15. data/lib/simplyrets/models/geographic_data.rb +61 -28
  16. data/lib/simplyrets/models/listing.rb +94 -70
  17. data/lib/simplyrets/models/mls_information.rb +95 -37
  18. data/lib/simplyrets/models/office.rb +62 -28
  19. data/lib/simplyrets/models/open_house.rb +66 -36
  20. data/lib/simplyrets/models/parking.rb +59 -24
  21. data/lib/simplyrets/models/property.rb +128 -136
  22. data/lib/simplyrets/models/sales.rb +61 -28
  23. data/lib/simplyrets/models/school.rb +60 -34
  24. data/lib/simplyrets/models/street_address.rb +66 -55
  25. data/lib/simplyrets/models/tax.rb +70 -35
  26. data/lib/simplyrets/version.rb +13 -2
  27. data/ruby-client.meta +1 -0
  28. data/ruby-client.zip +0 -0
  29. data/ruby-client/.gitignore +50 -0
  30. data/ruby-client/.rspec +2 -0
  31. data/ruby-client/.swagger-codegen-ignore +23 -0
  32. data/ruby-client/LICENSE +201 -0
  33. data/ruby-client/README.md +128 -0
  34. data/ruby-client/docs/Agent.md +11 -0
  35. data/ruby-client/docs/Broker.md +8 -0
  36. data/ruby-client/docs/ContactInformation.md +10 -0
  37. data/ruby-client/docs/DefaultApi.md +306 -0
  38. data/ruby-client/docs/Error.md +9 -0
  39. data/ruby-client/docs/GeographicData.md +12 -0
  40. data/ruby-client/docs/Listing.md +30 -0
  41. data/ruby-client/docs/MlsInformation.md +11 -0
  42. data/ruby-client/docs/Office.md +11 -0
  43. data/ruby-client/docs/OpenHouse.md +15 -0
  44. data/ruby-client/docs/Parking.md +10 -0
  45. data/ruby-client/docs/Property.md +43 -0
  46. data/ruby-client/docs/Sales.md +12 -0
  47. data/ruby-client/docs/School.md +11 -0
  48. data/ruby-client/docs/StreetAddress.md +16 -0
  49. data/ruby-client/docs/Tax.md +10 -0
  50. data/ruby-client/git_push.sh +67 -0
  51. data/ruby-client/lib/swagger_client.rb +66 -0
  52. data/ruby-client/lib/swagger_client/api/default_api.rb +383 -0
  53. data/ruby-client/lib/swagger_client/api_client.rb +373 -0
  54. data/ruby-client/lib/swagger_client/api_error.rb +47 -0
  55. data/ruby-client/lib/swagger_client/configuration.rb +193 -0
  56. data/ruby-client/lib/swagger_client/models/agent.rb +230 -0
  57. data/ruby-client/lib/swagger_client/models/broker.rb +200 -0
  58. data/ruby-client/lib/swagger_client/models/contact_information.rb +220 -0
  59. data/ruby-client/lib/swagger_client/models/error.rb +210 -0
  60. data/ruby-client/lib/swagger_client/models/geographic_data.rb +240 -0
  61. data/ruby-client/lib/swagger_client/models/listing.rb +422 -0
  62. data/ruby-client/lib/swagger_client/models/mls_information.rb +263 -0
  63. data/ruby-client/lib/swagger_client/models/office.rb +230 -0
  64. data/ruby-client/lib/swagger_client/models/open_house.rb +270 -0
  65. data/ruby-client/lib/swagger_client/models/parking.rb +219 -0
  66. data/ruby-client/lib/swagger_client/models/property.rb +574 -0
  67. data/ruby-client/lib/swagger_client/models/sales.rb +240 -0
  68. data/ruby-client/lib/swagger_client/models/school.rb +230 -0
  69. data/ruby-client/lib/swagger_client/models/street_address.rb +280 -0
  70. data/ruby-client/lib/swagger_client/models/tax.rb +220 -0
  71. data/ruby-client/lib/swagger_client/version.rb +26 -0
  72. data/ruby-client/spec/api/default_api_spec.rb +132 -0
  73. data/ruby-client/spec/api_client_spec.rb +296 -0
  74. data/ruby-client/spec/configuration_spec.rb +48 -0
  75. data/ruby-client/spec/models/agent_spec.rb +71 -0
  76. data/ruby-client/spec/models/broker_spec.rb +53 -0
  77. data/ruby-client/spec/models/contact_information_spec.rb +65 -0
  78. data/ruby-client/spec/models/error_spec.rb +59 -0
  79. data/ruby-client/spec/models/geographic_data_spec.rb +77 -0
  80. data/ruby-client/spec/models/listing_spec.rb +185 -0
  81. data/ruby-client/spec/models/mls_information_spec.rb +74 -0
  82. data/ruby-client/spec/models/office_spec.rb +71 -0
  83. data/ruby-client/spec/models/open_house_spec.rb +95 -0
  84. data/ruby-client/spec/models/parking_spec.rb +65 -0
  85. data/ruby-client/spec/models/property_spec.rb +266 -0
  86. data/ruby-client/spec/models/sales_spec.rb +77 -0
  87. data/ruby-client/spec/models/school_spec.rb +71 -0
  88. data/ruby-client/spec/models/street_address_spec.rb +101 -0
  89. data/ruby-client/spec/models/tax_spec.rb +65 -0
  90. data/ruby-client/spec/spec_helper.rb +122 -0
  91. data/ruby-client/swagger_client.gemspec +55 -0
  92. data/simplyrets.gemspec +1 -1
  93. metadata +71 -5
@@ -0,0 +1,240 @@
1
+ =begin
2
+ SimplyRETS API
3
+
4
+ The SimplyRETS API is an exciting step towards making it easier for developers and real estate agents to build something awesome with real estate data! The documentation below makes live requests to our API using the trial data. To get set up with the API using live MLS data, you must have RETS credentials from your MLS, which you can then use to create an app with SimplyRETS. For more information on that process, please see our [FAQ](https://simplyrets.com/faq), [Getting Started](https://simplyrets.com/blog/getting-set-up.html) page, or [contact us](https://simplyrets.com/\\#home-contact). Below you'll find the API endpoints, query parameters, response bodies, and other information about using the SimplyRETS API. You can run queries by clicking the 'Try it Out' button at the bottom of each section. ### Authentication The SimplyRETS API uses Basic Authentication. When you create an app, you'll get a set of API credentials to access your listings. If you're trying out the test data, you can use `simplyrets:simplyrets` for connecting to the API. ### Media Types The SimplyRETS API uses the `Accept` header to allow clients to control media types (content versions). We maintain backwards compatibility with API clients by allowing them to specify a content version. We highly recommend setting and explicity media type when your application reaches production. Both the structure and content of our API response bodies is subject to change so we can add new features while respecting the stability of applications which have already been developed. To always use the latest SimplyRETS content version, simply use `application/json` in your application `Accept` header. If you want to pin your clients media type to a specific version, you can use the vendor-specific SimplyRETS media type, e.g. `application/vnd.simplyrets-v0.1+json\"` To view all valid content-types for making an `OPTIONS`, make a request to the SimplyRETS api root `curl -XOPTIONS -u simplyrets:simplyrets https://api.simplyrets.com/` The default media types used in our API responses may change in the future. If you're building an application and care about the stability of the API, be sure to request a specific media type in the Accept header as shown in the examples below. The wordpress plugin automatically sets the `Accept` header for the compatible SimplyRETS media types. ### Pagination There a few pieces of useful information about each request stored in the HTTP Headers: - `X-Total-Count` shows you the total amount of listings that match your current query. - `Link` contains pre-built pagination links for accessing the next 'page' of listings that match your query. Read more about that [here](https://simplyrets.com/blog/api-pagination.html).
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 SwaggerClient
27
+ # Sales Data
28
+ class Sales
29
+ # RETS Sales data close date
30
+ attr_accessor :close_date
31
+
32
+ # RETS Sales data selling office/brokerage id
33
+ attr_accessor :office
34
+
35
+ # RETS Sales data sold price
36
+ attr_accessor :close_price
37
+
38
+ # RETS Sales data agent id
39
+ attr_accessor :agent
40
+
41
+ # RETS Sales data contract date
42
+ attr_accessor :contract_date
43
+
44
+
45
+ # Attribute mapping from ruby-style variable name to JSON key.
46
+ def self.attribute_map
47
+ {
48
+ :'close_date' => :'closeDate',
49
+ :'office' => :'office',
50
+ :'close_price' => :'closePrice',
51
+ :'agent' => :'agent',
52
+ :'contract_date' => :'contractDate'
53
+ }
54
+ end
55
+
56
+ # Attribute type mapping.
57
+ def self.swagger_types
58
+ {
59
+ :'close_date' => :'DateTime',
60
+ :'office' => :'String',
61
+ :'close_price' => :'Integer',
62
+ :'agent' => :'String',
63
+ :'contract_date' => :'DateTime'
64
+ }
65
+ end
66
+
67
+ # Initializes the object
68
+ # @param [Hash] attributes Model attributes in the form of hash
69
+ def initialize(attributes = {})
70
+ return unless attributes.is_a?(Hash)
71
+
72
+ # convert string to symbol for hash key
73
+ attributes = attributes.each_with_object({}){|(k,v), h| h[k.to_sym] = v}
74
+
75
+ if attributes.has_key?(:'closeDate')
76
+ self.close_date = attributes[:'closeDate']
77
+ end
78
+
79
+ if attributes.has_key?(:'office')
80
+ self.office = attributes[:'office']
81
+ end
82
+
83
+ if attributes.has_key?(:'closePrice')
84
+ self.close_price = attributes[:'closePrice']
85
+ end
86
+
87
+ if attributes.has_key?(:'agent')
88
+ self.agent = attributes[:'agent']
89
+ end
90
+
91
+ if attributes.has_key?(:'contractDate')
92
+ self.contract_date = attributes[:'contractDate']
93
+ end
94
+
95
+ end
96
+
97
+ # Show invalid properties with the reasons. Usually used together with valid?
98
+ # @return Array for valid properies with the reasons
99
+ def list_invalid_properties
100
+ invalid_properties = Array.new
101
+ return invalid_properties
102
+ end
103
+
104
+ # Check to see if the all the properties in the model are valid
105
+ # @return true if the model is valid
106
+ def valid?
107
+ return true
108
+ end
109
+
110
+ # Checks equality by comparing each attribute.
111
+ # @param [Object] Object to be compared
112
+ def ==(o)
113
+ return true if self.equal?(o)
114
+ self.class == o.class &&
115
+ close_date == o.close_date &&
116
+ office == o.office &&
117
+ close_price == o.close_price &&
118
+ agent == o.agent &&
119
+ contract_date == o.contract_date
120
+ end
121
+
122
+ # @see the `==` method
123
+ # @param [Object] Object to be compared
124
+ def eql?(o)
125
+ self == o
126
+ end
127
+
128
+ # Calculates hash code according to all attributes.
129
+ # @return [Fixnum] Hash code
130
+ def hash
131
+ [close_date, office, close_price, agent, contract_date].hash
132
+ end
133
+
134
+ # Builds the object from hash
135
+ # @param [Hash] attributes Model attributes in the form of hash
136
+ # @return [Object] Returns the model itself
137
+ def build_from_hash(attributes)
138
+ return nil unless attributes.is_a?(Hash)
139
+ self.class.swagger_types.each_pair do |key, type|
140
+ if type =~ /^Array<(.*)>/i
141
+ # check to ensure the input is an array given that the the attribute
142
+ # is documented as an array but the input is not
143
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
144
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map{ |v| _deserialize($1, v) } )
145
+ end
146
+ elsif !attributes[self.class.attribute_map[key]].nil?
147
+ self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
148
+ end # or else data not found in attributes(hash), not an issue as the data can be optional
149
+ end
150
+
151
+ self
152
+ end
153
+
154
+ # Deserializes the data based on type
155
+ # @param string type Data type
156
+ # @param string value Value to be deserialized
157
+ # @return [Object] Deserialized data
158
+ def _deserialize(type, value)
159
+ case type.to_sym
160
+ when :DateTime
161
+ DateTime.parse(value)
162
+ when :Date
163
+ Date.parse(value)
164
+ when :String
165
+ value.to_s
166
+ when :Integer
167
+ value.to_i
168
+ when :Float
169
+ value.to_f
170
+ when :BOOLEAN
171
+ if value.to_s =~ /^(true|t|yes|y|1)$/i
172
+ true
173
+ else
174
+ false
175
+ end
176
+ when :Object
177
+ # generic object (usually a Hash), return directly
178
+ value
179
+ when /\AArray<(?<inner_type>.+)>\z/
180
+ inner_type = Regexp.last_match[:inner_type]
181
+ value.map { |v| _deserialize(inner_type, v) }
182
+ when /\AHash<(?<k_type>.+), (?<v_type>.+)>\z/
183
+ k_type = Regexp.last_match[:k_type]
184
+ v_type = Regexp.last_match[:v_type]
185
+ {}.tap do |hash|
186
+ value.each do |k, v|
187
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
188
+ end
189
+ end
190
+ else # model
191
+ temp_model = SwaggerClient.const_get(type).new
192
+ temp_model.build_from_hash(value)
193
+ end
194
+ end
195
+
196
+ # Returns the string representation of the object
197
+ # @return [String] String presentation of the object
198
+ def to_s
199
+ to_hash.to_s
200
+ end
201
+
202
+ # to_body is an alias to to_hash (backward compatibility)
203
+ # @return [Hash] Returns the object in the form of hash
204
+ def to_body
205
+ to_hash
206
+ end
207
+
208
+ # Returns the object in the form of hash
209
+ # @return [Hash] Returns the object in the form of hash
210
+ def to_hash
211
+ hash = {}
212
+ self.class.attribute_map.each_pair do |attr, param|
213
+ value = self.send(attr)
214
+ next if value.nil?
215
+ hash[param] = _to_hash(value)
216
+ end
217
+ hash
218
+ end
219
+
220
+ # Outputs non-array value in the form of hash
221
+ # For object, use to_hash. Otherwise, just return the value
222
+ # @param [Object] value Any valid value
223
+ # @return [Hash] Returns the value in the form of hash
224
+ def _to_hash(value)
225
+ if value.is_a?(Array)
226
+ value.compact.map{ |v| _to_hash(v) }
227
+ elsif value.is_a?(Hash)
228
+ {}.tap do |hash|
229
+ value.each { |k, v| hash[k] = _to_hash(v) }
230
+ end
231
+ elsif value.respond_to? :to_hash
232
+ value.to_hash
233
+ else
234
+ value
235
+ end
236
+ end
237
+
238
+ end
239
+
240
+ end
@@ -0,0 +1,230 @@
1
+ =begin
2
+ SimplyRETS API
3
+
4
+ The SimplyRETS API is an exciting step towards making it easier for developers and real estate agents to build something awesome with real estate data! The documentation below makes live requests to our API using the trial data. To get set up with the API using live MLS data, you must have RETS credentials from your MLS, which you can then use to create an app with SimplyRETS. For more information on that process, please see our [FAQ](https://simplyrets.com/faq), [Getting Started](https://simplyrets.com/blog/getting-set-up.html) page, or [contact us](https://simplyrets.com/\\#home-contact). Below you'll find the API endpoints, query parameters, response bodies, and other information about using the SimplyRETS API. You can run queries by clicking the 'Try it Out' button at the bottom of each section. ### Authentication The SimplyRETS API uses Basic Authentication. When you create an app, you'll get a set of API credentials to access your listings. If you're trying out the test data, you can use `simplyrets:simplyrets` for connecting to the API. ### Media Types The SimplyRETS API uses the `Accept` header to allow clients to control media types (content versions). We maintain backwards compatibility with API clients by allowing them to specify a content version. We highly recommend setting and explicity media type when your application reaches production. Both the structure and content of our API response bodies is subject to change so we can add new features while respecting the stability of applications which have already been developed. To always use the latest SimplyRETS content version, simply use `application/json` in your application `Accept` header. If you want to pin your clients media type to a specific version, you can use the vendor-specific SimplyRETS media type, e.g. `application/vnd.simplyrets-v0.1+json\"` To view all valid content-types for making an `OPTIONS`, make a request to the SimplyRETS api root `curl -XOPTIONS -u simplyrets:simplyrets https://api.simplyrets.com/` The default media types used in our API responses may change in the future. If you're building an application and care about the stability of the API, be sure to request a specific media type in the Accept header as shown in the examples below. The wordpress plugin automatically sets the `Accept` header for the compatible SimplyRETS media types. ### Pagination There a few pieces of useful information about each request stored in the HTTP Headers: - `X-Total-Count` shows you the total amount of listings that match your current query. - `Link` contains pre-built pagination links for accessing the next 'page' of listings that match your query. Read more about that [here](https://simplyrets.com/blog/api-pagination.html).
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 SwaggerClient
27
+ # RETS MLS School Data
28
+ class School
29
+ # Middle or junior school name
30
+ attr_accessor :middle_school
31
+
32
+ # High school name
33
+ attr_accessor :high_school
34
+
35
+ # Elementary school name.
36
+ attr_accessor :elementary_school
37
+
38
+ # School district name.
39
+ attr_accessor :district
40
+
41
+
42
+ # Attribute mapping from ruby-style variable name to JSON key.
43
+ def self.attribute_map
44
+ {
45
+ :'middle_school' => :'middleSchool',
46
+ :'high_school' => :'highSchool',
47
+ :'elementary_school' => :'elementarySchool',
48
+ :'district' => :'district'
49
+ }
50
+ end
51
+
52
+ # Attribute type mapping.
53
+ def self.swagger_types
54
+ {
55
+ :'middle_school' => :'String',
56
+ :'high_school' => :'String',
57
+ :'elementary_school' => :'String',
58
+ :'district' => :'String'
59
+ }
60
+ end
61
+
62
+ # Initializes the object
63
+ # @param [Hash] attributes Model attributes in the form of hash
64
+ def initialize(attributes = {})
65
+ return unless attributes.is_a?(Hash)
66
+
67
+ # convert string to symbol for hash key
68
+ attributes = attributes.each_with_object({}){|(k,v), h| h[k.to_sym] = v}
69
+
70
+ if attributes.has_key?(:'middleSchool')
71
+ self.middle_school = attributes[:'middleSchool']
72
+ end
73
+
74
+ if attributes.has_key?(:'highSchool')
75
+ self.high_school = attributes[:'highSchool']
76
+ end
77
+
78
+ if attributes.has_key?(:'elementarySchool')
79
+ self.elementary_school = attributes[:'elementarySchool']
80
+ end
81
+
82
+ if attributes.has_key?(:'district')
83
+ self.district = attributes[:'district']
84
+ end
85
+
86
+ end
87
+
88
+ # Show invalid properties with the reasons. Usually used together with valid?
89
+ # @return Array for valid properies with the reasons
90
+ def list_invalid_properties
91
+ invalid_properties = Array.new
92
+ return invalid_properties
93
+ end
94
+
95
+ # Check to see if the all the properties in the model are valid
96
+ # @return true if the model is valid
97
+ def valid?
98
+ return true
99
+ end
100
+
101
+ # Checks equality by comparing each attribute.
102
+ # @param [Object] Object to be compared
103
+ def ==(o)
104
+ return true if self.equal?(o)
105
+ self.class == o.class &&
106
+ middle_school == o.middle_school &&
107
+ high_school == o.high_school &&
108
+ elementary_school == o.elementary_school &&
109
+ district == o.district
110
+ end
111
+
112
+ # @see the `==` method
113
+ # @param [Object] Object to be compared
114
+ def eql?(o)
115
+ self == o
116
+ end
117
+
118
+ # Calculates hash code according to all attributes.
119
+ # @return [Fixnum] Hash code
120
+ def hash
121
+ [middle_school, high_school, elementary_school, district].hash
122
+ end
123
+
124
+ # Builds the object from hash
125
+ # @param [Hash] attributes Model attributes in the form of hash
126
+ # @return [Object] Returns the model itself
127
+ def build_from_hash(attributes)
128
+ return nil unless attributes.is_a?(Hash)
129
+ self.class.swagger_types.each_pair do |key, type|
130
+ if type =~ /^Array<(.*)>/i
131
+ # check to ensure the input is an array given that the the attribute
132
+ # is documented as an array but the input is not
133
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
134
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map{ |v| _deserialize($1, v) } )
135
+ end
136
+ elsif !attributes[self.class.attribute_map[key]].nil?
137
+ self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
138
+ end # or else data not found in attributes(hash), not an issue as the data can be optional
139
+ end
140
+
141
+ self
142
+ end
143
+
144
+ # Deserializes the data based on type
145
+ # @param string type Data type
146
+ # @param string value Value to be deserialized
147
+ # @return [Object] Deserialized data
148
+ def _deserialize(type, value)
149
+ case type.to_sym
150
+ when :DateTime
151
+ DateTime.parse(value)
152
+ when :Date
153
+ Date.parse(value)
154
+ when :String
155
+ value.to_s
156
+ when :Integer
157
+ value.to_i
158
+ when :Float
159
+ value.to_f
160
+ when :BOOLEAN
161
+ if value.to_s =~ /^(true|t|yes|y|1)$/i
162
+ true
163
+ else
164
+ false
165
+ end
166
+ when :Object
167
+ # generic object (usually a Hash), return directly
168
+ value
169
+ when /\AArray<(?<inner_type>.+)>\z/
170
+ inner_type = Regexp.last_match[:inner_type]
171
+ value.map { |v| _deserialize(inner_type, v) }
172
+ when /\AHash<(?<k_type>.+), (?<v_type>.+)>\z/
173
+ k_type = Regexp.last_match[:k_type]
174
+ v_type = Regexp.last_match[:v_type]
175
+ {}.tap do |hash|
176
+ value.each do |k, v|
177
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
178
+ end
179
+ end
180
+ else # model
181
+ temp_model = SwaggerClient.const_get(type).new
182
+ temp_model.build_from_hash(value)
183
+ end
184
+ end
185
+
186
+ # Returns the string representation of the object
187
+ # @return [String] String presentation of the object
188
+ def to_s
189
+ to_hash.to_s
190
+ end
191
+
192
+ # to_body is an alias to to_hash (backward compatibility)
193
+ # @return [Hash] Returns the object in the form of hash
194
+ def to_body
195
+ to_hash
196
+ end
197
+
198
+ # Returns the object in the form of hash
199
+ # @return [Hash] Returns the object in the form of hash
200
+ def to_hash
201
+ hash = {}
202
+ self.class.attribute_map.each_pair do |attr, param|
203
+ value = self.send(attr)
204
+ next if value.nil?
205
+ hash[param] = _to_hash(value)
206
+ end
207
+ hash
208
+ end
209
+
210
+ # Outputs non-array value in the form of hash
211
+ # For object, use to_hash. Otherwise, just return the value
212
+ # @param [Object] value Any valid value
213
+ # @return [Hash] Returns the value in the form of hash
214
+ def _to_hash(value)
215
+ if value.is_a?(Array)
216
+ value.compact.map{ |v| _to_hash(v) }
217
+ elsif value.is_a?(Hash)
218
+ {}.tap do |hash|
219
+ value.each { |k, v| hash[k] = _to_hash(v) }
220
+ end
221
+ elsif value.respond_to? :to_hash
222
+ value.to_hash
223
+ else
224
+ value
225
+ end
226
+ end
227
+
228
+ end
229
+
230
+ end