Class: Seam::Clients::AccessMethods

Inherits:
Object
  • Object
show all
Defined in:
lib/seam/routes/access_methods.rb

Instance Method Summary collapse

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.

Parameters:

  • access_method_id

    ID of the access_method to assign the credential to.

  • card_number

    Card number of the credential to assign.

Returns:



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.

Parameters:

  • access_method_id (defaults to: nil)

    ID of access method to delete.

  • access_grant_id (defaults to: nil)

    ID of access grant whose access methods should be deleted.

  • reservation_key (defaults to: nil)

    Reservation key of the access grant whose access methods should be deleted.

Returns:

  • (nil)

    OK



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.

Parameters:

  • access_method_id

    ID of the access_method to encode onto a card.

  • acs_encoder_id

    ID of the acs_encoder to use to encode the access_method.

Returns:



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.

Parameters:

  • access_method_id

    ID of access method to get.

Returns:



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

Gets all related resources for one or more Access Methods.

Parameters:

  • access_method_ids

    IDs of the access methods that you want to get along with their related resources.

  • exclude (defaults to: nil)
  • include (defaults to: nil)

Returns:



66
67
68
69
70
# File 'lib/seam/routes/access_methods.rb', line 66

def get_related(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.

Parameters:

  • access_code_id (defaults to: nil)

    ID of the access code by which to filter the returned access methods. Must be combined with access_grant_id, access_grant_key, or acs_entrance_id.

  • access_grant_id (defaults to: nil)

    ID of Access Grant to list access methods for.

  • access_grant_key (defaults to: nil)

    Key of Access Grant to list access methods for.

  • acs_entrance_id (defaults to: nil)

    ID of the entrance for which you want to retrieve all access methods that grant access to it.

  • device_id (defaults to: nil)

    ID of the device by which to filter the returned access methods. Must be combined with access_grant_id, access_grant_key, or acs_entrance_id.

  • limit (defaults to: nil)

    Maximum number of records to return per page.

  • page_cursor (defaults to: nil)

    Identifies the specific page of results to return, obtained from the previous page's next_page_cursor.

  • space_id (defaults to: nil)

    ID of the space by which to filter the returned access methods. Must be combined with access_grant_id, access_grant_key, or acs_entrance_id.

Returns:



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.

Parameters:

  • access_method_id

    ID of the cloud_key access_method to use for the unlock operation.

  • acs_entrance_id

    ID of the entrance to unlock.

Returns:



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

#unmanagedObject



13
14
15
# File 'lib/seam/routes/access_methods.rb', line 13

def unmanaged
  @unmanaged ||= Seam::Clients::AccessMethodsUnmanaged.new(client: @client, defaults: @defaults)
end