v2.0.0
Migration guide
Learn how to migrate from the seamapi package to the seam package.
The new SDK has fewer dependencies and is generated daily to ensure methods and types are always up-to-date with the latest API changes. It is mostly a drop-in replacement, however some method signatures and options have changed to improve overall consistency with the Seam API.
This guide includes descriptions of all breaking changes. Please refer to the README for updated usage instructions and a complete list of new features.
New Ruby gem name
Changed the gem name from seamapi to seam.
- bundle add seamapi
+ bundle add seamSimplified main class initialization
The main class has been renamed from Seam::Client to Seam. You can now initialize it directly.
seam = Seam.new(api_key: "your-api-key")Specify your-api-key during initialization, or Seam automatically uses your exported SEAM_API_KEY.
Updated API method signatures
Keyword arguments
API method signatures now only accept keyword arguments.
- seam.access_codes.get("your-access-code-id")
+ seam.access_codes.get(access_code_id: "your-access-code-id")- seam.devices.get("your-device-id")
+ seam.devices.get(device_id: "your-device-id")Standardized resource ID arguments
Changed from accepting both resource objects and resource ID strings to accepting only resource ID strings. Includes a renaming scheme for clarity.
- def unlock_door(device_or_id)
+ def unlock_door(device_id:)Usage
- seam.devices.get(device: your_device)
+ seam.devices.get(device_id: your_device.device_id)Removed methods
wait_until_finished
Removed wait_until_finished from the ActionAttempt resource. To resolve an action attempt returned by the method, use the wait_for_action_attempt method argument instead.
- seam.locks.unlock_door(device_id: "your-device-id").wait_until_finished
+ seam.locks.unlock_door(device_id: "your-device-id", wait_for_action_attempt: true)seam.health
Removed the seam.health method for checking client health. In the future, we plan to add a health check mechanism that is consistent across all the Seam SDKs.
Removed constructor argument
Removed the debug argument from the Seam class constructor.
Renamed constructor argument
Renamed the base_uri argument to endpoint for overriding the default API endpoint.
Deprecated methods
seam.unmanaged_access_codes
seam.unmanaged_access_codes is now deprecated. Use seam.access_codes.unmanaged instead.
- seam.unmanaged_access_codes.get(access_code_id: "your-access-code-id")
+ seam.access_codes.unmanaged.get(access_code_id: "your-access-code-id")seam.unmanaged_devices
seam.unmanaged_devices is now deprecated. Use seam.devices.unmanaged instead.
- seam.unmanaged_devices.get(device_id: "your-device-id")
+ seam.devices.unmanaged.get(device_id: "your-device-id")Return value changes
Changed the return values for some methods to enhance API consistency and reliability.
The following methods now return nil:
access_codes.delete: Instead, you should wait for theaccess_code.deletedevent.access_codes.update: Instead, you should watch for relevantaccess_code.*events or poll the resource as needed.access_codes.unmanaged.deleteaccess_codes.unmanaged.convert_to_managed: Instead, you should wait for theaccess_code.unmanaged.converted_to_managedandaccess_code.unmanaged.failed_to_convert_to_managedevents.
The following methods now return an ActionAttempt:
workspaces.reset_sandbox: Instead, you should use the newly-createdaction_attempt_idto poll the status of the action attempt usingseam.action_attempts.get.
Action attempt resolution
Now, all methods returning action attempts wait for the action attempt to resolve by default. Further, you can configure this behavior using the wait_for_action_attempt option on a per-request basis. You can also set the default behavior for the client.
Set per request
# Wait for the action attempt to be ready with a default timeout of 5.0 seconds and a default polling interval of 0.5 seconds.
seam.locks.lock_door(
device_id: "your-device-id",
wait_for_action_attempt: false
)
# Wait up to 10 seconds for the action attempt to be ready, checking every 2 seconds.
seam.locks.lock_door(
device_id: "your-device-id",
wait_for_action_attempt: {
timeout: 10.0, # Up to 10 seconds
polling_interval: 2.0 # Every 2 seconds
}
)Set default behavior
seam = Seam.new(wait_for_action_attempt: false)Resource attribute references
Now, use dot notation instead of square brackets to refer to resource attributes.
- front_door.properties['online']
+ front_door.properties.onlineEnvironment variables
The SEAM_API_URL environment variable is now deprecated. Use SEAM_ENDPOINT instead.
Version changes
Updated the minimum supported Ruby version to 3.1.0.
Highlighted new features
API key authentication with from_api_key factory method
Added a new from_api_key factory method for API key authentication of the Seam client.
seam = Seam.from_api_key("your-api-key")PAT authentication scoped to a single workspace
Added support for workspace personal access token (PAT) authentication.
# Pass as an option to the constructor.
seam = Seam.new(
personal_access_token: "your-personal-access-token",
workspace_id: "your-workspace-id",
)
# Use the factory method
seam = Seam.from_personal_access_token(
"your-personal-access-token",
"your-workspace-id",
)PAT authentication not bound to a specific workspace
For authentication with a personal access token not bound to a specific workspace, use Seam::Http::SeamMultiWorkspace.
# Pass as an option to the constructor.
seam_multi_workspace = Seam::Http::SeamMultiWorkspace.new(personal_access_token: "your-personal-access-token")
# Use the factory method.
seam_multi_workspace = Seam::Http::SeamMultiWorkspace.from_personal_access_token(
"your-personal-access-token"
)
workspace = seam_multi_workspace.workspaces.create(company_name: "Example Inc.")Webhook handler
The Ruby SDK exports a thin wrapper Seam::Webhook around the svix package. Use it to parse and validate Seam webhook events.
New configurable Faraday HTTP client with retry options
The Ruby SDK now uses the Faraday HTTP client under the hood, which you can configure using faraday_options and faraday_retry_options.
seam = Seam.new(
api_key: "your-api-key",
faraday_options: {
headers: {
"Custom-Header": "Custom-Value"
}
},
faraday_retry_options: {
max: 3,
backoff_factor: 2
}
)The Faraday client is also exposed through the seam.client property and can be used or configured directly.
require "seam"
require "faraday"
class MyMiddleware < Faraday::Middleware
def on_complete(env)
puts env.response.inspect
end
end
seam = Seam.new
seam.client.builder.use MyMiddleware
devices = seam.client.get("/devices/list").body["devices"]