realogy 0.6.4 → 0.6.7

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: 8bd21ebae2bdd067d907b8be8b4205f91874e8074f83189bcb719d793e251672
4
- data.tar.gz: a9afc5328a86797ec677fd28aaaf1d1932bc29cf65a84e906b956c9d7ac76897
3
+ metadata.gz: af21ce6dbe48615c3a3ecc256c80e8a040d0b6509fdc519daea7f5427cc48cda
4
+ data.tar.gz: c8e39d729c23718404fc01cebe9a99f2d07fb14be2113512025e0881ce4ab25e
5
5
  SHA512:
6
- metadata.gz: fb23e4584877fb4a473f05ee86d68a7a325adde0a7941a43f643d18b94238522673188f0d2adb8f80b332b2eb02614d97503c0404d9239072ec4247eff9b90de
7
- data.tar.gz: 79329f73bdcc2f6467b46246e105bad993ee24bc335d3bd64e0fdd2001cc8cedb309a2949ef26be20ad7badd6b024ff1c22f5f25c8136ff09f7695ca1c39bc7b
6
+ metadata.gz: cc34e6fe481234ded70d4d5de236e2c4af525471895d64a66451ef817f4a299dae6efd918d750a0a511e9f4528122f50275070b2e985d57ea5cbedec3ac55bbc
7
+ data.tar.gz: f065a69112faaba033180837cc7b0086f5582dfa3afff86c287ce99d1fbb8797245867e7c9b44b598042ff4d88b873446e45eace0ed86a4381a85507a05e9bde
data/README.md CHANGED
@@ -219,26 +219,26 @@ When passing in `followNext: true`, the returned result will be an array of enti
219
219
  To retrieve all listings, `fromDate` and `brandCode` are mandatory parameters. A minimum call to retrieve all listing entities could look like this:
220
220
 
221
221
  ```ruby
222
- realogy.get_all_listings(brandCode: "COR", fromDate: 1.week.ago.to_query_string)
222
+ realogy.get_all_listings(brandCode: "COR", fromDate: 1.week.ago.json_string)
223
223
  ```
224
224
 
225
225
  These are additional filters that can be applied:
226
226
 
227
227
  ```ruby
228
- # fromDate and toDate must be converted to supported text format. This is done with to_query_string:
229
- realogy.get_all_listings(brandCode: "COR", fromDate: 1.week.ago.to_query_string, toDate: DateTime.now.to_query_string)
228
+ # fromDate and toDate must be converted to supported text format. This is done with json_string:
229
+ realogy.get_all_listings(brandCode: "COR", fromDate: 1.week.ago.json_string, toDate: DateTime.now.json_string)
230
230
 
231
231
  # Allowed type values: ForSale, ForRent, ForSaleCommercial, & ForLeaseCommercial
232
- realogy.get_all_listings(brandCode: "C21", fromDate: 1.week.ago.to_query_string, type: "ForSale")
232
+ realogy.get_all_listings(brandCode: "C21", fromDate: 1.week.ago.json_string, type: "ForSale")
233
233
 
234
234
  # Allowed status values: Active, Available, Pending, & Closed
235
- realogy.get_all_listings(brandCode: "CB", fromDate: 1.week.ago.to_query_string, status: "Active")
235
+ realogy.get_all_listings(brandCode: "CB", fromDate: 1.week.ago.json_string, status: "Active")
236
236
 
237
237
  # Limit results to a particular country
238
- realogy.get_all_listings(brandCode: "SIR", fromDate: 1.week.ago.to_query_string, countryCode: "IT")
238
+ realogy.get_all_listings(brandCode: "SIR", fromDate: 1.week.ago.json_string, countryCode: "IT")
239
239
 
240
240
  # Limit number of listings per result batch. Allowed span: 10–1000.
241
- realogy.get_all_listings(brandCode: "BHG", fromDate: 1.week.ago.to_query_string, limit: 10)
241
+ realogy.get_all_listings(brandCode: "BHG", fromDate: 1.week.ago.json_string, limit: 10)
242
242
 
243
243
  ```
244
244
 
@@ -1,11 +1,11 @@
1
1
  DateTime.class_eval do
2
- def to_query_string
2
+ def json_string
3
3
  self.to_json.split("\"").last
4
4
  end
5
5
  end
6
6
 
7
7
  ActiveSupport::TimeWithZone.class_eval do
8
- def to_query_string
8
+ def json_string
9
9
  self.to_datetime.to_json.split("\"").last
10
10
  end
11
11
  end
@@ -2,7 +2,7 @@ class Realogy::Entity < ApplicationRecord
2
2
  self.table_name = 'realogy_entities'
3
3
 
4
4
  validates :type, presence: true
5
- validates :entity_id, presence: true
5
+ validates :entity_id, presence: true, uniqueness: true
6
6
  validates :last_update_on, presence: true
7
7
 
8
8
  def needs_updating?
@@ -14,10 +14,14 @@ class Realogy::Entity < ApplicationRecord
14
14
  @object.last_update_on = hash["lastUpdateOn"].to_s.to_datetime
15
15
  @object.populate if @object.needs_updating?
16
16
  end
17
-
18
- def populate
17
+
18
+ def get_data
19
19
  call = ["get_", self.class.to_s.downcase.split("::").last, "_by_id"].join.to_sym
20
- result = Realogy::DataSync.client.__send__(call, self.entity_id)
20
+ Realogy::DataSync.client.__send__(call, self.entity_id)
21
+ end
22
+
23
+ def populate
24
+ result = get_data
21
25
  self.data = result unless result.blank?
22
26
  self.save if self.changed?
23
27
  end
@@ -95,7 +95,7 @@ namespace :realogy do
95
95
  def perform_delta_update_for klass, since
96
96
  return unless %w(agents companies listings offices teams).include?(plural = klass.to_s.tableize.split("/").last)
97
97
  call = "get_#{plural}_delta".to_sym
98
- Realogy::DataSync.client.send(call, {since: since.to_i.minutes.ago}).each do |hash|
98
+ Realogy::DataSync.client.send(call, {since: since.to_i.minutes.ago, followNext: true}).each do |hash|
99
99
  case hash["action"]
100
100
  when "Delete"
101
101
  klass.find_by(entity_id: hash["id"]).try(:destroy)
@@ -1,3 +1,3 @@
1
1
  module Realogy
2
- VERSION = "0.6.4"
2
+ VERSION = "0.6.7"
3
3
  end
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.4
4
+ version: 0.6.7
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-15 00:00:00.000000000 Z
11
+ date: 2022-03-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler