simplyrets 1.0.7 → 2.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +23 -21
- data/Makefile +48 -0
- data/README.org +5 -58
- data/example.rb +14 -4
- data/lib/simplyrets.rb +42 -21
- data/lib/simplyrets/api/default_api.rb +292 -59
- data/lib/simplyrets/api_client.rb +370 -0
- data/lib/simplyrets/api_error.rb +36 -0
- data/lib/simplyrets/configuration.rb +170 -0
- data/lib/simplyrets/models/agent.rb +146 -11
- data/lib/simplyrets/models/broker.rb +133 -7
- data/lib/simplyrets/models/contact_information.rb +149 -17
- data/lib/simplyrets/models/error.rb +138 -9
- data/lib/simplyrets/models/geographic_data.rb +150 -12
- data/lib/simplyrets/models/listing.rb +248 -49
- data/lib/simplyrets/models/mls_information.rb +148 -12
- data/lib/simplyrets/models/office.rb +146 -11
- data/lib/simplyrets/models/open_house.rb +215 -12
- data/lib/simplyrets/models/parking.rb +148 -17
- data/lib/simplyrets/models/property.rb +353 -129
- data/lib/simplyrets/models/sales.rb +163 -25
- data/lib/simplyrets/models/school.rb +167 -24
- data/lib/simplyrets/models/street_address.rb +204 -26
- data/lib/simplyrets/models/tax.rb +150 -18
- data/lib/simplyrets/version.rb +15 -0
- data/multi-query-param.patch +44 -0
- data/simplyrets.gemspec +4 -4
- data/spec/api/default_api_spec.rb +172 -0
- data/spec/models/agent_spec.rb +75 -0
- data/spec/models/broker_spec.rb +45 -0
- data/spec/models/contact_information_spec.rb +65 -0
- data/spec/models/error_spec.rb +55 -0
- data/spec/models/geographic_data_spec.rb +85 -0
- data/spec/models/listing_spec.rb +245 -0
- data/spec/models/mls_information_spec.rb +75 -0
- data/spec/models/office_spec.rb +75 -0
- data/spec/models/open_house_spec.rb +115 -0
- data/spec/models/parking_spec.rb +65 -0
- data/spec/models/property_spec.rb +365 -0
- data/spec/models/sales_spec.rb +85 -0
- data/spec/models/school_spec.rb +75 -0
- data/spec/models/street_address_spec.rb +105 -0
- data/spec/models/tax_spec.rb +65 -0
- data/spec/spec_helper.rb +78 -0
- metadata +33 -18
- data/lib/simplyrets.rb~ +0 -34
- data/lib/simplyrets/api/#default_api.rb# +0 -146
- data/lib/simplyrets/simplyrets/api_error.rb +0 -26
- data/lib/simplyrets/simplyrets/configuration.rb +0 -101
- data/lib/simplyrets/simplyrets/request.rb +0 -248
- data/lib/simplyrets/simplyrets/response.rb +0 -156
- data/lib/simplyrets/simplyrets/version.rb +0 -5
- data/simplyrets-1.0.6.gem +0 -0
@@ -1,68 +1,206 @@
|
|
1
|
+
=begin
|
2
|
+
SimplyRETS API
|
3
|
+
|
4
|
+
The SimplyRETS API is an exciting step towards making it easier for\ndevelopers and real estate agents to build something awesome with\nreal estate data!\n\nThe documentation below makes live requests to our API using the\ntrial data. To get set up with the API using live MLS data, you\nmust have RETS credentials from your MLS, which you can then use to\ncreate an app with SimplyRETS. For more information on that\nprocess, please see our [FAQ](https://simplyrets.com/faq), [Getting\nStarted](https://simplyrets.com/blog/getting-set-up.html) page, or\n[contact us](https://simplyrets.com/\\#home-contact).\n\nBelow you'll find the API endpoints, query parameters, response bodies,\nand other information about using the SimplyRETS API. You can run\nqueries by clicking the 'Try it Out' button at the bottom of each\nsection.\n\n### Authentication\nThe SimplyRETS API uses Basic Authentication. When you create an\napp, you'll get a set of API credentials to access your\nlistings. If you're trying out the test data, you can use\n`simplyrets:simplyrets` for connecting to the API.\n\n### Media Types\nThe SimplyRETS API uses the `Accept` header to allow clients to\ncontrol media types (content versions). We maintain backwards\ncompatibility with API clients by allowing them to specify a\ncontent version. We highly recommend setting and explicity media\ntype when your application reaches production. Both the structure\nand content of our API response bodies is subject to change so we\ncan add new features while respecting the stability of applications\nwhich have already been developed.\n\nTo always use the latest SimplyRETS content version, simply use\n`application/json` in your application `Accept` header.\n\nIf you want to pin your clients media type to a specific version,\nyou can use the vendor-specific SimplyRETS media type, e.g.\n`application/vnd.simplyrets-v0.1+json\"`\n\nTo view all valid content-types for making an `OPTIONS`, make a\nrequest to the SimplyRETS api root\n\n`curl -XOPTIONS -u simplyrets:simplyrets https://api.simplyrets.com/`\n\nThe default media types used in our API responses may change in the\nfuture. If you're building an application and care about the\nstability of the API, be sure to request a specific media type in the\nAccept header as shown in the examples below.\n\nThe wordpress plugin automatically sets the `Accept` header for the\ncompatible SimplyRETS media types.\n\n### Pagination\nThere a few pieces of useful information about each request stored\nin the HTTP Headers:\n\n- `X-Total-Count` shows you the total amount of listings that match\n your current query.\n- `Link` contains pre-built pagination links for accessing the next\n'page' of listings that match your query. Read more about that\n[here](https://simplyrets.com/blog/api-pagination.html).\n
|
5
|
+
|
6
|
+
OpenAPI spec version: 1.0.0
|
7
|
+
|
8
|
+
Generated by: https://github.com/swagger-api/swagger-codegen.git
|
9
|
+
|
10
|
+
|
11
|
+
=end
|
12
|
+
|
13
|
+
require 'date'
|
14
|
+
|
1
15
|
module SimplyRetsClient
|
2
|
-
#
|
3
|
-
class Sales
|
4
|
-
|
5
|
-
|
16
|
+
# Sales Data
|
17
|
+
class Sales
|
18
|
+
# RETS Sales data close date
|
19
|
+
attr_accessor :close_date
|
20
|
+
|
21
|
+
# RETS Sales data selling office/brokerage id
|
22
|
+
attr_accessor :office
|
23
|
+
|
24
|
+
# RETS Sales data sold price
|
25
|
+
attr_accessor :close_price
|
26
|
+
|
27
|
+
# RETS Sales data agent id
|
28
|
+
attr_accessor :agent
|
29
|
+
|
30
|
+
# RETS Sales data contract date
|
31
|
+
attr_accessor :contract_date
|
32
|
+
|
33
|
+
# Attribute mapping from ruby-style variable name to JSON key.
|
6
34
|
def self.attribute_map
|
7
35
|
{
|
8
36
|
|
9
|
-
# RETS Sales data agent id
|
10
|
-
:'agent' => :'agent',
|
11
|
-
|
12
|
-
# RETS Sales data close date
|
13
37
|
:'close_date' => :'closeDate',
|
14
38
|
|
15
|
-
|
39
|
+
:'office' => :'office',
|
40
|
+
|
16
41
|
:'close_price' => :'closePrice',
|
17
42
|
|
18
|
-
|
19
|
-
:'contract_date' => :'contractDate',
|
43
|
+
:'agent' => :'agent',
|
20
44
|
|
21
|
-
|
22
|
-
:'office' => :'office'
|
45
|
+
:'contract_date' => :'contractDate'
|
23
46
|
|
24
47
|
}
|
25
48
|
end
|
26
49
|
|
27
|
-
#
|
28
|
-
def self.
|
50
|
+
# Attribute type mapping.
|
51
|
+
def self.swagger_types
|
29
52
|
{
|
30
|
-
:'agent' => :'String',
|
31
53
|
:'close_date' => :'DateTime',
|
54
|
+
:'office' => :'String',
|
32
55
|
:'close_price' => :'Integer',
|
33
|
-
:'
|
34
|
-
:'
|
56
|
+
:'agent' => :'String',
|
57
|
+
:'contract_date' => :'DateTime'
|
35
58
|
|
36
59
|
}
|
37
60
|
end
|
38
61
|
|
39
62
|
def initialize(attributes = {})
|
40
|
-
return
|
63
|
+
return unless attributes.is_a?(Hash)
|
41
64
|
|
42
65
|
# convert string to symbol for hash key
|
43
66
|
attributes = attributes.inject({}){|memo,(k,v)| memo[k.to_sym] = v; memo}
|
44
67
|
|
45
68
|
|
46
|
-
if attributes[:'agent']
|
47
|
-
self.agent = attributes[:'agent']
|
48
|
-
end
|
49
|
-
|
50
69
|
if attributes[:'closeDate']
|
51
70
|
self.close_date = attributes[:'closeDate']
|
52
71
|
end
|
53
72
|
|
73
|
+
if attributes[:'office']
|
74
|
+
self.office = attributes[:'office']
|
75
|
+
end
|
76
|
+
|
54
77
|
if attributes[:'closePrice']
|
55
78
|
self.close_price = attributes[:'closePrice']
|
56
79
|
end
|
57
80
|
|
81
|
+
if attributes[:'agent']
|
82
|
+
self.agent = attributes[:'agent']
|
83
|
+
end
|
84
|
+
|
58
85
|
if attributes[:'contractDate']
|
59
86
|
self.contract_date = attributes[:'contractDate']
|
60
87
|
end
|
61
88
|
|
62
|
-
|
63
|
-
|
89
|
+
end
|
90
|
+
|
91
|
+
# Check equality by comparing each attribute.
|
92
|
+
def ==(o)
|
93
|
+
return true if self.equal?(o)
|
94
|
+
self.class == o.class &&
|
95
|
+
close_date == o.close_date &&
|
96
|
+
office == o.office &&
|
97
|
+
close_price == o.close_price &&
|
98
|
+
agent == o.agent &&
|
99
|
+
contract_date == o.contract_date
|
100
|
+
end
|
101
|
+
|
102
|
+
# @see the `==` method
|
103
|
+
def eql?(o)
|
104
|
+
self == o
|
105
|
+
end
|
106
|
+
|
107
|
+
# Calculate hash code according to all attributes.
|
108
|
+
def hash
|
109
|
+
[close_date, office, close_price, agent, contract_date].hash
|
110
|
+
end
|
111
|
+
|
112
|
+
# build the object from hash
|
113
|
+
def build_from_hash(attributes)
|
114
|
+
return nil unless attributes.is_a?(Hash)
|
115
|
+
self.class.swagger_types.each_pair do |key, type|
|
116
|
+
if type =~ /^Array<(.*)>/i
|
117
|
+
if attributes[self.class.attribute_map[key]].is_a?(Array)
|
118
|
+
self.send("#{key}=", attributes[self.class.attribute_map[key]].map{ |v| _deserialize($1, v) } )
|
119
|
+
else
|
120
|
+
#TODO show warning in debug mode
|
121
|
+
end
|
122
|
+
elsif !attributes[self.class.attribute_map[key]].nil?
|
123
|
+
self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
|
124
|
+
else
|
125
|
+
# data not found in attributes(hash), not an issue as the data can be optional
|
126
|
+
end
|
64
127
|
end
|
65
128
|
|
129
|
+
self
|
130
|
+
end
|
131
|
+
|
132
|
+
def _deserialize(type, value)
|
133
|
+
case type.to_sym
|
134
|
+
when :DateTime
|
135
|
+
DateTime.parse(value)
|
136
|
+
when :Date
|
137
|
+
Date.parse(value)
|
138
|
+
when :String
|
139
|
+
value.to_s
|
140
|
+
when :Integer
|
141
|
+
value.to_i
|
142
|
+
when :Float
|
143
|
+
value.to_f
|
144
|
+
when :BOOLEAN
|
145
|
+
if value.to_s =~ /^(true|t|yes|y|1)$/i
|
146
|
+
true
|
147
|
+
else
|
148
|
+
false
|
149
|
+
end
|
150
|
+
when :Object
|
151
|
+
# generic object (usually a Hash), return directly
|
152
|
+
value
|
153
|
+
when /\AArray<(?<inner_type>.+)>\z/
|
154
|
+
inner_type = Regexp.last_match[:inner_type]
|
155
|
+
value.map { |v| _deserialize(inner_type, v) }
|
156
|
+
when /\AHash<(?<k_type>.+), (?<v_type>.+)>\z/
|
157
|
+
k_type = Regexp.last_match[:k_type]
|
158
|
+
v_type = Regexp.last_match[:v_type]
|
159
|
+
{}.tap do |hash|
|
160
|
+
value.each do |k, v|
|
161
|
+
hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
|
162
|
+
end
|
163
|
+
end
|
164
|
+
else # model
|
165
|
+
_model = SimplyRetsClient.const_get(type).new
|
166
|
+
_model.build_from_hash(value)
|
167
|
+
end
|
168
|
+
end
|
169
|
+
|
170
|
+
def to_s
|
171
|
+
to_hash.to_s
|
172
|
+
end
|
173
|
+
|
174
|
+
# to_body is an alias to to_body (backward compatibility))
|
175
|
+
def to_body
|
176
|
+
to_hash
|
177
|
+
end
|
178
|
+
|
179
|
+
# return the object in the form of hash
|
180
|
+
def to_hash
|
181
|
+
hash = {}
|
182
|
+
self.class.attribute_map.each_pair do |attr, param|
|
183
|
+
value = self.send(attr)
|
184
|
+
next if value.nil?
|
185
|
+
hash[param] = _to_hash(value)
|
186
|
+
end
|
187
|
+
hash
|
188
|
+
end
|
189
|
+
|
190
|
+
# Method to output non-array value in the form of hash
|
191
|
+
# For object, use to_hash. Otherwise, just return the value
|
192
|
+
def _to_hash(value)
|
193
|
+
if value.is_a?(Array)
|
194
|
+
value.compact.map{ |v| _to_hash(v) }
|
195
|
+
elsif value.is_a?(Hash)
|
196
|
+
{}.tap do |hash|
|
197
|
+
value.each { |k, v| hash[k] = _to_hash(v) }
|
198
|
+
end
|
199
|
+
elsif value.respond_to? :to_hash
|
200
|
+
value.to_hash
|
201
|
+
else
|
202
|
+
value
|
203
|
+
end
|
66
204
|
end
|
67
205
|
|
68
206
|
end
|
@@ -1,60 +1,203 @@
|
|
1
|
+
=begin
|
2
|
+
SimplyRETS API
|
3
|
+
|
4
|
+
The SimplyRETS API is an exciting step towards making it easier for\ndevelopers and real estate agents to build something awesome with\nreal estate data!\n\nThe documentation below makes live requests to our API using the\ntrial data. To get set up with the API using live MLS data, you\nmust have RETS credentials from your MLS, which you can then use to\ncreate an app with SimplyRETS. For more information on that\nprocess, please see our [FAQ](https://simplyrets.com/faq), [Getting\nStarted](https://simplyrets.com/blog/getting-set-up.html) page, or\n[contact us](https://simplyrets.com/\\#home-contact).\n\nBelow you'll find the API endpoints, query parameters, response bodies,\nand other information about using the SimplyRETS API. You can run\nqueries by clicking the 'Try it Out' button at the bottom of each\nsection.\n\n### Authentication\nThe SimplyRETS API uses Basic Authentication. When you create an\napp, you'll get a set of API credentials to access your\nlistings. If you're trying out the test data, you can use\n`simplyrets:simplyrets` for connecting to the API.\n\n### Media Types\nThe SimplyRETS API uses the `Accept` header to allow clients to\ncontrol media types (content versions). We maintain backwards\ncompatibility with API clients by allowing them to specify a\ncontent version. We highly recommend setting and explicity media\ntype when your application reaches production. Both the structure\nand content of our API response bodies is subject to change so we\ncan add new features while respecting the stability of applications\nwhich have already been developed.\n\nTo always use the latest SimplyRETS content version, simply use\n`application/json` in your application `Accept` header.\n\nIf you want to pin your clients media type to a specific version,\nyou can use the vendor-specific SimplyRETS media type, e.g.\n`application/vnd.simplyrets-v0.1+json\"`\n\nTo view all valid content-types for making an `OPTIONS`, make a\nrequest to the SimplyRETS api root\n\n`curl -XOPTIONS -u simplyrets:simplyrets https://api.simplyrets.com/`\n\nThe default media types used in our API responses may change in the\nfuture. If you're building an application and care about the\nstability of the API, be sure to request a specific media type in the\nAccept header as shown in the examples below.\n\nThe wordpress plugin automatically sets the `Accept` header for the\ncompatible SimplyRETS media types.\n\n### Pagination\nThere a few pieces of useful information about each request stored\nin the HTTP Headers:\n\n- `X-Total-Count` shows you the total amount of listings that match\n your current query.\n- `Link` contains pre-built pagination links for accessing the next\n'page' of listings that match your query. Read more about that\n[here](https://simplyrets.com/blog/api-pagination.html).\n
|
5
|
+
|
6
|
+
OpenAPI spec version: 1.0.0
|
7
|
+
|
8
|
+
Generated by: https://github.com/swagger-api/swagger-codegen.git
|
9
|
+
|
10
|
+
|
11
|
+
=end
|
12
|
+
|
13
|
+
require 'date'
|
14
|
+
|
1
15
|
module SimplyRetsClient
|
2
|
-
#
|
3
|
-
class School
|
4
|
-
|
5
|
-
|
16
|
+
# RETS MLS School Data
|
17
|
+
class School
|
18
|
+
# Middle or junior school name
|
19
|
+
attr_accessor :middle_school
|
20
|
+
|
21
|
+
# High school name
|
22
|
+
attr_accessor :high_school
|
23
|
+
|
24
|
+
# Elementary school name.
|
25
|
+
attr_accessor :elementary_school
|
26
|
+
|
27
|
+
# School district name.
|
28
|
+
attr_accessor :district
|
29
|
+
|
30
|
+
# Attribute mapping from ruby-style variable name to JSON key.
|
6
31
|
def self.attribute_map
|
7
32
|
{
|
8
33
|
|
9
|
-
|
10
|
-
:'district' => :'district',
|
34
|
+
:'middle_school' => :'middleSchool',
|
11
35
|
|
12
|
-
|
13
|
-
:'elementary_school' => :'elementarySchool',
|
36
|
+
:'high_school' => :'highSchool',
|
14
37
|
|
15
|
-
|
16
|
-
:'middle_school' => :'middleSchool',
|
38
|
+
:'elementary_school' => :'elementarySchool',
|
17
39
|
|
18
|
-
|
19
|
-
:'high_school' => :'highSchool'
|
40
|
+
:'district' => :'district'
|
20
41
|
|
21
42
|
}
|
22
43
|
end
|
23
44
|
|
24
|
-
#
|
25
|
-
def self.
|
45
|
+
# Attribute type mapping.
|
46
|
+
def self.swagger_types
|
26
47
|
{
|
27
|
-
:'district' => :'String',
|
28
|
-
:'elementary_school' => :'String',
|
29
48
|
:'middle_school' => :'String',
|
30
|
-
:'high_school' => :'String'
|
49
|
+
:'high_school' => :'String',
|
50
|
+
:'elementary_school' => :'String',
|
51
|
+
:'district' => :'String'
|
31
52
|
|
32
53
|
}
|
33
54
|
end
|
34
55
|
|
35
56
|
def initialize(attributes = {})
|
36
|
-
return
|
57
|
+
return unless attributes.is_a?(Hash)
|
37
58
|
|
38
59
|
# convert string to symbol for hash key
|
39
60
|
attributes = attributes.inject({}){|memo,(k,v)| memo[k.to_sym] = v; memo}
|
40
61
|
|
41
62
|
|
42
|
-
if attributes[:'
|
43
|
-
self.
|
63
|
+
if attributes[:'middleSchool']
|
64
|
+
self.middle_school = attributes[:'middleSchool']
|
65
|
+
else
|
66
|
+
self.middle_school = "Middle School"
|
67
|
+
end
|
68
|
+
|
69
|
+
if attributes[:'highSchool']
|
70
|
+
self.high_school = attributes[:'highSchool']
|
71
|
+
else
|
72
|
+
self.high_school = "High School"
|
44
73
|
end
|
45
74
|
|
46
75
|
if attributes[:'elementarySchool']
|
47
76
|
self.elementary_school = attributes[:'elementarySchool']
|
77
|
+
else
|
78
|
+
self.elementary_school = "Elementary School"
|
48
79
|
end
|
49
80
|
|
50
|
-
if attributes[:'
|
51
|
-
self.
|
81
|
+
if attributes[:'district']
|
82
|
+
self.district = attributes[:'district']
|
83
|
+
else
|
84
|
+
self.district = "School District"
|
52
85
|
end
|
53
86
|
|
54
|
-
|
55
|
-
|
87
|
+
end
|
88
|
+
|
89
|
+
# Check equality by comparing each attribute.
|
90
|
+
def ==(o)
|
91
|
+
return true if self.equal?(o)
|
92
|
+
self.class == o.class &&
|
93
|
+
middle_school == o.middle_school &&
|
94
|
+
high_school == o.high_school &&
|
95
|
+
elementary_school == o.elementary_school &&
|
96
|
+
district == o.district
|
97
|
+
end
|
98
|
+
|
99
|
+
# @see the `==` method
|
100
|
+
def eql?(o)
|
101
|
+
self == o
|
102
|
+
end
|
103
|
+
|
104
|
+
# Calculate hash code according to all attributes.
|
105
|
+
def hash
|
106
|
+
[middle_school, high_school, elementary_school, district].hash
|
107
|
+
end
|
108
|
+
|
109
|
+
# build the object from hash
|
110
|
+
def build_from_hash(attributes)
|
111
|
+
return nil unless attributes.is_a?(Hash)
|
112
|
+
self.class.swagger_types.each_pair do |key, type|
|
113
|
+
if type =~ /^Array<(.*)>/i
|
114
|
+
if attributes[self.class.attribute_map[key]].is_a?(Array)
|
115
|
+
self.send("#{key}=", attributes[self.class.attribute_map[key]].map{ |v| _deserialize($1, v) } )
|
116
|
+
else
|
117
|
+
#TODO show warning in debug mode
|
118
|
+
end
|
119
|
+
elsif !attributes[self.class.attribute_map[key]].nil?
|
120
|
+
self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
|
121
|
+
else
|
122
|
+
# data not found in attributes(hash), not an issue as the data can be optional
|
123
|
+
end
|
56
124
|
end
|
57
125
|
|
126
|
+
self
|
127
|
+
end
|
128
|
+
|
129
|
+
def _deserialize(type, value)
|
130
|
+
case type.to_sym
|
131
|
+
when :DateTime
|
132
|
+
DateTime.parse(value)
|
133
|
+
when :Date
|
134
|
+
Date.parse(value)
|
135
|
+
when :String
|
136
|
+
value.to_s
|
137
|
+
when :Integer
|
138
|
+
value.to_i
|
139
|
+
when :Float
|
140
|
+
value.to_f
|
141
|
+
when :BOOLEAN
|
142
|
+
if value.to_s =~ /^(true|t|yes|y|1)$/i
|
143
|
+
true
|
144
|
+
else
|
145
|
+
false
|
146
|
+
end
|
147
|
+
when :Object
|
148
|
+
# generic object (usually a Hash), return directly
|
149
|
+
value
|
150
|
+
when /\AArray<(?<inner_type>.+)>\z/
|
151
|
+
inner_type = Regexp.last_match[:inner_type]
|
152
|
+
value.map { |v| _deserialize(inner_type, v) }
|
153
|
+
when /\AHash<(?<k_type>.+), (?<v_type>.+)>\z/
|
154
|
+
k_type = Regexp.last_match[:k_type]
|
155
|
+
v_type = Regexp.last_match[:v_type]
|
156
|
+
{}.tap do |hash|
|
157
|
+
value.each do |k, v|
|
158
|
+
hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
|
159
|
+
end
|
160
|
+
end
|
161
|
+
else # model
|
162
|
+
_model = SimplyRetsClient.const_get(type).new
|
163
|
+
_model.build_from_hash(value)
|
164
|
+
end
|
165
|
+
end
|
166
|
+
|
167
|
+
def to_s
|
168
|
+
to_hash.to_s
|
169
|
+
end
|
170
|
+
|
171
|
+
# to_body is an alias to to_body (backward compatibility))
|
172
|
+
def to_body
|
173
|
+
to_hash
|
174
|
+
end
|
175
|
+
|
176
|
+
# return the object in the form of hash
|
177
|
+
def to_hash
|
178
|
+
hash = {}
|
179
|
+
self.class.attribute_map.each_pair do |attr, param|
|
180
|
+
value = self.send(attr)
|
181
|
+
next if value.nil?
|
182
|
+
hash[param] = _to_hash(value)
|
183
|
+
end
|
184
|
+
hash
|
185
|
+
end
|
186
|
+
|
187
|
+
# Method to output non-array value in the form of hash
|
188
|
+
# For object, use to_hash. Otherwise, just return the value
|
189
|
+
def _to_hash(value)
|
190
|
+
if value.is_a?(Array)
|
191
|
+
value.compact.map{ |v| _to_hash(v) }
|
192
|
+
elsif value.is_a?(Hash)
|
193
|
+
{}.tap do |hash|
|
194
|
+
value.each { |k, v| hash[k] = _to_hash(v) }
|
195
|
+
end
|
196
|
+
elsif value.respond_to? :to_hash
|
197
|
+
value.to_hash
|
198
|
+
else
|
199
|
+
value
|
200
|
+
end
|
58
201
|
end
|
59
202
|
|
60
203
|
end
|