seam 2.148.0 → 2.149.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 +4 -4
- data/Gemfile.lock +2 -2
- data/README.md +29 -0
- data/lib/seam/http.rb +9 -2
- data/lib/seam/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 20eb2c8e0938d5dcb96d337254d2eaba3c77d9c1fe672292c09af488638aa3b3
|
|
4
|
+
data.tar.gz: 24d8ca1c9ce0dd9f901fc19fcb48990885e9301a9feb0fa26fd890cd0fdc55e6
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 054cbd509a8a694e7b3c56a068f10256b0563a3327d9d4032236a996cd7c9d2af2d761e65573f2a17e0fd9f475bb9eb4a388e3cb6b6f147b6d3fa41548589f32
|
|
7
|
+
data.tar.gz: 0cbe6605e8b2c9e913a97ad1810d837ee84c3480da6e713107bf031ba0100c6be31633941a2930f422fd11dec915633699b484f7bf14ef00bf89e3d25fca6492
|
data/Gemfile.lock
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
PATH
|
|
2
2
|
remote: .
|
|
3
3
|
specs:
|
|
4
|
-
seam (2.
|
|
4
|
+
seam (2.149.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.
|
|
174
|
+
seam (2.149.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
|
@@ -35,6 +35,8 @@ constraints.
|
|
|
35
35
|
- [Resume pagination](#resume-pagination)
|
|
36
36
|
- [Iterate over all resources](#iterate-over-all-resources)
|
|
37
37
|
- [Return all resources across all pages as a list](#return-all-resources-across-all-pages-as-a-list)
|
|
38
|
+
- [Error Handling](#error-handling)
|
|
39
|
+
- [Validation errors](#validation-errors)
|
|
38
40
|
- [Requests without a Workspace in scope](#requests-without-a-workspace-in-scope)
|
|
39
41
|
- [Personal Access Token](#personal-access-token-1)
|
|
40
42
|
- [Webhooks](#webhooks)
|
|
@@ -352,6 +354,33 @@ paginator = seam.create_paginator(seam.devices.method(:list), {limit: 20})
|
|
|
352
354
|
all_devices = paginator.flatten_to_list
|
|
353
355
|
```
|
|
354
356
|
|
|
357
|
+
### Error Handling
|
|
358
|
+
|
|
359
|
+
Requests rejected by the Seam API raise a `Seam::Http::ApiError` subclass
|
|
360
|
+
carrying the HTTP `status_code`, API error `code`, and `request_id`.
|
|
361
|
+
|
|
362
|
+
#### Validation errors
|
|
363
|
+
|
|
364
|
+
When the API rejects a request because a parameter is invalid, it raises a
|
|
365
|
+
`Seam::Http::InvalidInputError`. Look up messages for a parameter you are
|
|
366
|
+
already rendering, for example a field in a form:
|
|
367
|
+
|
|
368
|
+
```ruby
|
|
369
|
+
begin
|
|
370
|
+
seam.devices.list(device_ids: ["not-a-uuid"])
|
|
371
|
+
rescue Seam::Http::InvalidInputError => error
|
|
372
|
+
puts error.get_validation_error_messages("device_ids")
|
|
373
|
+
end
|
|
374
|
+
```
|
|
375
|
+
|
|
376
|
+
Or read every parameter that failed validation to summarize the request:
|
|
377
|
+
|
|
378
|
+
```ruby
|
|
379
|
+
error.validation_errors.each do |validation_error|
|
|
380
|
+
puts "#{validation_error.parameter_name}: #{validation_error.error_messages.join(", ")}"
|
|
381
|
+
end
|
|
382
|
+
```
|
|
383
|
+
|
|
355
384
|
### Requests without a Workspace in scope
|
|
356
385
|
|
|
357
386
|
Some Seam API endpoints do not require a workspace in scope.
|
data/lib/seam/http.rb
CHANGED
|
@@ -36,17 +36,24 @@ module Seam
|
|
|
36
36
|
end
|
|
37
37
|
end
|
|
38
38
|
|
|
39
|
+
ValidationError = Data.define(:parameter_name, :error_messages)
|
|
40
|
+
|
|
39
41
|
class InvalidInputError < ApiError
|
|
40
42
|
attr_reader :validation_errors
|
|
41
43
|
|
|
42
44
|
def initialize(error, status_code, request_id)
|
|
43
45
|
super
|
|
44
46
|
@code = "invalid_input"
|
|
45
|
-
@
|
|
47
|
+
@raw_validation_errors = error["validation_errors"] || {}
|
|
48
|
+
@validation_errors = @raw_validation_errors.filter_map do |parameter_name, _|
|
|
49
|
+
next if parameter_name == "_errors"
|
|
50
|
+
|
|
51
|
+
ValidationError.new(parameter_name:, error_messages: get_validation_error_messages(parameter_name))
|
|
52
|
+
end
|
|
46
53
|
end
|
|
47
54
|
|
|
48
55
|
def get_validation_error_messages(param_name)
|
|
49
|
-
@
|
|
56
|
+
@raw_validation_errors.dig(param_name, "_errors") || []
|
|
50
57
|
end
|
|
51
58
|
end
|
|
52
59
|
end
|
data/lib/seam/version.rb
CHANGED