seam 2.149.0 → 2.150.0

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: 20eb2c8e0938d5dcb96d337254d2eaba3c77d9c1fe672292c09af488638aa3b3
4
- data.tar.gz: 24d8ca1c9ce0dd9f901fc19fcb48990885e9301a9feb0fa26fd890cd0fdc55e6
3
+ metadata.gz: 622126d4b9112044964d3981c67d435df6ee7312b92328ba2164e0694f637453
4
+ data.tar.gz: b7125af103c4c2c77bc7af576f4e510991e9dcabc99f9cec77878798f6d3caf5
5
5
  SHA512:
6
- metadata.gz: 054cbd509a8a694e7b3c56a068f10256b0563a3327d9d4032236a996cd7c9d2af2d761e65573f2a17e0fd9f475bb9eb4a388e3cb6b6f147b6d3fa41548589f32
7
- data.tar.gz: 0cbe6605e8b2c9e913a97ad1810d837ee84c3480da6e713107bf031ba0100c6be31633941a2930f422fd11dec915633699b484f7bf14ef00bf89e3d25fca6492
6
+ metadata.gz: e7a700660cc4938aea1e2f413a9c02b05dae9d7f17db5c78e9710f804206d294c62f7de4cf7bbafb0dca7ea839bf9b8d9d9bb33ae0698ea2df9dd4043a0fb950
7
+ data.tar.gz: a5de101243c4b173a64449a8355b19ab4e578a743b92e3b6f70ef917a95d40e2e9f3f1d38ff0f83d5da8172b8ae4cb81914f075fb4aaca042d151abeb46c9c92
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- seam (2.149.0)
4
+ seam (2.150.0)
5
5
  faraday (~> 2.7)
6
6
  faraday-retry (~> 2.2)
7
7
  svix (~> 1.30)
@@ -171,7 +171,7 @@ CHECKSUMS
171
171
  rubocop-ast (1.50.0) sha256=b9ca88300da0803ee222ad20cdb30494c0a784eed06fdc35d254b06d662788db
172
172
  rubocop-performance (1.26.1) sha256=cd19b936ff196df85829d264b522fd4f98b6c89ad271fa52744a8c11b8f71834
173
173
  ruby-progressbar (1.13.0) sha256=80fc9c47a9b640d6834e0dc7b3c94c9df37f08cb072b7761e4a71e22cff29b33
174
- seam (2.149.0)
174
+ seam (2.150.0)
175
175
  simplecov (1.1.1) sha256=25825ef13f0b2e74694d769817dad6ab8e90131dabdaa666e522fea105521e78
176
176
  simplecov-console (0.9.5) sha256=b1108bcfff5f210143e2b8301698c367b01586f20d25a73e95475a5df6fc6ff6
177
177
  standard (1.56.0) sha256=ae2af4d9669589162ac69ed5ef59dcf9f346d4afc81f7e62b84339310dfcb787
data/README.md CHANGED
@@ -163,6 +163,21 @@ When the `wait_for_action_attempt` option is enabled, the SDK:
163
163
  - Raises a `Seam::ActionAttemptTimeoutError` if the action attempt is still pending when the `timeout` is reached.
164
164
  - Both errors expose an `action_attempt` property.
165
165
 
166
+ The `error` and `result` values are only present for their matching status:
167
+ `error` is `nil` unless the `status` is `"error"`,
168
+ and `result` is `nil` unless the `status` is `"success"`.
169
+
170
+ ```ruby
171
+ action_attempt = seam.locks.unlock_door(
172
+ device_id: device_id,
173
+ wait_for_action_attempt: false
174
+ )
175
+
176
+ action_attempt.status # => "pending"
177
+ action_attempt.error # => nil
178
+ action_attempt.result # => nil
179
+ ```
180
+
166
181
  If you already have an action attempt ID
167
182
  and want to wait for it to resolve, simply use:
168
183
 
@@ -78,6 +78,14 @@ module Seam
78
78
  end
79
79
  end
80
80
 
81
+ def self.available_only_for_statuses(attr, statuses)
82
+ unscoped = instance_method(attr)
83
+ define_method(attr) do
84
+ statuses.include?(status) ? unscoped.bind_call(self) : nil
85
+ end
86
+ end
87
+ private_class_method :available_only_for_statuses
88
+
81
89
  def self.resource_accessors
82
90
  @resource_accessors ||= {}
83
91
  end
@@ -32,10 +32,14 @@ module Seam
32
32
 
33
33
  # Error associated with the action.
34
34
  # @return [Error, nil]
35
+ # Only present when `status` is `error`; `nil` otherwise.
35
36
  resource_accessor :error, Error
37
+ available_only_for_statuses :error, ["error"]
36
38
  # Result of the action.
37
39
  # @return [Result, nil]
40
+ # Only present when `status` is `success`; `nil` otherwise.
38
41
  resource_accessor :result, Result
42
+ available_only_for_statuses :result, ["success"]
39
43
  # ID of the action attempt.
40
44
  # @return [String]
41
45
  attr_accessor :action_attempt_id
@@ -71,10 +75,14 @@ module Seam
71
75
 
72
76
  # Error associated with the action.
73
77
  # @return [Error, nil]
78
+ # Only present when `status` is `error`; `nil` otherwise.
74
79
  resource_accessor :error, Error
80
+ available_only_for_statuses :error, ["error"]
75
81
  # Result of the action.
76
82
  # @return [Result, nil]
83
+ # Only present when `status` is `success`; `nil` otherwise.
77
84
  resource_accessor :result, Result
85
+ available_only_for_statuses :result, ["success"]
78
86
  # ID of the action attempt.
79
87
  # @return [String]
80
88
  attr_accessor :action_attempt_id
@@ -399,10 +407,14 @@ module Seam
399
407
  end
400
408
 
401
409
  # @return [Error, nil]
410
+ # Only present when `status` is `error`; `nil` otherwise.
402
411
  resource_accessor :error, Error
412
+ available_only_for_statuses :error, ["error"]
403
413
  # Result of scanning a card. If the attempt was successful, includes a snapshot of credential data read from the physical encoder, the corresponding data stored on Seam and the access system, and any associated warnings.
404
414
  # @return [Result, nil]
415
+ # Only present when `status` is `success`; `nil` otherwise.
405
416
  resource_accessor :result, Result
417
+ available_only_for_statuses :result, ["success"]
406
418
  # ID of the action attempt.
407
419
  # @return [String]
408
420
  attr_accessor :action_attempt_id
@@ -644,10 +656,14 @@ module Seam
644
656
  end
645
657
 
646
658
  # @return [Error, nil]
659
+ # Only present when `status` is `error`; `nil` otherwise.
647
660
  resource_accessor :error, Error
661
+ available_only_for_statuses :error, ["error"]
648
662
  # Result of an encoding attempt. If the attempt was successful, includes the credential data that was encoded onto the card.
649
663
  # @return [Result, nil]
664
+ # Only present when `status` is `success`; `nil` otherwise.
650
665
  resource_accessor :result, Result
666
+ available_only_for_statuses :result, ["success"]
651
667
  # ID of the action attempt.
652
668
  # @return [String]
653
669
  attr_accessor :action_attempt_id
@@ -883,10 +899,14 @@ module Seam
883
899
  end
884
900
 
885
901
  # @return [Error, nil]
902
+ # Only present when `status` is `error`; `nil` otherwise.
886
903
  resource_accessor :error, Error
904
+ available_only_for_statuses :error, ["error"]
887
905
  # Result of a scan to assign attempt. If the attempt was successful, includes the credential data that was scanned and assigned.
888
906
  # @return [Result, nil]
907
+ # Only present when `status` is `success`; `nil` otherwise.
889
908
  resource_accessor :result, Result
909
+ available_only_for_statuses :result, ["success"]
890
910
  # ID of the action attempt.
891
911
  # @return [String]
892
912
  attr_accessor :action_attempt_id
@@ -1058,10 +1078,14 @@ module Seam
1058
1078
  end
1059
1079
 
1060
1080
  # @return [Error, nil]
1081
+ # Only present when `status` is `error`; `nil` otherwise.
1061
1082
  resource_accessor :error, Error
1083
+ available_only_for_statuses :error, ["error"]
1062
1084
  # Result of assigning a credential. If successful, includes the updated access method with the assigned credential.
1063
1085
  # @return [Result, nil]
1086
+ # Only present when `status` is `success`; `nil` otherwise.
1064
1087
  resource_accessor :result, Result
1088
+ available_only_for_statuses :result, ["success"]
1065
1089
  # ID of the action attempt.
1066
1090
  # @return [String]
1067
1091
  attr_accessor :action_attempt_id
@@ -1094,10 +1118,14 @@ module Seam
1094
1118
 
1095
1119
  # Error associated with the action.
1096
1120
  # @return [Error, nil]
1121
+ # Only present when `status` is `error`; `nil` otherwise.
1097
1122
  resource_accessor :error, Error
1123
+ available_only_for_statuses :error, ["error"]
1098
1124
  # Result of the action.
1099
1125
  # @return [Result, nil]
1126
+ # Only present when `status` is `success`; `nil` otherwise.
1100
1127
  resource_accessor :result, Result
1128
+ available_only_for_statuses :result, ["success"]
1101
1129
  # ID of the action attempt.
1102
1130
  # @return [String]
1103
1131
  attr_accessor :action_attempt_id
@@ -1130,10 +1158,14 @@ module Seam
1130
1158
 
1131
1159
  # Error associated with the action.
1132
1160
  # @return [Error, nil]
1161
+ # Only present when `status` is `error`; `nil` otherwise.
1133
1162
  resource_accessor :error, Error
1163
+ available_only_for_statuses :error, ["error"]
1134
1164
  # Result of the action.
1135
1165
  # @return [Result, nil]
1166
+ # Only present when `status` is `success`; `nil` otherwise.
1136
1167
  resource_accessor :result, Result
1168
+ available_only_for_statuses :result, ["success"]
1137
1169
  # ID of the action attempt.
1138
1170
  # @return [String]
1139
1171
  attr_accessor :action_attempt_id
@@ -1166,10 +1198,14 @@ module Seam
1166
1198
 
1167
1199
  # Error associated with the action.
1168
1200
  # @return [Error, nil]
1201
+ # Only present when `status` is `error`; `nil` otherwise.
1169
1202
  resource_accessor :error, Error
1203
+ available_only_for_statuses :error, ["error"]
1170
1204
  # Result of the action.
1171
1205
  # @return [Result, nil]
1206
+ # Only present when `status` is `success`; `nil` otherwise.
1172
1207
  resource_accessor :result, Result
1208
+ available_only_for_statuses :result, ["success"]
1173
1209
  # ID of the action attempt.
1174
1210
  # @return [String]
1175
1211
  attr_accessor :action_attempt_id
@@ -1202,10 +1238,14 @@ module Seam
1202
1238
 
1203
1239
  # Error associated with the action.
1204
1240
  # @return [Error, nil]
1241
+ # Only present when `status` is `error`; `nil` otherwise.
1205
1242
  resource_accessor :error, Error
1243
+ available_only_for_statuses :error, ["error"]
1206
1244
  # Result of the action.
1207
1245
  # @return [Result, nil]
1246
+ # Only present when `status` is `success`; `nil` otherwise.
1208
1247
  resource_accessor :result, Result
1248
+ available_only_for_statuses :result, ["success"]
1209
1249
  # ID of the action attempt.
1210
1250
  # @return [String]
1211
1251
  attr_accessor :action_attempt_id
@@ -1238,10 +1278,14 @@ module Seam
1238
1278
 
1239
1279
  # Error associated with the action.
1240
1280
  # @return [Error, nil]
1281
+ # Only present when `status` is `error`; `nil` otherwise.
1241
1282
  resource_accessor :error, Error
1283
+ available_only_for_statuses :error, ["error"]
1242
1284
  # Result of the action.
1243
1285
  # @return [Result, nil]
1286
+ # Only present when `status` is `success`; `nil` otherwise.
1244
1287
  resource_accessor :result, Result
1288
+ available_only_for_statuses :result, ["success"]
1245
1289
  # ID of the action attempt.
1246
1290
  # @return [String]
1247
1291
  attr_accessor :action_attempt_id
@@ -1274,10 +1318,14 @@ module Seam
1274
1318
 
1275
1319
  # Error associated with the action.
1276
1320
  # @return [Error, nil]
1321
+ # Only present when `status` is `error`; `nil` otherwise.
1277
1322
  resource_accessor :error, Error
1323
+ available_only_for_statuses :error, ["error"]
1278
1324
  # Result of the action.
1279
1325
  # @return [Result, nil]
1326
+ # Only present when `status` is `success`; `nil` otherwise.
1280
1327
  resource_accessor :result, Result
1328
+ available_only_for_statuses :result, ["success"]
1281
1329
  # ID of the action attempt.
1282
1330
  # @return [String]
1283
1331
  attr_accessor :action_attempt_id
@@ -1310,10 +1358,14 @@ module Seam
1310
1358
 
1311
1359
  # Error associated with the action.
1312
1360
  # @return [Error, nil]
1361
+ # Only present when `status` is `error`; `nil` otherwise.
1313
1362
  resource_accessor :error, Error
1363
+ available_only_for_statuses :error, ["error"]
1314
1364
  # Result of the action.
1315
1365
  # @return [Result, nil]
1366
+ # Only present when `status` is `success`; `nil` otherwise.
1316
1367
  resource_accessor :result, Result
1368
+ available_only_for_statuses :result, ["success"]
1317
1369
  # ID of the action attempt.
1318
1370
  # @return [String]
1319
1371
  attr_accessor :action_attempt_id
@@ -1346,10 +1398,14 @@ module Seam
1346
1398
 
1347
1399
  # Error associated with the action.
1348
1400
  # @return [Error, nil]
1401
+ # Only present when `status` is `error`; `nil` otherwise.
1349
1402
  resource_accessor :error, Error
1403
+ available_only_for_statuses :error, ["error"]
1350
1404
  # Result of the action.
1351
1405
  # @return [Result, nil]
1406
+ # Only present when `status` is `success`; `nil` otherwise.
1352
1407
  resource_accessor :result, Result
1408
+ available_only_for_statuses :result, ["success"]
1353
1409
  # ID of the action attempt.
1354
1410
  # @return [String]
1355
1411
  attr_accessor :action_attempt_id
@@ -1381,10 +1437,14 @@ module Seam
1381
1437
 
1382
1438
  # Error associated with the action.
1383
1439
  # @return [Error, nil]
1440
+ # Only present when `status` is `error`; `nil` otherwise.
1384
1441
  resource_accessor :error, Error
1442
+ available_only_for_statuses :error, ["error"]
1385
1443
  # Result of the action.
1386
1444
  # @return [Result, nil]
1445
+ # Only present when `status` is `success`; `nil` otherwise.
1387
1446
  resource_accessor :result, Result
1447
+ available_only_for_statuses :result, ["success"]
1388
1448
  # ID of the action attempt.
1389
1449
  # @return [String]
1390
1450
  attr_accessor :action_attempt_id
@@ -1419,10 +1479,14 @@ module Seam
1419
1479
 
1420
1480
  # Error associated with the action.
1421
1481
  # @return [Error, nil]
1482
+ # Only present when `status` is `error`; `nil` otherwise.
1422
1483
  resource_accessor :error, Error
1484
+ available_only_for_statuses :error, ["error"]
1423
1485
  # Result of the action.
1424
1486
  # @return [Result, nil]
1487
+ # Only present when `status` is `success`; `nil` otherwise.
1425
1488
  resource_accessor :result, Result
1489
+ available_only_for_statuses :result, ["success"]
1426
1490
  # ID of the action attempt.
1427
1491
  # @return [String]
1428
1492
  attr_accessor :action_attempt_id
@@ -1454,10 +1518,14 @@ module Seam
1454
1518
 
1455
1519
  # Error associated with the action.
1456
1520
  # @return [Error, nil]
1521
+ # Only present when `status` is `error`; `nil` otherwise.
1457
1522
  resource_accessor :error, Error
1523
+ available_only_for_statuses :error, ["error"]
1458
1524
  # Result of the action.
1459
1525
  # @return [Result, nil]
1526
+ # Only present when `status` is `success`; `nil` otherwise.
1460
1527
  resource_accessor :result, Result
1528
+ available_only_for_statuses :result, ["success"]
1461
1529
  # ID of the action attempt.
1462
1530
  # @return [String]
1463
1531
  attr_accessor :action_attempt_id
@@ -1492,10 +1560,14 @@ module Seam
1492
1560
 
1493
1561
  # Error associated with the action.
1494
1562
  # @return [Error, nil]
1563
+ # Only present when `status` is `error`; `nil` otherwise.
1495
1564
  resource_accessor :error, Error
1565
+ available_only_for_statuses :error, ["error"]
1496
1566
  # Result of the action.
1497
1567
  # @return [Result, nil]
1568
+ # Only present when `status` is `success`; `nil` otherwise.
1498
1569
  resource_accessor :result, Result
1570
+ available_only_for_statuses :result, ["success"]
1499
1571
  # ID of the action attempt.
1500
1572
  # @return [String]
1501
1573
  attr_accessor :action_attempt_id
@@ -1530,10 +1602,14 @@ module Seam
1530
1602
 
1531
1603
  # Error associated with the action.
1532
1604
  # @return [Error, nil]
1605
+ # Only present when `status` is `error`; `nil` otherwise.
1533
1606
  resource_accessor :error, Error
1607
+ available_only_for_statuses :error, ["error"]
1534
1608
  # Result of the action.
1535
1609
  # @return [Result, nil]
1610
+ # Only present when `status` is `success`; `nil` otherwise.
1536
1611
  resource_accessor :result, Result
1612
+ available_only_for_statuses :result, ["success"]
1537
1613
  # ID of the action attempt.
1538
1614
  # @return [String]
1539
1615
  attr_accessor :action_attempt_id
@@ -1565,10 +1641,14 @@ module Seam
1565
1641
 
1566
1642
  # Error associated with the action.
1567
1643
  # @return [Error, nil]
1644
+ # Only present when `status` is `error`; `nil` otherwise.
1568
1645
  resource_accessor :error, Error
1646
+ available_only_for_statuses :error, ["error"]
1569
1647
  # Result of the action.
1570
1648
  # @return [Result, nil]
1649
+ # Only present when `status` is `success`; `nil` otherwise.
1571
1650
  resource_accessor :result, Result
1651
+ available_only_for_statuses :result, ["success"]
1572
1652
  # ID of the action attempt.
1573
1653
  # @return [String]
1574
1654
  attr_accessor :action_attempt_id
@@ -1603,10 +1683,14 @@ module Seam
1603
1683
 
1604
1684
  # Error associated with the action.
1605
1685
  # @return [Error, nil]
1686
+ # Only present when `status` is `error`; `nil` otherwise.
1606
1687
  resource_accessor :error, Error
1688
+ available_only_for_statuses :error, ["error"]
1607
1689
  # Result of the action.
1608
1690
  # @return [Result, nil]
1691
+ # Only present when `status` is `success`; `nil` otherwise.
1609
1692
  resource_accessor :result, Result
1693
+ available_only_for_statuses :result, ["success"]
1610
1694
  # ID of the action attempt.
1611
1695
  # @return [String]
1612
1696
  attr_accessor :action_attempt_id
@@ -1623,11 +1707,14 @@ module Seam
1623
1707
  attr_accessor :status
1624
1708
  end
1625
1709
 
1626
- # Error associated with the action.
1627
1710
  # @return [Error, nil]
1711
+ # Only present when `status` is `error`; `nil` otherwise.
1628
1712
  resource_accessor :error, Error
1713
+ available_only_for_statuses :error, ["error"]
1629
1714
  # @return [Result, nil]
1715
+ # Only present when `status` is `success`; `nil` otherwise.
1630
1716
  resource_accessor :result, Result
1717
+ available_only_for_statuses :result, ["success"]
1631
1718
  # ID of the action attempt.
1632
1719
  # @return [String]
1633
1720
  attr_accessor :action_attempt_id
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.149.0"
4
+ VERSION = "2.150.0"
5
5
  end
@@ -18,8 +18,10 @@ module Seam
18
18
  attr_reader :code
19
19
 
20
20
  def initialize(action_attempt)
21
- super(action_attempt.error.message, action_attempt)
22
- @code = action_attempt.error.type
21
+ error = action_attempt.error
22
+ message = (error && error["message"]) || "Action attempt failed"
23
+ super(message, action_attempt)
24
+ @code = error && error["type"]
23
25
  end
24
26
  end
25
27
 
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.149.0
4
+ version: 2.150.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Seam Labs, Inc.