Class: Seam::Clients::AccessMethods
- Inherits:
-
Object
- Object
- Seam::Clients::AccessMethods
- Defined in:
- lib/seam/routes/access_methods.rb
Instance Method Summary collapse
-
#assign_card(access_method_id:, card_number:, wait_for_action_attempt: nil) ⇒ Seam::Resources::ActionAttempt
Assigns a pre-registered card credential, identified by
card_number, to a card-mode access method. -
#delete(access_method_id: nil, access_grant_id: nil, reservation_key: nil) ⇒ nil
Deletes an access method.
-
#encode(access_method_id:, acs_encoder_id:, wait_for_action_attempt: nil) ⇒ Seam::Resources::ActionAttempt
Encodes an existing access method onto a plastic card placed on the specified encoder.
-
#get(access_method_id:) ⇒ Seam::Resources::AccessMethod
Gets an access method.
-
#get_related(access_method_ids:, exclude: nil, include: nil) ⇒ Seam::Resources::Batch
Gets all related resources for one or more Access Methods.
-
#initialize(client:, defaults:) ⇒ AccessMethods
constructor
A new instance of AccessMethods.
-
#list(access_code_id: nil, access_grant_id: nil, access_grant_key: nil, acs_entrance_id: nil, device_id: nil, limit: nil, page_cursor: nil, space_id: nil) ⇒ Seam::Resources::AccessMethod
Lists all access methods, usually filtered by Access Grant.
-
#unlock_door(access_method_id:, acs_entrance_id:, wait_for_action_attempt: nil) ⇒ Seam::Resources::ActionAttempt
Remotely unlocks a specified entrance using the cloud key credential associated with an access method.
- #unmanaged ⇒ Object
Constructor Details
#initialize(client:, defaults:) ⇒ AccessMethods
Returns a new instance of AccessMethods.
8 9 10 11 |
# File 'lib/seam/routes/access_methods.rb', line 8 def initialize(client:, defaults:) @client = client @defaults = defaults end |
Instance Method Details
#assign_card(access_method_id:, card_number:, wait_for_action_attempt: nil) ⇒ Seam::Resources::ActionAttempt
Assigns a pre-registered card credential, identified by card_number, to a card-mode access method. Use this endpoint for access systems that use pre-registered cards, where a physical card must be associated with an access method before it can be used for access. Assigning a card credential also triggers issuance of the access method.
21 22 23 24 25 26 27 |
# File 'lib/seam/routes/access_methods.rb', line 21 def assign_card(access_method_id:, card_number:, wait_for_action_attempt: nil) res = @client.post("/access_methods/assign_card", {access_method_id: access_method_id, card_number: card_number}.compact) wait_for_action_attempt = wait_for_action_attempt.nil? ? @defaults.wait_for_action_attempt : wait_for_action_attempt Helpers::ActionAttempt.decide_and_wait(Seam::Resources::ActionAttempt.load_from_response(res.body["action_attempt"]), @client, wait_for_action_attempt) end |
#delete(access_method_id: nil, access_grant_id: nil, reservation_key: nil) ⇒ nil
Deletes an access method.
34 35 36 37 38 |
# File 'lib/seam/routes/access_methods.rb', line 34 def delete(access_method_id: nil, access_grant_id: nil, reservation_key: nil) @client.post("/access_methods/delete", {access_method_id: access_method_id, access_grant_id: access_grant_id, reservation_key: reservation_key}.compact) nil end |
#encode(access_method_id:, acs_encoder_id:, wait_for_action_attempt: nil) ⇒ Seam::Resources::ActionAttempt
Encodes an existing access method onto a plastic card placed on the specified encoder.
44 45 46 47 48 49 50 |
# File 'lib/seam/routes/access_methods.rb', line 44 def encode(access_method_id:, acs_encoder_id:, wait_for_action_attempt: nil) res = @client.post("/access_methods/encode", {access_method_id: access_method_id, acs_encoder_id: acs_encoder_id}.compact) wait_for_action_attempt = wait_for_action_attempt.nil? ? @defaults.wait_for_action_attempt : wait_for_action_attempt Helpers::ActionAttempt.decide_and_wait(Seam::Resources::ActionAttempt.load_from_response(res.body["action_attempt"]), @client, wait_for_action_attempt) end |
#get(access_method_id:) ⇒ Seam::Resources::AccessMethod
Gets an access method.
55 56 57 58 59 |
# File 'lib/seam/routes/access_methods.rb', line 55 def get(access_method_id:) res = @client.post("/access_methods/get", {access_method_id: access_method_id}.compact) Seam::Resources::AccessMethod.load_from_response(res.body["access_method"]) end |
#get_related(access_method_ids:, exclude: nil, include: nil) ⇒ Seam::Resources::Batch
Gets all related resources for one or more Access Methods.
66 67 68 69 70 |
# File 'lib/seam/routes/access_methods.rb', line 66 def (access_method_ids:, exclude: nil, include: nil) res = @client.post("/access_methods/get_related", {access_method_ids: access_method_ids, exclude: exclude, include: include}.compact) Seam::Resources::Batch.load_from_response(res.body["batch"]) end |
#list(access_code_id: nil, access_grant_id: nil, access_grant_key: nil, acs_entrance_id: nil, device_id: nil, limit: nil, page_cursor: nil, space_id: nil) ⇒ Seam::Resources::AccessMethod
Lists all access methods, usually filtered by Access Grant.
82 83 84 85 86 |
# File 'lib/seam/routes/access_methods.rb', line 82 def list(access_code_id: nil, access_grant_id: nil, access_grant_key: nil, acs_entrance_id: nil, device_id: nil, limit: nil, page_cursor: nil, space_id: nil) res = @client.post("/access_methods/list", {access_code_id: access_code_id, access_grant_id: access_grant_id, access_grant_key: access_grant_key, acs_entrance_id: acs_entrance_id, device_id: device_id, limit: limit, page_cursor: page_cursor, space_id: space_id}.compact) Seam::Resources::AccessMethod.load_from_response(res.body["access_methods"]) end |
#unlock_door(access_method_id:, acs_entrance_id:, wait_for_action_attempt: nil) ⇒ Seam::Resources::ActionAttempt
Remotely unlocks a specified entrance using the cloud key credential associated with an access method. Returns an action attempt that tracks the progress of the unlock operation.
92 93 94 95 96 97 98 |
# File 'lib/seam/routes/access_methods.rb', line 92 def unlock_door(access_method_id:, acs_entrance_id:, wait_for_action_attempt: nil) res = @client.post("/access_methods/unlock_door", {access_method_id: access_method_id, acs_entrance_id: acs_entrance_id}.compact) wait_for_action_attempt = wait_for_action_attempt.nil? ? @defaults.wait_for_action_attempt : wait_for_action_attempt Helpers::ActionAttempt.decide_and_wait(Seam::Resources::ActionAttempt.load_from_response(res.body["action_attempt"]), @client, wait_for_action_attempt) end |
#unmanaged ⇒ Object
13 14 15 |
# File 'lib/seam/routes/access_methods.rb', line 13 def unmanaged @unmanaged ||= Seam::Clients::AccessMethodsUnmanaged.new(client: @client, defaults: @defaults) end |