realogy 0.6.1 → 0.6.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 12d8e93945c23e56e01fbe630bec8fdbe5ce249bd3b005a86d4a6912d9784db4
4
- data.tar.gz: 4d10e4f50b4966dc5c9ba7f3b520db7d521f9406799822bd80cf9f422c4589a5
3
+ metadata.gz: f02721407645903a2d9ac60db41b1d8cbf634ca114dda8a59d30adc2f965de8c
4
+ data.tar.gz: 71e9bdeccb476d4410210361cc296a3185c683f63601da6d01f9560b1e9e8c3c
5
5
  SHA512:
6
- metadata.gz: bd20fd303e29928de9b4f087dca56ccaf4c42934bb17d1e71439bf343b02add61d9c449a0fa94b9bfe6fc959273006bb987cdcd7381dc7542134b844fef18a6b
7
- data.tar.gz: ba898e4b69cd3db029e63db391117a337f10d66a2770a7ba932eb85885f44d8708c6c5dc2474688fef4cfed5123f388fa676675ed6ad67098ed5d6020074b94f
6
+ metadata.gz: f761f642d02074648b93393a673e8174f1152b3f5b4227a073bcfbabbd9fef33edd806c65742becbd1f27a7dcd4a7a4e2e1847a2071afe51774b68a7b07de179
7
+ data.tar.gz: 5c0327820519b16c455ef8b6b4f7b8da293c4a4ac2b9558dbaca5f1feaf4217c9a60b104bca774d6434d45db67abdd47fceb8ef4372fc7cd25a165ce6ffac7ed
data/README.md CHANGED
@@ -128,9 +128,10 @@ config.active_job.queue_adapter = :delayed_job
128
128
  ```ruby
129
129
  realogy = Realogy::DataSync.client
130
130
  ```
131
- #### Retrieve array of objects
132
131
 
133
- The calls to retrieve entities are:
132
+ #### Get active objects
133
+
134
+ The calls to retrieve active entities are:
134
135
 
135
136
  ```ruby
136
137
  realogy.get_active_agents
@@ -140,20 +141,31 @@ realogy.get_active_offices
140
141
  realogy.get_active_teams
141
142
  ```
142
143
 
143
- When no argument is submitted, all entities are returned. Filters can be applied for `brandCode` or `countryCode` though, provided as keys in a hash. For example:
144
+ When no argument is submitted, all active entities are returned.
145
+
146
+ Filters can be applied for `brandCode` and `countryCode`. For example:
144
147
 
145
148
  ```ruby
146
149
  # Fetch all active agents, for all brands, in all countries:
147
- realogy.get_active_agents()
150
+ realogy.get_active_agents
148
151
 
149
152
  # Fetch all active agents, for all brands, in Sweden:
150
- realogy.get_active_agents({countryCode: "SE"})
153
+ realogy.get_active_companies(countryCode: "SE")
151
154
 
155
+ # Allowed brandCode values: C21, CB, ERA, SIR, BHG, CBC, ZIP, CLB, & COR
152
156
  # Fetch all active Sotheby's agents in all countries:
153
- realogy.get_active_agents({brandCode: "SIR"})
157
+ realogy.get_active_offices(brandCode: "SIR")
154
158
 
155
159
  # Fetch all active Sotheby's agents in Sweden:
156
- realogy.get_active_agents({brandCode: "SIR", countryCode: "SE"})
160
+ realogy.get_active_teams(brandCode: "SIR", countryCode: "SE")
161
+ ```
162
+
163
+ When fetching listings, the type of listing can also be specified:
164
+
165
+ ```ruby
166
+ # Allowed type values: ForSale, ForRent, ForSaleCommercial, & ForLeaseCommercial
167
+ # Fetch all active agents, for all brands, in all countries:
168
+ realogy.get_active_listings(type: "ForSale")
157
169
  ```
158
170
 
159
171
  #### Retrieve delta of objects
@@ -180,6 +192,35 @@ realogy.get_offices_delta({since: 5.minutes.ago})
180
192
  realogy.get_teams_delta({since: 1.day.ago})
181
193
  ```
182
194
 
195
+ #### Get all listings
196
+
197
+ To retrieve all listings, `fromDate` and `brandCode` are mandatory parameters. A minimum call to retrieve all listing entities could look like this:
198
+
199
+ ```ruby
200
+ realogy.get_all_listings(brandCode: "COR", fromDate: 1.week.ago.to_query_string)
201
+ ```
202
+
203
+ These are additional filters that can be applied:
204
+
205
+ ```ruby
206
+ # fromDate and toDate must be converted to supported text format. This is done with to_query_string:
207
+ realogy.get_all_listings(brandCode: "COR", fromDate: 1.week.ago.to_query_string, toDate: DateTime.now.to_query_string)
208
+
209
+ # Allowed type values: ForSale, ForRent, ForSaleCommercial, & ForLeaseCommercial
210
+ realogy.get_all_listings(brandCode: "C21", fromDate: 1.week.ago.to_query_string, type: "ForSale")
211
+
212
+ # Allowed status values: Active, Available, Pending, & Closed
213
+ realogy.get_all_listings(brandCode: "CB", fromDate: 1.week.ago.to_query_string, status: "Active")
214
+
215
+ # Limit results to a particular country
216
+ realogy.get_all_listings(brandCode: "SIR", fromDate: 1.week.ago.to_query_string, countryCode: "IT")
217
+
218
+ # Limit number of listings per result batch. Allowed span: 10–1000.
219
+ realogy.get_all_listings(brandCode: "BHG", fromDate: 1.week.ago.to_query_string, limit: 10)
220
+
221
+ ```
222
+
223
+
183
224
  #### Retrieve JSON object
184
225
 
185
226
  ```ruby
@@ -23,6 +23,10 @@ module Realogy
23
23
  get_active_teams: "teams/active"
24
24
  }
25
25
 
26
+ ALL_API_ENDPOINTS = {
27
+ get_all_listings: "listings/all"
28
+ }
29
+
26
30
  DELTA_API_ENDPOINTS = {
27
31
  get_agents_delta: "agents/delta",
28
32
  get_companies_delta: "companies/delta",
@@ -47,7 +51,26 @@ module Realogy
47
51
  endpoint = ACTIVE_API_ENDPOINTS[method_name]
48
52
  params = {
49
53
  'brandCode': hash[:brandCode],
50
- 'countryCode': hash[:countryCode]
54
+ 'countryCode': hash[:countryCode],
55
+ 'type': hash[:type]
56
+ }.compact
57
+ return perform_api_call(endpoint, params)
58
+ end
59
+ end
60
+
61
+ ALL_API_ENDPOINTS.keys.each do |method_name|
62
+ define_method method_name do |*args|
63
+ hash = args.first.is_a?(::Hash) ? args.first : {}
64
+ endpoint = ALL_API_ENDPOINTS[method_name]
65
+ params = {
66
+ 'brandCode': hash[:brandCode],
67
+ 'countryCode': hash[:countryCode],
68
+ 'cursor': hash[:cursor],
69
+ 'fromDate': hash[:fromDate],
70
+ 'limit': hash[:limit],
71
+ 'status': hash[:status],
72
+ 'toDate': hash[:toDate],
73
+ 'type': hash[:type]
51
74
  }.compact
52
75
  return perform_api_call(endpoint, params)
53
76
  end
@@ -0,0 +1,11 @@
1
+ DateTime.class_eval do
2
+ def to_query_string
3
+ self.to_json.split("\"").last
4
+ end
5
+ end
6
+
7
+ ActiveSupport::TimeWithZone.class_eval do
8
+ def to_query_string
9
+ self.to_datetime.to_json.split("\"").last
10
+ end
11
+ end
@@ -1,3 +1,3 @@
1
1
  module Realogy
2
- VERSION = "0.6.1"
2
+ VERSION = "0.6.2"
3
3
  end
data/lib/realogy.rb CHANGED
@@ -2,6 +2,7 @@ require "realogy/version"
2
2
  require "realogy/railtie" if defined?(Rails)
3
3
  require "realogy/app/models/application_record.rb"
4
4
  require "realogy/app/models/data_sync.rb"
5
+ require "realogy/app/models/date_time.rb"
5
6
  require "realogy/app/models/hash.rb"
6
7
  require "realogy/app/models/realogy/entity.rb"
7
8
  require "realogy/app/models/realogy/agent.rb"
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: realogy
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.1
4
+ version: 0.6.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Michael Edlund
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2022-03-14 00:00:00.000000000 Z
11
+ date: 2022-03-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -120,6 +120,7 @@ files:
120
120
  - lib/realogy/app/jobs/populate_realogy_entity_job.rb
121
121
  - lib/realogy/app/models/application_record.rb
122
122
  - lib/realogy/app/models/data_sync.rb
123
+ - lib/realogy/app/models/date_time.rb
123
124
  - lib/realogy/app/models/hash.rb
124
125
  - lib/realogy/app/models/realogy/agent.rb
125
126
  - lib/realogy/app/models/realogy/company.rb