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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: '06196d87a7db7cb6f396e2ce2f94f02d9dfb2c2eecff52fa314df6d95856ff57'
4
- data.tar.gz: f7be00a016e5c13fc8e937595b80302453ae8625d27df6a0541d1eacf5b3504e
3
+ metadata.gz: 20eb2c8e0938d5dcb96d337254d2eaba3c77d9c1fe672292c09af488638aa3b3
4
+ data.tar.gz: 24d8ca1c9ce0dd9f901fc19fcb48990885e9301a9feb0fa26fd890cd0fdc55e6
5
5
  SHA512:
6
- metadata.gz: 68f7a956b71ae32046af99e15b612d1fa1ac4a689539dadf795776bdd873ea5bd4ed7ace6105f17678c760184567a02bd5b6d472d0c536ab19eba4fa3e45f655
7
- data.tar.gz: 66906c6e6172416dc861bb7dc71b6e51a49baba23331b4ddc5d0ef1fa6f677fa13841bd913a6c2537cfbc00eaf74e9700f14cef44907efbff213960836ac5b75
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.148.0)
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.148.0)
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
- @validation_errors = error["validation_errors"] || {}
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
- @validation_errors.dig(param_name, "_errors") || []
56
+ @raw_validation_errors.dig(param_name, "_errors") || []
50
57
  end
51
58
  end
52
59
  end
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.148.0"
4
+ VERSION = "2.149.0"
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.148.0
4
+ version: 2.149.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Seam Labs, Inc.