reso_api 0.5.9 → 1.5.11

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: 93ec181b3e217de6fae6347dfc921e023c754e3d39227853113ec99aebbd181a
4
- data.tar.gz: 73cdf08d64867150523c3fbac8ea5a963d54a4ec93ead7f8c83e919e86e786a9
3
+ metadata.gz: 64179669c8f73aa664bf2b2815e3e29408c889c9a1b666feea5c72d085e66883
4
+ data.tar.gz: e8a5487613760ab0639f531c795c6fb53a384b5b24cc89713fa0e4c367aef50f
5
5
  SHA512:
6
- metadata.gz: 2336f6f961807d614d081048df9ca05f46d8d719ed2828ce6b09285ff77fc7ca202318e0779913d6a1757ed7f5ab5426b2b1d33e90faddb10f34cdd0bf6400b7
7
- data.tar.gz: c454d4ff69646023681b29792b2a4f8f3af8ac81616204d89fc5d3b8da1b24f822441c0300794920f8aa075884480d4a3997b2b6b69280231b1977c25f8c1cdc
6
+ metadata.gz: '085e6a8cb6ca3c2888d730159bc1725f9fce37caa51ac5c5463fd49c435212e9a22b9f90c85baf54da25d3abc3b4e31b5bfb59312d400a2ef95702e1bd7a1d28'
7
+ data.tar.gz: 450cbebaa917b8a222de34348befcc83953886ed411fa2095ec792628c111f3ae319bf852dbe683eb184234ae3a8c7c629e2d1d1d3bb4c18e486649deca5f5ab
@@ -51,7 +51,6 @@ module RESO
51
51
  hash = args.first.is_a?(Hash) ? args.first : {}
52
52
  endpoint = FILTERABLE_ENDPOINTS[method_name]
53
53
  response = {}
54
- threads = []
55
54
  params = {
56
55
  "$select": hash[:select],
57
56
  "$filter": hash[:filter],
@@ -68,25 +67,15 @@ module RESO
68
67
  response = perform_call(endpoint, params)
69
68
 
70
69
  if response["value"].class.eql?(Array)
71
- threads << Thread.new do
72
- hash[:batch] ? block.call(response["value"]) : response["value"].each{|hash| block.call(hash)}
73
- end
70
+ hash[:batch] ? block.call(response["value"]) : response["value"].each{|hash| block.call(hash)}
74
71
  end
75
72
 
76
73
  while (next_link = response["@odata.nextLink"]).present?
77
- threads << Thread.new do
78
- response = perform_call(next_link, nil)
79
- end
80
-
81
- threads.each(&:join)
82
-
74
+ response = perform_call(next_link, nil)
83
75
  if response["value"].class.eql?(Array)
84
- threads << Thread.new do
85
- hash[:batch] ? block.call(response["value"]) : response["value"].each{|hash| block.call(hash)}
86
- end
76
+ hash[:batch] ? block.call(response["value"]) : response["value"].each{|hash| block.call(hash)}
87
77
  end
88
78
  end
89
- threads.each(&:join)
90
79
  else
91
80
  return perform_call(endpoint, params)
92
81
  end
@@ -137,7 +126,7 @@ module RESO
137
126
  end
138
127
 
139
128
  def oauth2_token_path
140
- File.join(Dir.tmpdir, [base_url.parameterize, "-oauth-token.json"].join)
129
+ File.join(Dir.tmpdir, [base_url.parameterize, client_id, "oauth-token.json"].join("-"))
141
130
  end
142
131
 
143
132
  def oauth2_payload
@@ -175,13 +164,17 @@ module RESO
175
164
  end
176
165
  response = JSON(res.body) rescue res.body
177
166
  if response.is_a?(String) && response.include?('Bad Gateway')
167
+ puts "Error: Bad Gateway."
178
168
  raise StandardError
179
169
  elsif response.is_a?(String) && response.include?('Unauthorized')
170
+ puts "Error: Unauthorized."
180
171
  fresh_oauth2_payload
181
172
  raise StandardError
182
173
  elsif response.is_a?(Hash) && response.has_key?("error")
174
+ puts "Error."
183
175
  raise StandardError
184
176
  elsif response.is_a?(Hash) && response.has_key?("retry-after")
177
+ puts "Error: Retrying in #{response["retry-after"].to_i}} seconds."
185
178
  sleep response["retry-after"].to_i
186
179
  raise StandardError
187
180
  end
@@ -1,3 +1,3 @@
1
1
  module ResoApi
2
- VERSION = "0.5.9"
2
+ VERSION = "1.5.11"
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.5.9
4
+ version: 1.5.11
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-26 00:00:00.000000000 Z
11
+ date: 2023-01-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler