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 39 40 41 42 |
# File 'lib/seam/routes/access_methods.rb', line 34 def delete(access_method_id: nil, access_grant_id: nil, reservation_key: nil) if access_method_id.nil? && access_grant_id.nil? && reservation_key.nil? raise TypeError, "At least one parameter is required for /access_methods/delete" end @client.delete("/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.
48 49 50 51 52 53 54 |
# File 'lib/seam/routes/access_methods.rb', line 48 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.
59 60 61 62 63 |
# File 'lib/seam/routes/access_methods.rb', line 59 def get(access_method_id:) res = @client.get("/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.
70 71 72 73 74 |
# File 'lib/seam/routes/access_methods.rb', line 70 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.
86 87 88 89 90 91 92 93 94 |
# File 'lib/seam/routes/access_methods.rb', line 86 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) if 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? raise TypeError, "At least one parameter is required for /access_methods/list" end res = @client.get("/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.
100 101 102 103 104 105 106 |
# File 'lib/seam/routes/access_methods.rb', line 100 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 |