seam 2.141.0 → 2.141.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 67761c76f072fe523b56a8ee78b3112bcccd5c2da40cdd6a38c623e251a66861
4
- data.tar.gz: 17eb707e5799d5b97c05d18abb5ce0224411a9cb5f06d00166a791de0e342c66
3
+ metadata.gz: 74daae0b262e03490e0317f9b90fa9c117834a99ebce0e1e32b7c020f05bc7cd
4
+ data.tar.gz: 56c57316a19a5e4bcbd2381ac9dce3b3c84ed58d060096e8cf323b4588862f8b
5
5
  SHA512:
6
- metadata.gz: dda63b3fe99166377d432246a928f10da2f337cd8633da0df34055efb453afcffbdda6392b3ad94d4951ed12badf293dfb0bb94f5e2dd16dd8f36ef0ffe58f78
7
- data.tar.gz: 03233cc7ee5e3136c92e3274410539c0642e69352538797198e2a2dfaebfd9d3187a6fa1e15cfbd744b36c3c8ab12e490631f6513020fd8298e295d5b3fbce34
6
+ metadata.gz: e822df4248a29c5d4ee8ea3eeab2e3d19c4c33eba33f088268df9a815f6c712a95d4b12520226eef849bd32fec3c873adfbcbcc63c786bd72cc8a404d74324b2
7
+ data.tar.gz: 93db379056b0471a97aff42553b8a25011019b1d5832bd69b8e3fac8471f71fa291dddbdde4de5eb1ddbd6a53bf08bfa609cb6674f6894be2b89d89076f89ef6
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- seam (2.141.0)
4
+ seam (2.141.2)
5
5
  faraday (~> 2.7)
6
6
  faraday-retry (~> 2.2)
7
7
  svix (~> 1.30)
@@ -121,7 +121,7 @@ PLATFORMS
121
121
  x86_64-linux
122
122
 
123
123
  DEPENDENCIES
124
- bundler (~> 2.0)
124
+ bundler (~> 4.0)
125
125
  gem-release (~> 2.2)
126
126
  parse_gemspec-cli (~> 1.0)
127
127
  rake (~> 13.0)
@@ -132,5 +132,58 @@ DEPENDENCIES
132
132
  standard (~> 1.3)
133
133
  webmock (~> 3.26.2)
134
134
 
135
+ CHECKSUMS
136
+ addressable (2.9.0) sha256=7fdf6ac3660f7f4e867a0838be3f6cf722ace541dd97767fa42bc6cfa980c7af
137
+ ansi (1.6.0) sha256=ac9ea0c0ea8d32fb4e271348e609963ac78882f34b73836c2a02b3622e666658
138
+ ast (2.4.3) sha256=954615157c1d6a382bc27d690d973195e79db7f55e9765ac7c481c60bdb4d383
139
+ base64 (0.3.0) sha256=27337aeabad6ffae05c265c450490628ef3ebd4b67be58257393227588f5a97b
140
+ bigdecimal (4.1.2) sha256=53d217666027eab4280346fba98e7d5b66baaae1b9c3c1c0ffe89d48188a3fbd
141
+ crack (1.0.1) sha256=ff4a10390cd31d66440b7524eb1841874db86201d5b70032028553130b6d4c7e
142
+ diff-lcs (1.6.2) sha256=9ae0d2cba7d4df3075fe8cd8602a8604993efc0dfa934cff568969efb1909962
143
+ faraday (2.14.3) sha256=1882247e6766615c8220b4392bf1d27f6ebb63d8e28267587cef1fb0bf37f278
144
+ faraday-net_http (3.4.4) sha256=0e78af151747ed1b00f33e25973b4bc220d7f16c00c39676817c8b12331eb588
145
+ faraday-retry (2.4.0) sha256=7b79c48fb7e56526faf247b12d94a680071ff40c9fda7cf1ec1549439ad11ebe
146
+ gem-release (2.2.4) sha256=2f11124c1580c811507c3b47e875e420cf3ed792a98105b49df11971e6e94db3
147
+ hashdiff (1.2.1) sha256=9c079dbc513dfc8833ab59c0c2d8f230fa28499cc5efb4b8dd276cf931457cd1
148
+ json (2.21.2) sha256=1f1d3b7cf2b3ba1a69beca0bb6db13d5438b80bff3cd54cdaaa620b9b07c1c6a
149
+ language_server-protocol (3.17.0.6) sha256=5ef2c0c138f8267e1bc631d3328347d354f96724b0af22f2c79516120443b7f0
150
+ lint_roller (1.1.0) sha256=2c0c845b632a7d172cb849cc90c1bce937a28c5c8ccccb50dfd46a485003cc87
151
+ logger (1.7.0) sha256=196edec7cc44b66cfb40f9755ce11b392f21f7967696af15d274dde7edff0203
152
+ multi_json (1.21.1) sha256=e6126a31808e3b4d19f483c775ceac34df190dffa62adfb63a165ee14ba68080
153
+ net-http (0.9.1) sha256=25ba0b67c63e89df626ed8fac771d0ad24ad151a858af2cc8e6a716ca4336996
154
+ parallel (2.1.0) sha256=b35258865c2e31134c5ecb708beaaf6772adf9d5efae28e93e99260877b09356
155
+ parse_gemspec (1.0.0) sha256=1b324fdf93821fdc6515a989c4abefb2660e6fc9fd3d92a99ae9f65db48f1a76
156
+ parse_gemspec-cli (1.0.0) sha256=64207785844eabcd20770aeb959ecd0af25cbae6f165c11c97f21905d1144fe2
157
+ parser (3.3.12.0) sha256=21a6d7f755d5a24dfbdc6e6b772e4e879a52e7631a88bc5a3a134606052c9828
158
+ prism (1.9.0) sha256=7b530c6a9f92c24300014919c9dcbc055bf4cdf51ec30aed099b06cd6674ef85
159
+ public_suffix (7.0.5) sha256=1a8bb08f1bbea19228d3bed6e5ed908d1cb4f7c2726d18bd9cadf60bc676f623
160
+ racc (1.8.1) sha256=4a7f6929691dbec8b5209a0b373bc2614882b55fc5d2e447a21aaa691303d62f
161
+ rainbow (3.1.1) sha256=039491aa3a89f42efa1d6dec2fc4e62ede96eb6acd95e52f1ad581182b79bc6a
162
+ rake (13.4.2) sha256=cb825b2bd5f1f8e91ca37bddb4b9aaf345551b4731da62949be002fa89283701
163
+ regexp_parser (2.12.0) sha256=35a916a1d63190ab5c9009457136ae5f3c0c7512d60291d0d1378ba18ce08ebb
164
+ rexml (3.4.4) sha256=19e0a2c3425dfbf2d4fc1189747bdb2f849b6c5e74180401b15734bc97b5d142
165
+ rspec (3.13.2) sha256=206284a08ad798e61f86d7ca3e376718d52c0bc944626b2349266f239f820587
166
+ rspec-core (3.13.6) sha256=a8823c6411667b60a8bca135364351dda34cd55e44ff94c4be4633b37d828b2d
167
+ rspec-expectations (3.13.5) sha256=33a4d3a1d95060aea4c94e9f237030a8f9eae5615e9bd85718fe3a09e4b58836
168
+ rspec-mocks (3.13.8) sha256=086ad3d3d17533f4237643de0b5c42f04b66348c28bf6b9c2d3f4a3b01af1d47
169
+ rspec-support (3.13.7) sha256=0640e5570872aafefd79867901deeeeb40b0c9875a36b983d85f54fb7381c47c
170
+ rubocop (1.88.2) sha256=8def251c90cd955feb4daa3edc0ab56893250c4ce90ef81e6c80c03f9a939bbf
171
+ rubocop-ast (1.50.0) sha256=b9ca88300da0803ee222ad20cdb30494c0a784eed06fdc35d254b06d662788db
172
+ rubocop-performance (1.26.1) sha256=cd19b936ff196df85829d264b522fd4f98b6c89ad271fa52744a8c11b8f71834
173
+ ruby-progressbar (1.13.0) sha256=80fc9c47a9b640d6834e0dc7b3c94c9df37f08cb072b7761e4a71e22cff29b33
174
+ seam (2.141.2)
175
+ simplecov (1.1.1) sha256=25825ef13f0b2e74694d769817dad6ab8e90131dabdaa666e522fea105521e78
176
+ simplecov-console (0.9.5) sha256=b1108bcfff5f210143e2b8301698c367b01586f20d25a73e95475a5df6fc6ff6
177
+ standard (1.56.0) sha256=ae2af4d9669589162ac69ed5ef59dcf9f346d4afc81f7e62b84339310dfcb787
178
+ standard-custom (1.0.2) sha256=424adc84179a074f1a2a309bb9cf7cd6bfdb2b6541f20c6bf9436c0ba22a652b
179
+ standard-performance (1.9.0) sha256=49483d31be448292951d80e5e67cdcb576c2502103c7b40aec6f1b6e9c88e3f2
180
+ svix (1.99.1) sha256=d6a2942156242e3c17bd69e03145ff8338bc1384c66514d231420f7c981ca40c
181
+ terminal-table (4.0.0) sha256=f504793203f8251b2ea7c7068333053f0beeea26093ec9962e62ea79f94301d2
182
+ thor (1.5.0) sha256=e3a9e55fe857e44859ce104a84675ab6e8cd59c650a49106a05f55f136425e73
183
+ unicode-display_width (3.2.0) sha256=0cdd96b5681a5949cdbc2c55e7b420facae74c4aaf9a9815eee1087cb1853c42
184
+ unicode-emoji (4.2.0) sha256=519e69150f75652e40bf736106cfbc8f0f73aa3fb6a65afe62fefa7f80b0f80f
185
+ uri (1.1.1) sha256=379fa58d27ffb1387eaada68c749d1426738bd0f654d812fcc07e7568f5c57c6
186
+ webmock (3.26.2) sha256=774556f2ea6371846cca68c01769b2eac0d134492d21f6d0ab5dd643965a4c90
187
+
135
188
  BUNDLED WITH
136
- 2.5.22
189
+ 4.0.3
@@ -0,0 +1,54 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "wait_for_action_attempt"
4
+
5
+ module Seam
6
+ class ActionAttemptResolver
7
+ def self.resolve(action_attempt, client, wait_for_action_attempt)
8
+ return wait_until_resolved(action_attempt, client) if wait_for_action_attempt == true
9
+
10
+ options = wait_options(wait_for_action_attempt)
11
+ return action_attempt if options.nil?
12
+
13
+ wait_until_resolved(action_attempt, client, timeout: options[:timeout],
14
+ polling_interval: options[:polling_interval])
15
+ end
16
+
17
+ # The client wraps its defaults in a DeepHashAccessor, so the hash form of
18
+ # this option reaches here as an accessor when it comes from the client
19
+ # and as a plain Hash when it comes from the method call.
20
+ def self.wait_options(wait_for_action_attempt)
21
+ case wait_for_action_attempt
22
+ when Hash then wait_for_action_attempt
23
+ when Seam::DeepHashAccessor then wait_for_action_attempt.to_h
24
+ end
25
+ end
26
+
27
+ def self.wait_until_resolved(action_attempt, client, timeout: nil, polling_interval: nil)
28
+ timeout = timeout.nil? ? 5.0 : timeout
29
+ polling_interval = polling_interval.nil? ? 0.5 : polling_interval
30
+
31
+ time_waiting = 0.0
32
+
33
+ while action_attempt.status == "pending"
34
+ sleep(polling_interval)
35
+ time_waiting += polling_interval
36
+
37
+ raise Seam::ActionAttemptTimeoutError.new(action_attempt, timeout) if time_waiting > timeout
38
+
39
+ action_attempt = update_action_attempt(action_attempt, client)
40
+ end
41
+
42
+ raise Seam::ActionAttemptFailedError.new(action_attempt) if action_attempt.status == "error"
43
+
44
+ action_attempt
45
+ end
46
+
47
+ def self.update_action_attempt(action_attempt, client)
48
+ response = client.get("/action_attempts/get", {action_attempt_id: action_attempt.action_attempt_id})
49
+
50
+ action_attempt.update_from_response(response.body["action_attempt"])
51
+ action_attempt
52
+ end
53
+ end
54
+ end
data/lib/seam/request.rb CHANGED
@@ -25,6 +25,12 @@ module Seam
25
25
  }
26
26
 
27
27
  options = deep_merge(default_options, faraday_options)
28
+ options.delete("headers")
29
+ options[:headers] = merge_headers(
30
+ faraday_options[:headers] || faraday_options["headers"] || {},
31
+ auth_headers,
32
+ default_headers
33
+ )
28
34
 
29
35
  default_faraday_retry_options = {
30
36
  max: 2,
@@ -49,7 +55,6 @@ module Seam
49
55
 
50
56
  def self.default_headers
51
57
  {
52
- "User-Agent" => "seam-ruby/#{Seam::VERSION}",
53
58
  "Content-Type" => "application/json",
54
59
  :"seam-sdk-name" => "seamapi/ruby",
55
60
  :"seam-sdk-version" => Seam::VERSION
@@ -123,7 +128,23 @@ module Seam
123
128
  result
124
129
  end
125
130
 
126
- private_class_method :deep_merge
131
+ def self.merge_headers(*headers_list)
132
+ result = {}
133
+ header_keys = {}
134
+
135
+ headers_list.each do |headers|
136
+ headers.each do |key, value|
137
+ normalized_key = key.to_s.downcase
138
+ result.delete(header_keys[normalized_key]) if header_keys.key?(normalized_key)
139
+ header_keys[normalized_key] = key
140
+ result[key] = value
141
+ end
142
+ end
143
+
144
+ result
145
+ end
146
+
147
+ private_class_method :deep_merge, :merge_headers
127
148
  end
128
149
 
129
150
  module UrlSearchParamsEncoder
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require "seam/helpers/action_attempt"
3
+ require "seam/action_attempt_resolver"
4
4
 
5
5
  module Seam
6
6
  module Clients
@@ -23,7 +23,7 @@ module Seam
23
23
 
24
24
  wait_for_action_attempt = wait_for_action_attempt.nil? ? @defaults.wait_for_action_attempt : wait_for_action_attempt
25
25
 
26
- Helpers::ActionAttempt.decide_and_wait(Seam::Resources::ActionAttempt.load_from_response(res.body["action_attempt"]), @client, wait_for_action_attempt)
26
+ Seam::ActionAttemptResolver.resolve(Seam::Resources::ActionAttempt.load_from_response(res.body["action_attempt"]), @client, wait_for_action_attempt)
27
27
  end
28
28
 
29
29
  # Deletes an access method.
@@ -50,7 +50,7 @@ module Seam
50
50
 
51
51
  wait_for_action_attempt = wait_for_action_attempt.nil? ? @defaults.wait_for_action_attempt : wait_for_action_attempt
52
52
 
53
- Helpers::ActionAttempt.decide_and_wait(Seam::Resources::ActionAttempt.load_from_response(res.body["action_attempt"]), @client, wait_for_action_attempt)
53
+ Seam::ActionAttemptResolver.resolve(Seam::Resources::ActionAttempt.load_from_response(res.body["action_attempt"]), @client, wait_for_action_attempt)
54
54
  end
55
55
 
56
56
  # Gets an access method.
@@ -102,7 +102,7 @@ module Seam
102
102
 
103
103
  wait_for_action_attempt = wait_for_action_attempt.nil? ? @defaults.wait_for_action_attempt : wait_for_action_attempt
104
104
 
105
- Helpers::ActionAttempt.decide_and_wait(Seam::Resources::ActionAttempt.load_from_response(res.body["action_attempt"]), @client, wait_for_action_attempt)
105
+ Seam::ActionAttemptResolver.resolve(Seam::Resources::ActionAttempt.load_from_response(res.body["action_attempt"]), @client, wait_for_action_attempt)
106
106
  end
107
107
  end
108
108
  end
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require "seam/helpers/action_attempt"
3
+ require "seam/action_attempt_resolver"
4
4
 
5
5
  module Seam
6
6
  module Clients
@@ -24,7 +24,7 @@ module Seam
24
24
 
25
25
  wait_for_action_attempt = wait_for_action_attempt.nil? ? @defaults.wait_for_action_attempt : wait_for_action_attempt
26
26
 
27
- Helpers::ActionAttempt.decide_and_wait(Seam::Resources::ActionAttempt.load_from_response(res.body["action_attempt"]), @client, wait_for_action_attempt)
27
+ Seam::ActionAttemptResolver.resolve(Seam::Resources::ActionAttempt.load_from_response(res.body["action_attempt"]), @client, wait_for_action_attempt)
28
28
  end
29
29
 
30
30
  # Returns a specified [encoder](https://docs.seam.co/low-level-apis/access-systems/working-with-card-encoders-and-scanners).
@@ -58,7 +58,7 @@ module Seam
58
58
 
59
59
  wait_for_action_attempt = wait_for_action_attempt.nil? ? @defaults.wait_for_action_attempt : wait_for_action_attempt
60
60
 
61
- Helpers::ActionAttempt.decide_and_wait(Seam::Resources::ActionAttempt.load_from_response(res.body["action_attempt"]), @client, wait_for_action_attempt)
61
+ Seam::ActionAttemptResolver.resolve(Seam::Resources::ActionAttempt.load_from_response(res.body["action_attempt"]), @client, wait_for_action_attempt)
62
62
  end
63
63
 
64
64
  # Scans a physical card placed on the specified [encoder](https://docs.seam.co/low-level-apis/access-systems/working-with-card-encoders-and-scanners) and assigns the scanned credential to an ACS user. Provide either an `acs_user_id` or a `user_identity_id`.
@@ -72,7 +72,7 @@ module Seam
72
72
 
73
73
  wait_for_action_attempt = wait_for_action_attempt.nil? ? @defaults.wait_for_action_attempt : wait_for_action_attempt
74
74
 
75
- Helpers::ActionAttempt.decide_and_wait(Seam::Resources::ActionAttempt.load_from_response(res.body["action_attempt"]), @client, wait_for_action_attempt)
75
+ Seam::ActionAttemptResolver.resolve(Seam::Resources::ActionAttempt.load_from_response(res.body["action_attempt"]), @client, wait_for_action_attempt)
76
76
  end
77
77
  end
78
78
  end
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require "seam/helpers/action_attempt"
3
+ require "seam/action_attempt_resolver"
4
4
 
5
5
  module Seam
6
6
  module Clients
@@ -69,7 +69,7 @@ module Seam
69
69
 
70
70
  wait_for_action_attempt = wait_for_action_attempt.nil? ? @defaults.wait_for_action_attempt : wait_for_action_attempt
71
71
 
72
- Helpers::ActionAttempt.decide_and_wait(Seam::Resources::ActionAttempt.load_from_response(res.body["action_attempt"]), @client, wait_for_action_attempt)
72
+ Seam::ActionAttemptResolver.resolve(Seam::Resources::ActionAttempt.load_from_response(res.body["action_attempt"]), @client, wait_for_action_attempt)
73
73
  end
74
74
  end
75
75
  end
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require "seam/helpers/action_attempt"
3
+ require "seam/action_attempt_resolver"
4
4
 
5
5
  module Seam
6
6
  module Clients
@@ -18,7 +18,7 @@ module Seam
18
18
 
19
19
  wait_for_action_attempt = wait_for_action_attempt.nil? ? @defaults.wait_for_action_attempt : wait_for_action_attempt
20
20
 
21
- Helpers::ActionAttempt.decide_and_wait(Seam::Resources::ActionAttempt.load_from_response(res.body["action_attempt"]), @client, wait_for_action_attempt)
21
+ Seam::ActionAttemptResolver.resolve(Seam::Resources::ActionAttempt.load_from_response(res.body["action_attempt"]), @client, wait_for_action_attempt)
22
22
  end
23
23
 
24
24
  # Returns a list of the [action attempts](https://docs.seam.co/core-concepts/action-attempts) that you specify as an array of `action_attempt_id`s.
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require "seam/helpers/action_attempt"
3
+ require "seam/action_attempt_resolver"
4
4
 
5
5
  module Seam
6
6
  module Clients
@@ -24,7 +24,7 @@ module Seam
24
24
 
25
25
  wait_for_action_attempt = wait_for_action_attempt.nil? ? @defaults.wait_for_action_attempt : wait_for_action_attempt
26
26
 
27
- Helpers::ActionAttempt.decide_and_wait(Seam::Resources::ActionAttempt.load_from_response(res.body["action_attempt"]), @client, wait_for_action_attempt)
27
+ Seam::ActionAttemptResolver.resolve(Seam::Resources::ActionAttempt.load_from_response(res.body["action_attempt"]), @client, wait_for_action_attempt)
28
28
  end
29
29
 
30
30
  # Returns a specified [lock](https://docs.seam.co/low-level-apis/smart-locks).
@@ -64,7 +64,7 @@ module Seam
64
64
 
65
65
  wait_for_action_attempt = wait_for_action_attempt.nil? ? @defaults.wait_for_action_attempt : wait_for_action_attempt
66
66
 
67
- Helpers::ActionAttempt.decide_and_wait(Seam::Resources::ActionAttempt.load_from_response(res.body["action_attempt"]), @client, wait_for_action_attempt)
67
+ Seam::ActionAttemptResolver.resolve(Seam::Resources::ActionAttempt.load_from_response(res.body["action_attempt"]), @client, wait_for_action_attempt)
68
68
  end
69
69
 
70
70
  # Unlocks a [lock](https://docs.seam.co/low-level-apis/smart-locks). See also [Locking and Unlocking Smart Locks](https://docs.seam.co/low-level-apis/smart-locks/lock-and-unlock).
@@ -75,7 +75,7 @@ module Seam
75
75
 
76
76
  wait_for_action_attempt = wait_for_action_attempt.nil? ? @defaults.wait_for_action_attempt : wait_for_action_attempt
77
77
 
78
- Helpers::ActionAttempt.decide_and_wait(Seam::Resources::ActionAttempt.load_from_response(res.body["action_attempt"]), @client, wait_for_action_attempt)
78
+ Seam::ActionAttemptResolver.resolve(Seam::Resources::ActionAttempt.load_from_response(res.body["action_attempt"]), @client, wait_for_action_attempt)
79
79
  end
80
80
  end
81
81
  end
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require "seam/helpers/action_attempt"
3
+ require "seam/action_attempt_resolver"
4
4
 
5
5
  module Seam
6
6
  module Clients
@@ -19,7 +19,7 @@ module Seam
19
19
 
20
20
  wait_for_action_attempt = wait_for_action_attempt.nil? ? @defaults.wait_for_action_attempt : wait_for_action_attempt
21
21
 
22
- Helpers::ActionAttempt.decide_and_wait(Seam::Resources::ActionAttempt.load_from_response(res.body["action_attempt"]), @client, wait_for_action_attempt)
22
+ Seam::ActionAttemptResolver.resolve(Seam::Resources::ActionAttempt.load_from_response(res.body["action_attempt"]), @client, wait_for_action_attempt)
23
23
  end
24
24
 
25
25
  # Simulates a manual lock action using a keypad. You can only perform this action for [August](https://docs.seam.co/device-and-system-integration-guides/august-locks) devices within [sandbox workspaces](https://docs.seam.co/core-concepts/workspaces#sandbox-workspaces).
@@ -30,7 +30,7 @@ module Seam
30
30
 
31
31
  wait_for_action_attempt = wait_for_action_attempt.nil? ? @defaults.wait_for_action_attempt : wait_for_action_attempt
32
32
 
33
- Helpers::ActionAttempt.decide_and_wait(Seam::Resources::ActionAttempt.load_from_response(res.body["action_attempt"]), @client, wait_for_action_attempt)
33
+ Seam::ActionAttemptResolver.resolve(Seam::Resources::ActionAttempt.load_from_response(res.body["action_attempt"]), @client, wait_for_action_attempt)
34
34
  end
35
35
  end
36
36
  end
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require "seam/helpers/action_attempt"
3
+ require "seam/action_attempt_resolver"
4
4
 
5
5
  module Seam
6
6
  module Clients
@@ -31,7 +31,7 @@ module Seam
31
31
 
32
32
  wait_for_action_attempt = wait_for_action_attempt.nil? ? @defaults.wait_for_action_attempt : wait_for_action_attempt
33
33
 
34
- Helpers::ActionAttempt.decide_and_wait(Seam::Resources::ActionAttempt.load_from_response(res.body["action_attempt"]), @client, wait_for_action_attempt)
34
+ Seam::ActionAttemptResolver.resolve(Seam::Resources::ActionAttempt.load_from_response(res.body["action_attempt"]), @client, wait_for_action_attempt)
35
35
  end
36
36
 
37
37
  # Sets a specified [thermostat](https://docs.seam.co/capability-guides/thermostats) to [cool mode](https://docs.seam.co/capability-guides/thermostats/configure-current-climate-settings).
@@ -44,7 +44,7 @@ module Seam
44
44
 
45
45
  wait_for_action_attempt = wait_for_action_attempt.nil? ? @defaults.wait_for_action_attempt : wait_for_action_attempt
46
46
 
47
- Helpers::ActionAttempt.decide_and_wait(Seam::Resources::ActionAttempt.load_from_response(res.body["action_attempt"]), @client, wait_for_action_attempt)
47
+ Seam::ActionAttemptResolver.resolve(Seam::Resources::ActionAttempt.load_from_response(res.body["action_attempt"]), @client, wait_for_action_attempt)
48
48
  end
49
49
 
50
50
  # Creates a [climate preset](https://docs.seam.co/capability-guides/thermostats/creating-and-managing-climate-presets) for a specified [thermostat](https://docs.seam.co/capability-guides/thermostats).
@@ -88,7 +88,7 @@ module Seam
88
88
 
89
89
  wait_for_action_attempt = wait_for_action_attempt.nil? ? @defaults.wait_for_action_attempt : wait_for_action_attempt
90
90
 
91
- Helpers::ActionAttempt.decide_and_wait(Seam::Resources::ActionAttempt.load_from_response(res.body["action_attempt"]), @client, wait_for_action_attempt)
91
+ Seam::ActionAttemptResolver.resolve(Seam::Resources::ActionAttempt.load_from_response(res.body["action_attempt"]), @client, wait_for_action_attempt)
92
92
  end
93
93
 
94
94
  # Sets a specified [thermostat](https://docs.seam.co/capability-guides/thermostats) to [heat-cool ("auto") mode](https://docs.seam.co/capability-guides/thermostats/configure-current-climate-settings).
@@ -103,7 +103,7 @@ module Seam
103
103
 
104
104
  wait_for_action_attempt = wait_for_action_attempt.nil? ? @defaults.wait_for_action_attempt : wait_for_action_attempt
105
105
 
106
- Helpers::ActionAttempt.decide_and_wait(Seam::Resources::ActionAttempt.load_from_response(res.body["action_attempt"]), @client, wait_for_action_attempt)
106
+ Seam::ActionAttemptResolver.resolve(Seam::Resources::ActionAttempt.load_from_response(res.body["action_attempt"]), @client, wait_for_action_attempt)
107
107
  end
108
108
 
109
109
  # Returns a list of all [thermostats](https://docs.seam.co/capability-guides/thermostats).
@@ -128,7 +128,7 @@ module Seam
128
128
 
129
129
  wait_for_action_attempt = wait_for_action_attempt.nil? ? @defaults.wait_for_action_attempt : wait_for_action_attempt
130
130
 
131
- Helpers::ActionAttempt.decide_and_wait(Seam::Resources::ActionAttempt.load_from_response(res.body["action_attempt"]), @client, wait_for_action_attempt)
131
+ Seam::ActionAttemptResolver.resolve(Seam::Resources::ActionAttempt.load_from_response(res.body["action_attempt"]), @client, wait_for_action_attempt)
132
132
  end
133
133
 
134
134
  # Sets a specified [climate preset](https://docs.seam.co/capability-guides/thermostats/creating-and-managing-climate-presets) as the ["fallback"](https://docs.seam.co/capability-guides/thermostats/creating-and-managing-climate-presets/setting-the-fallback-climate-preset) preset for a specified [thermostat](https://docs.seam.co/capability-guides/thermostats).
@@ -152,7 +152,7 @@ module Seam
152
152
 
153
153
  wait_for_action_attempt = wait_for_action_attempt.nil? ? @defaults.wait_for_action_attempt : wait_for_action_attempt
154
154
 
155
- Helpers::ActionAttempt.decide_and_wait(Seam::Resources::ActionAttempt.load_from_response(res.body["action_attempt"]), @client, wait_for_action_attempt)
155
+ Seam::ActionAttemptResolver.resolve(Seam::Resources::ActionAttempt.load_from_response(res.body["action_attempt"]), @client, wait_for_action_attempt)
156
156
  end
157
157
 
158
158
  # Sets the [HVAC mode](https://docs.seam.co/capability-guides/thermostats/configure-current-climate-settings) for a specified [thermostat](https://docs.seam.co/capability-guides/thermostats).
@@ -168,7 +168,7 @@ module Seam
168
168
 
169
169
  wait_for_action_attempt = wait_for_action_attempt.nil? ? @defaults.wait_for_action_attempt : wait_for_action_attempt
170
170
 
171
- Helpers::ActionAttempt.decide_and_wait(Seam::Resources::ActionAttempt.load_from_response(res.body["action_attempt"]), @client, wait_for_action_attempt)
171
+ Seam::ActionAttemptResolver.resolve(Seam::Resources::ActionAttempt.load_from_response(res.body["action_attempt"]), @client, wait_for_action_attempt)
172
172
  end
173
173
 
174
174
  # Sets a [temperature threshold](https://docs.seam.co/capability-guides/thermostats/setting-and-monitoring-temperature-thresholds) for a specified thermostat. Seam emits a `thermostat.temperature_threshold_exceeded` event and adds a warning on a thermostat if it reports a temperature outside the threshold range.
@@ -220,7 +220,7 @@ module Seam
220
220
 
221
221
  wait_for_action_attempt = wait_for_action_attempt.nil? ? @defaults.wait_for_action_attempt : wait_for_action_attempt
222
222
 
223
- Helpers::ActionAttempt.decide_and_wait(Seam::Resources::ActionAttempt.load_from_response(res.body["action_attempt"]), @client, wait_for_action_attempt)
223
+ Seam::ActionAttemptResolver.resolve(Seam::Resources::ActionAttempt.load_from_response(res.body["action_attempt"]), @client, wait_for_action_attempt)
224
224
  end
225
225
  end
226
226
  end
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require "seam/helpers/action_attempt"
3
+ require "seam/action_attempt_resolver"
4
4
 
5
5
  module Seam
6
6
  module Clients
@@ -40,7 +40,7 @@ module Seam
40
40
 
41
41
  wait_for_action_attempt = wait_for_action_attempt.nil? ? @defaults.wait_for_action_attempt : wait_for_action_attempt
42
42
 
43
- Helpers::ActionAttempt.decide_and_wait(Seam::Resources::ActionAttempt.load_from_response(res.body["action_attempt"]), @client, wait_for_action_attempt)
43
+ Seam::ActionAttemptResolver.resolve(Seam::Resources::ActionAttempt.load_from_response(res.body["action_attempt"]), @client, wait_for_action_attempt)
44
44
  end
45
45
  end
46
46
  end
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require "seam/helpers/action_attempt"
3
+ require "seam/action_attempt_resolver"
4
4
 
5
5
  module Seam
6
6
  module Clients
@@ -56,7 +56,7 @@ module Seam
56
56
 
57
57
  wait_for_action_attempt = wait_for_action_attempt.nil? ? @defaults.wait_for_action_attempt : wait_for_action_attempt
58
58
 
59
- Helpers::ActionAttempt.decide_and_wait(Seam::Resources::ActionAttempt.load_from_response(res.body["action_attempt"]), @client, wait_for_action_attempt)
59
+ Seam::ActionAttemptResolver.resolve(Seam::Resources::ActionAttempt.load_from_response(res.body["action_attempt"]), @client, wait_for_action_attempt)
60
60
  end
61
61
 
62
62
  # Updates the [workspace](https://docs.seam.co/core-concepts/workspaces) associated with the authentication value.
data/lib/seam/version.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Seam
4
- VERSION = "2.141.0"
4
+ VERSION = "2.141.2"
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: seam
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.141.0
4
+ version: 2.141.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Seam Labs, Inc.
@@ -57,14 +57,14 @@ dependencies:
57
57
  requirements:
58
58
  - - "~>"
59
59
  - !ruby/object:Gem::Version
60
- version: '2.0'
60
+ version: '4.0'
61
61
  type: :development
62
62
  prerelease: false
63
63
  version_requirements: !ruby/object:Gem::Requirement
64
64
  requirements:
65
65
  - - "~>"
66
66
  - !ruby/object:Gem::Version
67
- version: '2.0'
67
+ version: '4.0'
68
68
  - !ruby/object:Gem::Dependency
69
69
  name: gem-release
70
70
  requirement: !ruby/object:Gem::Requirement
@@ -189,11 +189,11 @@ files:
189
189
  - README.md
190
190
  - Rakefile
191
191
  - lib/seam.rb
192
+ - lib/seam/action_attempt_resolver.rb
192
193
  - lib/seam/auth.rb
193
194
  - lib/seam/base_resource.rb
194
195
  - lib/seam/deep_hash_accessor.rb
195
196
  - lib/seam/defaults.rb
196
- - lib/seam/helpers/action_attempt.rb
197
197
  - lib/seam/http.rb
198
198
  - lib/seam/http_single_workspace.rb
199
199
  - lib/seam/http_without_workspace.rb
@@ -1,56 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require_relative "../wait_for_action_attempt"
4
-
5
- module Seam
6
- module Helpers
7
- module ActionAttempt
8
- def self.decide_and_wait(action_attempt, client, wait_for_action_attempt)
9
- return wait_until_finished(action_attempt, client) if wait_for_action_attempt == true
10
-
11
- options = wait_options(wait_for_action_attempt)
12
- return action_attempt if options.nil?
13
-
14
- wait_until_finished(action_attempt, client, timeout: options[:timeout],
15
- polling_interval: options[:polling_interval])
16
- end
17
-
18
- # The client wraps its defaults in a DeepHashAccessor, so the hash form of
19
- # this option reaches here as an accessor when it comes from the client
20
- # and as a plain Hash when it comes from the method call.
21
- def self.wait_options(wait_for_action_attempt)
22
- case wait_for_action_attempt
23
- when Hash then wait_for_action_attempt
24
- when Seam::DeepHashAccessor then wait_for_action_attempt.to_h
25
- end
26
- end
27
-
28
- def self.wait_until_finished(action_attempt, client, timeout: nil, polling_interval: nil)
29
- timeout = timeout.nil? ? 5.0 : timeout
30
- polling_interval = polling_interval.nil? ? 0.5 : polling_interval
31
-
32
- time_waiting = 0.0
33
-
34
- while action_attempt.status == "pending"
35
- sleep(polling_interval)
36
- time_waiting += polling_interval
37
-
38
- raise Seam::ActionAttemptTimeoutError.new(action_attempt, timeout) if time_waiting > timeout
39
-
40
- action_attempt = update_action_attempt(action_attempt, client)
41
- end
42
-
43
- raise Seam::ActionAttemptFailedError.new(action_attempt) if action_attempt.status == "error"
44
-
45
- action_attempt
46
- end
47
-
48
- def self.update_action_attempt(action_attempt, client)
49
- response = client.get("/action_attempts/get", {action_attempt_id: action_attempt.action_attempt_id})
50
-
51
- action_attempt.update_from_response(response.body["action_attempt"])
52
- action_attempt
53
- end
54
- end
55
- end
56
- end