Class: Seam::Clients::AccessCodes
- Inherits:
-
Object
- Object
- Seam::Clients::AccessCodes
- Defined in:
- lib/seam/routes/access_codes.rb
Instance Method Summary collapse
-
#create(device_id:, allow_external_modification: nil, attempt_for_offline_device: nil, code: nil, common_code_key: nil, ends_at: nil, is_external_modification_allowed: nil, is_offline_access_code: nil, is_one_time_use: nil, max_time_rounding: nil, name: nil, prefer_native_scheduling: nil, preferred_code_length: nil, starts_at: nil, use_backup_access_code_pool: nil, use_offline_access_code: nil) ⇒ Seam::Resources::AccessCode
deprecated
Deprecated.
use_offline_access_code: Use
is_offline_access_codeinstead. -
#create_multiple(device_ids:, allow_external_modification: nil, attempt_for_offline_device: nil, behavior_when_code_cannot_be_shared: nil, code: nil, ends_at: nil, is_external_modification_allowed: nil, name: nil, prefer_native_scheduling: nil, preferred_code_length: nil, starts_at: nil, use_backup_access_code_pool: nil) ⇒ Seam::Resources::AccessCode
Creates new access codes that share a common code across multiple devices.
-
#delete(access_code_id:, device_id: nil) ⇒ nil
Deletes an access code.
-
#generate_code(device_id:) ⇒ Seam::Resources::AccessCode
Generates a code for an access code, given a device ID.
-
#get(access_code_id: nil, code: nil, device_id: nil) ⇒ Seam::Resources::AccessCode
Returns a specified access code.
-
#initialize(client:, defaults:) ⇒ AccessCodes
constructor
A new instance of AccessCodes.
-
#list(access_code_ids: nil, access_grant_id: nil, access_grant_key: nil, access_method_id: nil, customer_key: nil, device_id: nil, limit: nil, page_cursor: nil, search: nil, user_identifier_key: nil) ⇒ Seam::Resources::AccessCode
Returns a list of all access codes.
-
#pull_backup_access_code(access_code_id:) ⇒ Seam::Resources::AccessCode
Retrieves a backup access code for an access code.
-
#report_device_constraints(device_id:, max_code_length: nil, min_code_length: nil, supported_code_lengths: nil) ⇒ nil
Enables you to report access code-related constraints for a device.
- #simulate ⇒ Object
- #unmanaged ⇒ Object
-
#update(access_code_id:, allow_external_modification: nil, attempt_for_offline_device: nil, code: nil, device_id: nil, ends_at: nil, is_external_modification_allowed: nil, is_managed: nil, is_offline_access_code: nil, is_one_time_use: nil, max_time_rounding: nil, name: nil, prefer_native_scheduling: nil, preferred_code_length: nil, starts_at: nil, type: nil, use_backup_access_code_pool: nil, use_offline_access_code: nil) ⇒ nil
deprecated
Deprecated.
use_offline_access_code: Use
is_offline_access_codeinstead. -
#update_multiple(common_code_key:, ends_at: nil, name: nil, starts_at: nil) ⇒ nil
Updates access codes that share a common code across multiple devices.
Constructor Details
#initialize(client:, defaults:) ⇒ AccessCodes
Returns a new instance of AccessCodes.
6 7 8 9 |
# File 'lib/seam/routes/access_codes.rb', line 6 def initialize(client:, defaults:) @client = client @defaults = defaults end |
Instance Method Details
#create(device_id:, allow_external_modification: nil, attempt_for_offline_device: nil, code: nil, common_code_key: nil, ends_at: nil, is_external_modification_allowed: nil, is_offline_access_code: nil, is_one_time_use: nil, max_time_rounding: nil, name: nil, prefer_native_scheduling: nil, preferred_code_length: nil, starts_at: nil, use_backup_access_code_pool: nil, use_offline_access_code: nil) ⇒ Seam::Resources::AccessCode
use_offline_access_code: Use is_offline_access_code instead.
Creates a new access code. For granting access, we recommend Access Grants instead: they work across both standalone smart locks and access control systems and manage the underlying codes for you. Use this low-level endpoint only when you need direct control over a code on a single device, such as setting a custom PIN value.
Note that the name provided on Seam is used to identify the code on Seam and is not necessarily the name that will appear in the lock provider's app or on the device. This is because lock providers may have constraints on names, such as length, uniqueness, or characters that can be used. In addition, some lock providers may break down names into components such as first_name and last_name.
To provide a consistent experience, Seam identifies the code on Seam by its name but may modify the name that appears on the lock provider's app or on the device. For example, Seam may add additional characters or truncate the name to meet provider constraints.
To help your users identify codes set by Seam, Seam provides the name exactly as it appears on the lock provider's app or on the device as a separate property called appearance. This is an object with a name property and, optionally, first_name and last_name properties (for providers that break down a name into components).
44 45 46 47 48 |
# File 'lib/seam/routes/access_codes.rb', line 44 def create(device_id:, allow_external_modification: nil, attempt_for_offline_device: nil, code: nil, common_code_key: nil, ends_at: nil, is_external_modification_allowed: nil, is_offline_access_code: nil, is_one_time_use: nil, max_time_rounding: nil, name: nil, prefer_native_scheduling: nil, preferred_code_length: nil, starts_at: nil, use_backup_access_code_pool: nil, use_offline_access_code: nil) res = @client.post("/access_codes/create", {device_id: device_id, allow_external_modification: allow_external_modification, attempt_for_offline_device: attempt_for_offline_device, code: code, common_code_key: common_code_key, ends_at: ends_at, is_external_modification_allowed: is_external_modification_allowed, is_offline_access_code: is_offline_access_code, is_one_time_use: is_one_time_use, max_time_rounding: max_time_rounding, name: name, prefer_native_scheduling: prefer_native_scheduling, preferred_code_length: preferred_code_length, starts_at: starts_at, use_backup_access_code_pool: use_backup_access_code_pool, use_offline_access_code: use_offline_access_code}.compact) Seam::Resources::AccessCode.load_from_response(res.body["access_code"]) end |
#create_multiple(device_ids:, allow_external_modification: nil, attempt_for_offline_device: nil, behavior_when_code_cannot_be_shared: nil, code: nil, ends_at: nil, is_external_modification_allowed: nil, name: nil, prefer_native_scheduling: nil, preferred_code_length: nil, starts_at: nil, use_backup_access_code_pool: nil) ⇒ Seam::Resources::AccessCode
Creates new access codes that share a common code across multiple devices.
Users with more than one door lock in a property may want to create groups of linked access codes, all of which have the same code (PIN). For example, a short-term rental host may want to provide guests the same PIN for both a front door lock and a back door lock.
If you specify a custom code, Seam assigns this custom code to each of the resulting access codes. However, in this case, Seam does not link these access codes together with a common_code_key. That is, common_code_key remains null for these access codes.
If you want to change these access codes that are not linked by a common_code_key, you cannot use /access_codes/update_multiple. However, you can update each of these access codes individually, using /access_codes/update.
See also Creating and Updating Multiple Linked Access Codes.
For granting a person access to a space, Access Grants are the default and recommended approach and work across both standalone smart locks and access systems. Use the lower-level Access Codes API directly only when you specifically need to manage individual PIN codes.
Note that the name provided on Seam is used to identify the code on Seam and is not necessarily the name that will appear in the lock provider's app or on the device. This is because lock providers may have constraints on names, such as length, uniqueness, or characters that can be used. In addition, some lock providers may break down names into components such as first_name and last_name.
To provide a consistent experience, Seam identifies the code on Seam by its name but may modify the name that appears on the lock provider's app or on the device. For example, Seam may add additional characters or truncate the name to meet provider constraints.
To help your users identify codes set by Seam, Seam provides the name exactly as it appears on the lock provider's app or on the device as a separate property called appearance. This is an object with a name property and, optionally, first_name and last_name properties (for providers that break down a name into components).
80 81 82 83 84 |
# File 'lib/seam/routes/access_codes.rb', line 80 def create_multiple(device_ids:, allow_external_modification: nil, attempt_for_offline_device: nil, behavior_when_code_cannot_be_shared: nil, code: nil, ends_at: nil, is_external_modification_allowed: nil, name: nil, prefer_native_scheduling: nil, preferred_code_length: nil, starts_at: nil, use_backup_access_code_pool: nil) res = @client.post("/access_codes/create_multiple", {device_ids: device_ids, allow_external_modification: allow_external_modification, attempt_for_offline_device: attempt_for_offline_device, behavior_when_code_cannot_be_shared: behavior_when_code_cannot_be_shared, code: code, ends_at: ends_at, is_external_modification_allowed: is_external_modification_allowed, name: name, prefer_native_scheduling: prefer_native_scheduling, preferred_code_length: preferred_code_length, starts_at: starts_at, use_backup_access_code_pool: use_backup_access_code_pool}.compact) Seam::Resources::AccessCode.load_from_response(res.body["access_codes"]) end |
#delete(access_code_id:, device_id: nil) ⇒ nil
Deletes an access code.
90 91 92 93 94 |
# File 'lib/seam/routes/access_codes.rb', line 90 def delete(access_code_id:, device_id: nil) @client.post("/access_codes/delete", {access_code_id: access_code_id, device_id: device_id}.compact) nil end |
#generate_code(device_id:) ⇒ Seam::Resources::AccessCode
Generates a code for an access code, given a device ID.
99 100 101 102 103 |
# File 'lib/seam/routes/access_codes.rb', line 99 def generate_code(device_id:) res = @client.post("/access_codes/generate_code", {device_id: device_id}.compact) Seam::Resources::AccessCode.load_from_response(res.body["generated_code"]) end |
#get(access_code_id: nil, code: nil, device_id: nil) ⇒ Seam::Resources::AccessCode
Returns a specified access code.
You must specify either access_code_id or both device_id and code.
112 113 114 115 116 |
# File 'lib/seam/routes/access_codes.rb', line 112 def get(access_code_id: nil, code: nil, device_id: nil) res = @client.post("/access_codes/get", {access_code_id: access_code_id, code: code, device_id: device_id}.compact) Seam::Resources::AccessCode.load_from_response(res.body["access_code"]) end |
#list(access_code_ids: nil, access_grant_id: nil, access_grant_key: nil, access_method_id: nil, customer_key: nil, device_id: nil, limit: nil, page_cursor: nil, search: nil, user_identifier_key: nil) ⇒ Seam::Resources::AccessCode
Returns a list of all access codes.
Specify device_id, access_code_ids, access_method_id, access_grant_id, or access_grant_key.
132 133 134 135 136 |
# File 'lib/seam/routes/access_codes.rb', line 132 def list(access_code_ids: nil, access_grant_id: nil, access_grant_key: nil, access_method_id: nil, customer_key: nil, device_id: nil, limit: nil, page_cursor: nil, search: nil, user_identifier_key: nil) res = @client.post("/access_codes/list", {access_code_ids: access_code_ids, access_grant_id: access_grant_id, access_grant_key: access_grant_key, access_method_id: access_method_id, customer_key: customer_key, device_id: device_id, limit: limit, page_cursor: page_cursor, search: search, user_identifier_key: user_identifier_key}.compact) Seam::Resources::AccessCode.load_from_response(res.body["access_codes"]) end |
#pull_backup_access_code(access_code_id:) ⇒ Seam::Resources::AccessCode
Retrieves a backup access code for an access code. See also Managing Backup Access Codes.
A backup access code pool is a collection of pre-programmed access codes stored on a device, ready for use. These codes are programmed in addition to the regular access codes on Seam, serving as a safety net for any issues with the primary codes. If there's ever a complication with a primary access code—be it due to intermittent connectivity, manual removal from a device, or provider outages—a backup code can be retrieved. Its end time can then be adjusted to align with the original code, facilitating seamless and uninterrupted access.
You can pull a backup access code from the pool at any time. These backup codes are guaranteed to work immediately and automatically programmed to be removed from the device after the access code ends.
You can only pull backup access codes for time-bound access codes.
Before pulling a backup access code, make sure that the device's properties.supports_backup_access_code_pool is true. Then, to activate the backup pool, set use_backup_access_code_pool to true when creating an access code.
149 150 151 152 153 |
# File 'lib/seam/routes/access_codes.rb', line 149 def pull_backup_access_code(access_code_id:) res = @client.post("/access_codes/pull_backup_access_code", {access_code_id: access_code_id}.compact) Seam::Resources::AccessCode.load_from_response(res.body["access_code"]) end |
#report_device_constraints(device_id:, max_code_length: nil, min_code_length: nil, supported_code_lengths: nil) ⇒ nil
Enables you to report access code-related constraints for a device. Currently, supports reporting supported code length constraints for SmartThings devices.
Specify either supported_code_lengths or min_code_length/max_code_length.
163 164 165 166 167 |
# File 'lib/seam/routes/access_codes.rb', line 163 def report_device_constraints(device_id:, max_code_length: nil, min_code_length: nil, supported_code_lengths: nil) @client.post("/access_codes/report_device_constraints", {device_id: device_id, max_code_length: max_code_length, min_code_length: min_code_length, supported_code_lengths: supported_code_lengths}.compact) nil end |
#simulate ⇒ Object
11 12 13 |
# File 'lib/seam/routes/access_codes.rb', line 11 def simulate @simulate ||= Seam::Clients::AccessCodesSimulate.new(client: @client, defaults: @defaults) end |
#unmanaged ⇒ Object
15 16 17 |
# File 'lib/seam/routes/access_codes.rb', line 15 def unmanaged @unmanaged ||= Seam::Clients::AccessCodesUnmanaged.new(client: @client, defaults: @defaults) end |
#update(access_code_id:, allow_external_modification: nil, attempt_for_offline_device: nil, code: nil, device_id: nil, ends_at: nil, is_external_modification_allowed: nil, is_managed: nil, is_offline_access_code: nil, is_one_time_use: nil, max_time_rounding: nil, name: nil, prefer_native_scheduling: nil, preferred_code_length: nil, starts_at: nil, type: nil, use_backup_access_code_pool: nil, use_offline_access_code: nil) ⇒ nil
use_offline_access_code: Use is_offline_access_code instead.
Updates a specified active or upcoming access code.
See also Modifying Access Codes.
Note that the name provided on Seam is used to identify the code on Seam and is not necessarily the name that will appear in the lock provider's app or on the device. This is because lock providers may have constraints on names, such as length, uniqueness, or characters that can be used. In addition, some lock providers may break down names into components such as first_name and last_name.
To provide a consistent experience, Seam identifies the code on Seam by its name but may modify the name that appears on the lock provider's app or on the device. For example, Seam may add additional characters or truncate the name to meet provider constraints.
To help your users identify codes set by Seam, Seam provides the name exactly as it appears on the lock provider's app or on the device as a separate property called appearance. This is an object with a name property and, optionally, first_name and last_name properties (for providers that break down a name into components).
198 199 200 201 202 |
# File 'lib/seam/routes/access_codes.rb', line 198 def update(access_code_id:, allow_external_modification: nil, attempt_for_offline_device: nil, code: nil, device_id: nil, ends_at: nil, is_external_modification_allowed: nil, is_managed: nil, is_offline_access_code: nil, is_one_time_use: nil, max_time_rounding: nil, name: nil, prefer_native_scheduling: nil, preferred_code_length: nil, starts_at: nil, type: nil, use_backup_access_code_pool: nil, use_offline_access_code: nil) @client.post("/access_codes/update", {access_code_id: access_code_id, allow_external_modification: allow_external_modification, attempt_for_offline_device: attempt_for_offline_device, code: code, device_id: device_id, ends_at: ends_at, is_external_modification_allowed: is_external_modification_allowed, is_managed: is_managed, is_offline_access_code: is_offline_access_code, is_one_time_use: is_one_time_use, max_time_rounding: max_time_rounding, name: name, prefer_native_scheduling: prefer_native_scheduling, preferred_code_length: preferred_code_length, starts_at: starts_at, type: type, use_backup_access_code_pool: use_backup_access_code_pool, use_offline_access_code: use_offline_access_code}.compact) nil end |
#update_multiple(common_code_key:, ends_at: nil, name: nil, starts_at: nil) ⇒ nil
Updates access codes that share a common code across multiple devices.
Specify the common_code_key to identify the set of access codes that you want to update.
See also Update Linked Access Codes.
Note that the name provided on Seam is used to identify the code on Seam and is not necessarily the name that will appear in the lock provider's app or on the device. This is because lock providers may have constraints on names, such as length, uniqueness, or characters that can be used. In addition, some lock providers may break down names into components such as first_name and last_name.
To provide a consistent experience, Seam identifies the code on Seam by its name but may modify the name that appears on the lock provider's app or on the device. For example, Seam may add additional characters or truncate the name to meet provider constraints.
To help your users identify codes set by Seam, Seam provides the name exactly as it appears on the lock provider's app or on the device as a separate property called appearance. This is an object with a name property and, optionally, first_name and last_name properties (for providers that break down a name into components).
220 221 222 223 224 |
# File 'lib/seam/routes/access_codes.rb', line 220 def update_multiple(common_code_key:, ends_at: nil, name: nil, starts_at: nil) @client.post("/access_codes/update_multiple", {common_code_key: common_code_key, ends_at: ends_at, name: name, starts_at: starts_at}.compact) nil end |