reso_api 0.3.1 → 0.4.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +18 -1
- data/lib/reso_api/app/models/reso/api/client.rb +12 -3
- data/lib/reso_api/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 875af398db2f60126a49b410bedfa34d8c0b5427f614b8758176a6f40f8c184a
|
4
|
+
data.tar.gz: c6795fa6d9b96ad8e108fe05559dff495548aa2eed09d2c9454991215146d8a8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: dc5e5b6c38cf16ac70c05ec7f83eeebfed006ebf54f0f1fadc7b3ab7475aeaa1b04b3ca54125842183e2f5ae8246d3c8772046d4319a2e4a23b47915f32078c2
|
7
|
+
data.tar.gz: c6ccdd77da2494aa8eb37b6b77b30e7b613a0aa626d10c979448b538dc6c4c690d6af2060a5f3a2921422bd198d40ff02e34ac1e5feca5932db4e31948bd2aaa
|
data/README.md
CHANGED
@@ -143,7 +143,24 @@ $expand in oData is meant to join two resources together. For the Syndication AP
|
|
143
143
|
client.properties(expand: "Media")
|
144
144
|
```
|
145
145
|
|
146
|
-
####
|
146
|
+
#### Automatically iterate over all results
|
147
|
+
|
148
|
+
By passing a block to Media, Member, Office, and Property resource calls, subsequent paginated calls will automatically be made until the whole result set has been traversed. The block provided is executed for each returned object hash.
|
149
|
+
|
150
|
+
Here are a couple of examples of how that can be used:
|
151
|
+
|
152
|
+
```ruby
|
153
|
+
client.properties(filter: "StandardStatus eq 'Active'") do |hash|
|
154
|
+
puts "#{hash['ListingKey']} – #{hash['UnparsedAddress']}"
|
155
|
+
end
|
156
|
+
|
157
|
+
client.properties(filter: "StandardStatus eq 'Active'") do |hash|
|
158
|
+
Listing.create(listing_key: hash['ListingKey'], data: hash)
|
159
|
+
end
|
160
|
+
```
|
161
|
+
|
162
|
+
|
163
|
+
#### Manually iterate over all results
|
147
164
|
|
148
165
|
The default number of results returned is 100. You can override the default limit using the `$top` parameter. The higher the number specific for `$top`, the longer the API response will take, and pay attention to that different services does enforce a cap for number of records returned.
|
149
166
|
|
@@ -47,7 +47,7 @@ module RESO
|
|
47
47
|
}
|
48
48
|
|
49
49
|
FILTERABLE_ENDPOINTS.keys.each do |method_name|
|
50
|
-
define_method method_name do |*args|
|
50
|
+
define_method method_name do |*args, &block|
|
51
51
|
hash = args.first.is_a?(Hash) ? args.first : {}
|
52
52
|
endpoint = FILTERABLE_ENDPOINTS[method_name]
|
53
53
|
params = {
|
@@ -61,7 +61,16 @@ module RESO
|
|
61
61
|
"$count": hash[:count].to_s.presence,
|
62
62
|
"$debug": hash[:debug]
|
63
63
|
}.compact
|
64
|
-
|
64
|
+
if !block.nil?
|
65
|
+
response = perform_call(endpoint, params)
|
66
|
+
response["value"].each{|hash| block.call(hash)} if response["value"].class.eql?(Array)
|
67
|
+
while (next_link = response["@odata.nextLink"]).present?
|
68
|
+
response = perform_call(next_link, nil)
|
69
|
+
response["value"].each{|hash| block.call(hash)} if response["value"].class.eql?(Array)
|
70
|
+
end
|
71
|
+
else
|
72
|
+
return perform_call(endpoint, params)
|
73
|
+
end
|
65
74
|
end
|
66
75
|
end
|
67
76
|
|
@@ -123,7 +132,7 @@ module RESO
|
|
123
132
|
end
|
124
133
|
|
125
134
|
def uri_for_endpoint endpoint
|
126
|
-
return URI([base_url, endpoint].join)
|
135
|
+
return URI(endpoint).host? ? endpoint : URI([base_url, endpoint].join)
|
127
136
|
end
|
128
137
|
|
129
138
|
def perform_call(endpoint, params)
|
data/lib/reso_api/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: reso_api
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.4.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-
|
11
|
+
date: 2022-04-23 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|