simplyrets 1.0.7 → 2.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (54) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile.lock +23 -21
  3. data/Makefile +48 -0
  4. data/README.org +5 -58
  5. data/example.rb +14 -4
  6. data/lib/simplyrets.rb +42 -21
  7. data/lib/simplyrets/api/default_api.rb +292 -59
  8. data/lib/simplyrets/api_client.rb +370 -0
  9. data/lib/simplyrets/api_error.rb +36 -0
  10. data/lib/simplyrets/configuration.rb +170 -0
  11. data/lib/simplyrets/models/agent.rb +146 -11
  12. data/lib/simplyrets/models/broker.rb +133 -7
  13. data/lib/simplyrets/models/contact_information.rb +149 -17
  14. data/lib/simplyrets/models/error.rb +138 -9
  15. data/lib/simplyrets/models/geographic_data.rb +150 -12
  16. data/lib/simplyrets/models/listing.rb +248 -49
  17. data/lib/simplyrets/models/mls_information.rb +148 -12
  18. data/lib/simplyrets/models/office.rb +146 -11
  19. data/lib/simplyrets/models/open_house.rb +215 -12
  20. data/lib/simplyrets/models/parking.rb +148 -17
  21. data/lib/simplyrets/models/property.rb +353 -129
  22. data/lib/simplyrets/models/sales.rb +163 -25
  23. data/lib/simplyrets/models/school.rb +167 -24
  24. data/lib/simplyrets/models/street_address.rb +204 -26
  25. data/lib/simplyrets/models/tax.rb +150 -18
  26. data/lib/simplyrets/version.rb +15 -0
  27. data/multi-query-param.patch +44 -0
  28. data/simplyrets.gemspec +4 -4
  29. data/spec/api/default_api_spec.rb +172 -0
  30. data/spec/models/agent_spec.rb +75 -0
  31. data/spec/models/broker_spec.rb +45 -0
  32. data/spec/models/contact_information_spec.rb +65 -0
  33. data/spec/models/error_spec.rb +55 -0
  34. data/spec/models/geographic_data_spec.rb +85 -0
  35. data/spec/models/listing_spec.rb +245 -0
  36. data/spec/models/mls_information_spec.rb +75 -0
  37. data/spec/models/office_spec.rb +75 -0
  38. data/spec/models/open_house_spec.rb +115 -0
  39. data/spec/models/parking_spec.rb +65 -0
  40. data/spec/models/property_spec.rb +365 -0
  41. data/spec/models/sales_spec.rb +85 -0
  42. data/spec/models/school_spec.rb +75 -0
  43. data/spec/models/street_address_spec.rb +105 -0
  44. data/spec/models/tax_spec.rb +65 -0
  45. data/spec/spec_helper.rb +78 -0
  46. metadata +33 -18
  47. data/lib/simplyrets.rb~ +0 -34
  48. data/lib/simplyrets/api/#default_api.rb# +0 -146
  49. data/lib/simplyrets/simplyrets/api_error.rb +0 -26
  50. data/lib/simplyrets/simplyrets/configuration.rb +0 -101
  51. data/lib/simplyrets/simplyrets/request.rb +0 -248
  52. data/lib/simplyrets/simplyrets/response.rb +0 -156
  53. data/lib/simplyrets/simplyrets/version.rb +0 -5
  54. data/simplyrets-1.0.6.gem +0 -0
@@ -1,28 +1,49 @@
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 Agent < BaseObject
4
- attr_accessor :last_name, :contact, :first_name, :id
5
- # attribute mapping from ruby-style variable name to JSON key
16
+ # SimplyRETS Agent Api
17
+ class Agent
18
+ # Agent last name
19
+ attr_accessor :last_name
20
+
21
+ # Agent contact info. This information is only present when\nyour RETS feed specifies the agent wishes to show their\ncontact information publicly.\n
22
+ attr_accessor :contact
23
+
24
+ # Agent first name
25
+ attr_accessor :first_name
26
+
27
+ # Well known Agent MLS number or id.
28
+ attr_accessor :id
29
+
30
+ # Attribute mapping from ruby-style variable name to JSON key.
6
31
  def self.attribute_map
7
32
  {
8
33
 
9
- # Agent last name
10
34
  :'last_name' => :'lastName',
11
35
 
12
- # Agent contact info. This information is only present when\nyour RETS feed specifies the agent wishes to show their\ncontact information publicly.\n
13
36
  :'contact' => :'contact',
14
37
 
15
- # Agent first name
16
38
  :'first_name' => :'firstName',
17
39
 
18
- # Well known Agent MLS number or id.
19
40
  :'id' => :'id'
20
41
 
21
42
  }
22
43
  end
23
44
 
24
- # attribute type
25
- def self.simplyrets_types
45
+ # Attribute type mapping.
46
+ def self.swagger_types
26
47
  {
27
48
  :'last_name' => :'String',
28
49
  :'contact' => :'ContactInformation',
@@ -33,7 +54,7 @@ module SimplyRetsClient
33
54
  end
34
55
 
35
56
  def initialize(attributes = {})
36
- return if !attributes.is_a?(Hash) || attributes.empty?
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}
@@ -57,5 +78,119 @@ module SimplyRetsClient
57
78
 
58
79
  end
59
80
 
81
+ # Check equality by comparing each attribute.
82
+ def ==(o)
83
+ return true if self.equal?(o)
84
+ self.class == o.class &&
85
+ last_name == o.last_name &&
86
+ contact == o.contact &&
87
+ first_name == o.first_name &&
88
+ id == o.id
89
+ end
90
+
91
+ # @see the `==` method
92
+ def eql?(o)
93
+ self == o
94
+ end
95
+
96
+ # Calculate hash code according to all attributes.
97
+ def hash
98
+ [last_name, contact, first_name, id].hash
99
+ end
100
+
101
+ # build the object from hash
102
+ def build_from_hash(attributes)
103
+ return nil unless attributes.is_a?(Hash)
104
+ self.class.swagger_types.each_pair do |key, type|
105
+ if type =~ /^Array<(.*)>/i
106
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
107
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map{ |v| _deserialize($1, v) } )
108
+ else
109
+ #TODO show warning in debug mode
110
+ end
111
+ elsif !attributes[self.class.attribute_map[key]].nil?
112
+ self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
113
+ else
114
+ # data not found in attributes(hash), not an issue as the data can be optional
115
+ end
116
+ end
117
+
118
+ self
119
+ end
120
+
121
+ def _deserialize(type, value)
122
+ case type.to_sym
123
+ when :DateTime
124
+ DateTime.parse(value)
125
+ when :Date
126
+ Date.parse(value)
127
+ when :String
128
+ value.to_s
129
+ when :Integer
130
+ value.to_i
131
+ when :Float
132
+ value.to_f
133
+ when :BOOLEAN
134
+ if value.to_s =~ /^(true|t|yes|y|1)$/i
135
+ true
136
+ else
137
+ false
138
+ end
139
+ when :Object
140
+ # generic object (usually a Hash), return directly
141
+ value
142
+ when /\AArray<(?<inner_type>.+)>\z/
143
+ inner_type = Regexp.last_match[:inner_type]
144
+ value.map { |v| _deserialize(inner_type, v) }
145
+ when /\AHash<(?<k_type>.+), (?<v_type>.+)>\z/
146
+ k_type = Regexp.last_match[:k_type]
147
+ v_type = Regexp.last_match[:v_type]
148
+ {}.tap do |hash|
149
+ value.each do |k, v|
150
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
151
+ end
152
+ end
153
+ else # model
154
+ _model = SimplyRetsClient.const_get(type).new
155
+ _model.build_from_hash(value)
156
+ end
157
+ end
158
+
159
+ def to_s
160
+ to_hash.to_s
161
+ end
162
+
163
+ # to_body is an alias to to_body (backward compatibility))
164
+ def to_body
165
+ to_hash
166
+ end
167
+
168
+ # return the object in the form of hash
169
+ def to_hash
170
+ hash = {}
171
+ self.class.attribute_map.each_pair do |attr, param|
172
+ value = self.send(attr)
173
+ next if value.nil?
174
+ hash[param] = _to_hash(value)
175
+ end
176
+ hash
177
+ end
178
+
179
+ # Method to output non-array value in the form of hash
180
+ # For object, use to_hash. Otherwise, just return the value
181
+ def _to_hash(value)
182
+ if value.is_a?(Array)
183
+ value.compact.map{ |v| _to_hash(v) }
184
+ elsif value.is_a?(Hash)
185
+ {}.tap do |hash|
186
+ value.each { |k, v| hash[k] = _to_hash(v) }
187
+ end
188
+ elsif value.respond_to? :to_hash
189
+ value.to_hash
190
+ else
191
+ value
192
+ end
193
+ end
194
+
60
195
  end
61
196
  end
@@ -1,19 +1,34 @@
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 Broker < BaseObject
16
+ # SimplyRETS Broker Api
17
+ class Broker
18
+ # Start Date
4
19
  attr_accessor :startdate
5
- # attribute mapping from ruby-style variable name to JSON key
20
+
21
+ # Attribute mapping from ruby-style variable name to JSON key.
6
22
  def self.attribute_map
7
23
  {
8
24
 
9
- # Start Date
10
25
  :'startdate' => :'startdate'
11
26
 
12
27
  }
13
28
  end
14
29
 
15
- # attribute type
16
- def self.simplyrets_types
30
+ # Attribute type mapping.
31
+ def self.swagger_types
17
32
  {
18
33
  :'startdate' => :'DateTime'
19
34
 
@@ -21,7 +36,7 @@ module SimplyRetsClient
21
36
  end
22
37
 
23
38
  def initialize(attributes = {})
24
- return if !attributes.is_a?(Hash) || attributes.empty?
39
+ return unless attributes.is_a?(Hash)
25
40
 
26
41
  # convert string to symbol for hash key
27
42
  attributes = attributes.inject({}){|memo,(k,v)| memo[k.to_sym] = v; memo}
@@ -33,5 +48,116 @@ module SimplyRetsClient
33
48
 
34
49
  end
35
50
 
51
+ # Check equality by comparing each attribute.
52
+ def ==(o)
53
+ return true if self.equal?(o)
54
+ self.class == o.class &&
55
+ startdate == o.startdate
56
+ end
57
+
58
+ # @see the `==` method
59
+ def eql?(o)
60
+ self == o
61
+ end
62
+
63
+ # Calculate hash code according to all attributes.
64
+ def hash
65
+ [startdate].hash
66
+ end
67
+
68
+ # build the object from hash
69
+ def build_from_hash(attributes)
70
+ return nil unless attributes.is_a?(Hash)
71
+ self.class.swagger_types.each_pair do |key, type|
72
+ if type =~ /^Array<(.*)>/i
73
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
74
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map{ |v| _deserialize($1, v) } )
75
+ else
76
+ #TODO show warning in debug mode
77
+ end
78
+ elsif !attributes[self.class.attribute_map[key]].nil?
79
+ self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
80
+ else
81
+ # data not found in attributes(hash), not an issue as the data can be optional
82
+ end
83
+ end
84
+
85
+ self
86
+ end
87
+
88
+ def _deserialize(type, value)
89
+ case type.to_sym
90
+ when :DateTime
91
+ DateTime.parse(value)
92
+ when :Date
93
+ Date.parse(value)
94
+ when :String
95
+ value.to_s
96
+ when :Integer
97
+ value.to_i
98
+ when :Float
99
+ value.to_f
100
+ when :BOOLEAN
101
+ if value.to_s =~ /^(true|t|yes|y|1)$/i
102
+ true
103
+ else
104
+ false
105
+ end
106
+ when :Object
107
+ # generic object (usually a Hash), return directly
108
+ value
109
+ when /\AArray<(?<inner_type>.+)>\z/
110
+ inner_type = Regexp.last_match[:inner_type]
111
+ value.map { |v| _deserialize(inner_type, v) }
112
+ when /\AHash<(?<k_type>.+), (?<v_type>.+)>\z/
113
+ k_type = Regexp.last_match[:k_type]
114
+ v_type = Regexp.last_match[:v_type]
115
+ {}.tap do |hash|
116
+ value.each do |k, v|
117
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
118
+ end
119
+ end
120
+ else # model
121
+ _model = SimplyRetsClient.const_get(type).new
122
+ _model.build_from_hash(value)
123
+ end
124
+ end
125
+
126
+ def to_s
127
+ to_hash.to_s
128
+ end
129
+
130
+ # to_body is an alias to to_body (backward compatibility))
131
+ def to_body
132
+ to_hash
133
+ end
134
+
135
+ # return the object in the form of hash
136
+ def to_hash
137
+ hash = {}
138
+ self.class.attribute_map.each_pair do |attr, param|
139
+ value = self.send(attr)
140
+ next if value.nil?
141
+ hash[param] = _to_hash(value)
142
+ end
143
+ hash
144
+ end
145
+
146
+ # Method to output non-array value in the form of hash
147
+ # For object, use to_hash. Otherwise, just return the value
148
+ def _to_hash(value)
149
+ if value.is_a?(Array)
150
+ value.compact.map{ |v| _to_hash(v) }
151
+ elsif value.is_a?(Hash)
152
+ {}.tap do |hash|
153
+ value.each { |k, v| hash[k] = _to_hash(v) }
154
+ end
155
+ elsif value.respond_to? :to_hash
156
+ value.to_hash
157
+ else
158
+ value
159
+ end
160
+ end
161
+
36
162
  end
37
163
  end
@@ -1,40 +1,63 @@
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 ContactInformation < BaseObject
4
- attr_accessor :office, :cell, :full
5
- # attribute mapping from ruby-style variable name to JSON key
16
+ # RETS MLS Contact Information
17
+ class ContactInformation
18
+ # The email address of the `ContactInformation`\n\n**Not available for all RETS vendors**\n
19
+ attr_accessor :email
20
+
21
+ # Contact Information Office Phone Number\n\n**Not available for all RETS vendors**\n
22
+ attr_accessor :office
23
+
24
+ # Contact Information Cell Phone\n\n**Not available for all RETS vendors**\n
25
+ attr_accessor :cell
26
+
27
+ # Attribute mapping from ruby-style variable name to JSON key.
6
28
  def self.attribute_map
7
29
  {
8
30
 
9
- # Contact Information Office Phone Number
10
- :'office' => :'office',
31
+ :'email' => :'email',
11
32
 
12
- # Contact Information Cell Phone
13
- :'cell' => :'cell',
33
+ :'office' => :'office',
14
34
 
15
- # Full pretty-printed address with suffix (if available)
16
- :'full' => :'full'
35
+ :'cell' => :'cell'
17
36
 
18
37
  }
19
38
  end
20
39
 
21
- # attribute type
22
- def self.simplyrets_types
40
+ # Attribute type mapping.
41
+ def self.swagger_types
23
42
  {
43
+ :'email' => :'String',
24
44
  :'office' => :'String',
25
- :'cell' => :'String',
26
- :'full' => :'String'
45
+ :'cell' => :'String'
27
46
 
28
47
  }
29
48
  end
30
49
 
31
50
  def initialize(attributes = {})
32
- return if !attributes.is_a?(Hash) || attributes.empty?
51
+ return unless attributes.is_a?(Hash)
33
52
 
34
53
  # convert string to symbol for hash key
35
54
  attributes = attributes.inject({}){|memo,(k,v)| memo[k.to_sym] = v; memo}
36
55
 
37
56
 
57
+ if attributes[:'email']
58
+ self.email = attributes[:'email']
59
+ end
60
+
38
61
  if attributes[:'office']
39
62
  self.office = attributes[:'office']
40
63
  end
@@ -43,10 +66,119 @@ module SimplyRetsClient
43
66
  self.cell = attributes[:'cell']
44
67
  end
45
68
 
46
- if attributes[:'full']
47
- self.full = attributes[:'full']
69
+ end
70
+
71
+ # Check equality by comparing each attribute.
72
+ def ==(o)
73
+ return true if self.equal?(o)
74
+ self.class == o.class &&
75
+ email == o.email &&
76
+ office == o.office &&
77
+ cell == o.cell
78
+ end
79
+
80
+ # @see the `==` method
81
+ def eql?(o)
82
+ self == o
83
+ end
84
+
85
+ # Calculate hash code according to all attributes.
86
+ def hash
87
+ [email, office, cell].hash
88
+ end
89
+
90
+ # build the object from hash
91
+ def build_from_hash(attributes)
92
+ return nil unless attributes.is_a?(Hash)
93
+ self.class.swagger_types.each_pair do |key, type|
94
+ if type =~ /^Array<(.*)>/i
95
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
96
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map{ |v| _deserialize($1, v) } )
97
+ else
98
+ #TODO show warning in debug mode
99
+ end
100
+ elsif !attributes[self.class.attribute_map[key]].nil?
101
+ self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
102
+ else
103
+ # data not found in attributes(hash), not an issue as the data can be optional
104
+ end
48
105
  end
49
106
 
107
+ self
108
+ end
109
+
110
+ def _deserialize(type, value)
111
+ case type.to_sym
112
+ when :DateTime
113
+ DateTime.parse(value)
114
+ when :Date
115
+ Date.parse(value)
116
+ when :String
117
+ value.to_s
118
+ when :Integer
119
+ value.to_i
120
+ when :Float
121
+ value.to_f
122
+ when :BOOLEAN
123
+ if value.to_s =~ /^(true|t|yes|y|1)$/i
124
+ true
125
+ else
126
+ false
127
+ end
128
+ when :Object
129
+ # generic object (usually a Hash), return directly
130
+ value
131
+ when /\AArray<(?<inner_type>.+)>\z/
132
+ inner_type = Regexp.last_match[:inner_type]
133
+ value.map { |v| _deserialize(inner_type, v) }
134
+ when /\AHash<(?<k_type>.+), (?<v_type>.+)>\z/
135
+ k_type = Regexp.last_match[:k_type]
136
+ v_type = Regexp.last_match[:v_type]
137
+ {}.tap do |hash|
138
+ value.each do |k, v|
139
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
140
+ end
141
+ end
142
+ else # model
143
+ _model = SimplyRetsClient.const_get(type).new
144
+ _model.build_from_hash(value)
145
+ end
146
+ end
147
+
148
+ def to_s
149
+ to_hash.to_s
150
+ end
151
+
152
+ # to_body is an alias to to_body (backward compatibility))
153
+ def to_body
154
+ to_hash
155
+ end
156
+
157
+ # return the object in the form of hash
158
+ def to_hash
159
+ hash = {}
160
+ self.class.attribute_map.each_pair do |attr, param|
161
+ value = self.send(attr)
162
+ next if value.nil?
163
+ hash[param] = _to_hash(value)
164
+ end
165
+ hash
166
+ end
167
+
168
+ # Method to output non-array value in the form of hash
169
+ # For object, use to_hash. Otherwise, just return the value
170
+ def _to_hash(value)
171
+ if value.is_a?(Array)
172
+ value.compact.map{ |v| _to_hash(v) }
173
+ elsif value.is_a?(Hash)
174
+ {}.tap do |hash|
175
+ value.each { |k, v| hash[k] = _to_hash(v) }
176
+ end
177
+ elsif value.respond_to? :to_hash
178
+ value.to_hash
179
+ else
180
+ value
181
+ end
50
182
  end
51
183
 
52
184
  end