reso_api 0.4.8 → 0.5.1

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: d52973c086bdbeff331fc267832e7ece9c7002d5f10e9273c619e9ff985a2ffa
4
- data.tar.gz: ac5cfd9c1416bb0a43d38d514ca7b3213f133749630869bc55fb2855c797e99c
3
+ metadata.gz: 4bfeffc2a9629c46003d493b06585b6be940ce6ff282991bc86d89e9858e8da8
4
+ data.tar.gz: 430c407fcbf090aa10ebf96c98b0742a01e20be21672cd77de49131b7ab7d016
5
5
  SHA512:
6
- metadata.gz: 13689a885600bd73802304c034c9b48bfa1f635fc2016e2be3780575a6a142f6e80809e6af010d65dd4d63be1567c5bf08f33cd89925343932d4dcb1ab3bc455
7
- data.tar.gz: c770fb9aba3551dd8ee037a37a8ddb6853af78d6530b78856ad45a5d045caeeba0c32ca70f75889a8182a95f8283ac93e273945894284924210365c32b3d7bb5
6
+ metadata.gz: e4a5fa56805f806d78434f978c31603e4b2150d2c573e2d8b637f9170e8f87506b71670581df16c24f615d0a10404197f8b0477721173f025b17f107769de543
7
+ data.tar.gz: 4b9117e4a8c9d7ff0848160afe64d412a5d84849e7f600c2b28e0053c184ba48832624efe64c687a292704bcfa2796396361da359c2486aad8f4d105c088bae5
data/Gemfile.lock CHANGED
@@ -1,74 +1,57 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- reso_api (0.2.1)
4
+ reso_api (0.5.0)
5
5
  activesupport
6
6
  oauth2
7
7
 
8
8
  GEM
9
9
  remote: https://rubygems.org/
10
10
  specs:
11
- activesupport (6.1.4.1)
11
+ activesupport (7.0.3)
12
12
  concurrent-ruby (~> 1.0, >= 1.0.2)
13
13
  i18n (>= 1.6, < 2)
14
14
  minitest (>= 5.1)
15
15
  tzinfo (~> 2.0)
16
- zeitwerk (~> 2.3)
17
- concurrent-ruby (1.1.9)
18
- diff-lcs (1.4.4)
19
- faraday (1.8.0)
20
- faraday-em_http (~> 1.0)
21
- faraday-em_synchrony (~> 1.0)
22
- faraday-excon (~> 1.1)
23
- faraday-httpclient (~> 1.0.1)
24
- faraday-net_http (~> 1.0)
25
- faraday-net_http_persistent (~> 1.1)
26
- faraday-patron (~> 1.0)
27
- faraday-rack (~> 1.0)
28
- multipart-post (>= 1.2, < 3)
16
+ concurrent-ruby (1.1.10)
17
+ diff-lcs (1.5.0)
18
+ faraday (2.3.0)
19
+ faraday-net_http (~> 2.0)
29
20
  ruby2_keywords (>= 0.0.4)
30
- faraday-em_http (1.0.0)
31
- faraday-em_synchrony (1.0.0)
32
- faraday-excon (1.1.0)
33
- faraday-httpclient (1.0.1)
34
- faraday-net_http (1.0.1)
35
- faraday-net_http_persistent (1.2.0)
36
- faraday-patron (1.0.0)
37
- faraday-rack (1.0.0)
38
- i18n (1.8.10)
21
+ faraday-net_http (2.0.3)
22
+ i18n (1.10.0)
39
23
  concurrent-ruby (~> 1.0)
40
- jwt (2.2.3)
41
- minitest (5.14.4)
24
+ jwt (2.3.0)
25
+ minitest (5.15.0)
42
26
  multi_json (1.15.0)
43
27
  multi_xml (0.6.0)
44
- multipart-post (2.1.1)
45
- oauth2 (1.4.7)
46
- faraday (>= 0.8, < 2.0)
28
+ oauth2 (1.4.9)
29
+ faraday (>= 0.17.3, < 3.0)
47
30
  jwt (>= 1.0, < 3.0)
48
31
  multi_json (~> 1.3)
49
32
  multi_xml (~> 0.5)
50
33
  rack (>= 1.2, < 3)
51
- rack (2.2.3)
34
+ rack (2.2.3.1)
52
35
  rake (13.0.6)
53
- rspec (3.10.0)
54
- rspec-core (~> 3.10.0)
55
- rspec-expectations (~> 3.10.0)
56
- rspec-mocks (~> 3.10.0)
57
- rspec-core (3.10.1)
58
- rspec-support (~> 3.10.0)
59
- rspec-expectations (3.10.1)
36
+ rspec (3.11.0)
37
+ rspec-core (~> 3.11.0)
38
+ rspec-expectations (~> 3.11.0)
39
+ rspec-mocks (~> 3.11.0)
40
+ rspec-core (3.11.0)
41
+ rspec-support (~> 3.11.0)
42
+ rspec-expectations (3.11.0)
60
43
  diff-lcs (>= 1.2.0, < 2.0)
61
- rspec-support (~> 3.10.0)
62
- rspec-mocks (3.10.2)
44
+ rspec-support (~> 3.11.0)
45
+ rspec-mocks (3.11.1)
63
46
  diff-lcs (>= 1.2.0, < 2.0)
64
- rspec-support (~> 3.10.0)
65
- rspec-support (3.10.2)
47
+ rspec-support (~> 3.11.0)
48
+ rspec-support (3.11.0)
66
49
  ruby2_keywords (0.0.5)
67
50
  tzinfo (2.0.4)
68
51
  concurrent-ruby (~> 1.0)
69
- zeitwerk (2.4.2)
70
52
 
71
53
  PLATFORMS
54
+ arm64-darwin-21
72
55
  x86_64-linux
73
56
 
74
57
  DEPENDENCIES
@@ -78,4 +61,4 @@ DEPENDENCIES
78
61
  rspec (~> 3.0)
79
62
 
80
63
  BUNDLED WITH
81
- 2.2.27
64
+ 2.3.7
data/README.md CHANGED
@@ -145,7 +145,7 @@ client.properties(expand: "Media")
145
145
 
146
146
  #### Automatically iterate over all results
147
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.
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. The `batch` option can be used to return the full array of results.
149
149
 
150
150
  Here are a couple of examples of how that can be used:
151
151
 
@@ -157,6 +157,10 @@ end
157
157
  client.properties(filter: "StandardStatus eq 'Active'") do |hash|
158
158
  Listing.create(listing_key: hash['ListingKey'], data: hash)
159
159
  end
160
+
161
+ client.properties(filter: "StandardStatus eq 'Active'", batch: true) do |results|
162
+ Listing.insert_all(results) # Perform some batch operation
163
+ end
160
164
  ```
161
165
 
162
166
 
@@ -51,6 +51,7 @@ module RESO
51
51
  hash = args.first.is_a?(Hash) ? args.first : {}
52
52
  endpoint = FILTERABLE_ENDPOINTS[method_name]
53
53
  response = {}
54
+ threads = []
54
55
  params = {
55
56
  "$select": hash[:select],
56
57
  "$filter": hash[:filter],
@@ -64,11 +65,27 @@ module RESO
64
65
  }.compact
65
66
  if !block.nil?
66
67
  response = perform_call(endpoint, params)
67
- response["value"].each{|hash| block.call(hash)} if response["value"].class.eql?(Array)
68
+
69
+ if response["value"].class.eql?(Array)
70
+ threads << Thread.new do
71
+ hash[:batch] ? block.call(response["value"]) : response["value"].each{|hash| block.call(hash)}
72
+ end
73
+ end
74
+
68
75
  while (next_link = response["@odata.nextLink"]).present?
69
- response = perform_call(next_link, nil)
70
- response["value"].each{|hash| block.call(hash)} if response["value"].class.eql?(Array)
76
+ threads << Thread.new do
77
+ response = perform_call(next_link, nil)
78
+ end
79
+
80
+ threads.each(&:join)
81
+
82
+ if response["value"].class.eql?(Array)
83
+ threads << Thread.new do
84
+ hash[:batch] ? block.call(response["value"]) : response["value"].each{|hash| block.call(hash)}
85
+ end
86
+ end
71
87
  end
88
+ threads.each(&:join)
72
89
  else
73
90
  return perform_call(endpoint, params)
74
91
  end
@@ -1,3 +1,3 @@
1
1
  module ResoApi
2
- VERSION = "0.4.8"
2
+ VERSION = "0.5.1"
3
3
  end
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.8
4
+ version: 0.5.1
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-05-10 00:00:00.000000000 Z
11
+ date: 2022-06-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler