Class: Seam::Clients::AccessGrants

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

Instance Method Summary collapse

Constructor Details

#initialize(client:, defaults:) ⇒ AccessGrants

Returns a new instance of AccessGrants.



6
7
8
9
# File 'lib/seam/routes/access_grants.rb', line 6

def initialize(client:, defaults:)
  @client = client
  @defaults = defaults
end

Instance Method Details

#create(requested_access_methods:, user_identity_id: nil, user_identity: nil, access_grant_key: nil, acs_entrance_ids: nil, customization_profile_id: nil, device_ids: nil, ends_at: nil, location: nil, location_ids: nil, name: nil, reservation_key: nil, space_ids: nil, space_keys: nil, starts_at: nil) ⇒ Seam::Resources::AccessGrant

Deprecated.

location: Create a space first, then reference it using space_ids.

Creates a new Access Grant. Access Grants are the default and recommended way to grant a user access to any physical space, irrespective of the locking hardware. They work with both standalone smart locks (using device_ids) and access control systems (using acs_entrance_ids or space_ids), and can issue PIN codes, key cards, and mobile keys through a single request.

Parameters:

  • requested_access_methods
  • user_identity_id (defaults to: nil)

    ID of user identity for whom access is being granted.

  • user_identity (defaults to: nil)

    When used, creates a new user identity with the given details, and grants them access.

  • access_grant_key (defaults to: nil)

    Unique key for the access grant within the workspace.

  • acs_entrance_ids (defaults to: nil)

    Set of IDs of the entrances to which access is being granted.

  • customization_profile_id (defaults to: nil)

    ID of the customization profile to apply to the Access Grant and its access methods.

  • device_ids (defaults to: nil)

    Set of IDs of the devices to which access is being granted.

  • ends_at (defaults to: nil)

    Date and time at which the validity of the new grant ends, in ISO 8601 format. Must be a time in the future and after starts_at.

  • location (defaults to: nil)
  • location_ids (defaults to: nil)
  • name (defaults to: nil)

    Name for the access grant.

  • reservation_key (defaults to: nil)

    Reservation key for the access grant.

  • space_ids (defaults to: nil)

    Set of IDs of existing spaces to which access is being granted.

  • space_keys (defaults to: nil)

    Set of keys of existing spaces to which access is being granted.

  • starts_at (defaults to: nil)

    Date and time at which the validity of the new grant starts, in ISO 8601 format.

Returns:



34
35
36
37
38
# File 'lib/seam/routes/access_grants.rb', line 34

def create(requested_access_methods:, user_identity_id: nil, user_identity: nil, access_grant_key: nil, acs_entrance_ids: nil, customization_profile_id: nil, device_ids: nil, ends_at: nil, location: nil, location_ids: nil, name: nil, reservation_key: nil, space_ids: nil, space_keys: nil, starts_at: nil)
  res = @client.post("/access_grants/create", {requested_access_methods: requested_access_methods, user_identity_id: user_identity_id, user_identity: user_identity, access_grant_key: access_grant_key, acs_entrance_ids: acs_entrance_ids, customization_profile_id: customization_profile_id, device_ids: device_ids, ends_at: ends_at, location: location, location_ids: location_ids, name: name, reservation_key: reservation_key, space_ids: space_ids, space_keys: space_keys, starts_at: starts_at}.compact)

  Seam::Resources::AccessGrant.load_from_response(res.body["access_grant"])
end

#delete(access_grant_id:) ⇒ nil

Delete an Access Grant.

Parameters:

  • access_grant_id

    ID of Access Grant to delete.

Returns:

  • (nil)

    OK



43
44
45
46
47
# File 'lib/seam/routes/access_grants.rb', line 43

def delete(access_grant_id:)
  @client.post("/access_grants/delete", {access_grant_id: access_grant_id}.compact)

  nil
end

#get(access_grant_id: nil, access_grant_key: nil) ⇒ Seam::Resources::AccessGrant

Get an Access Grant.

Parameters:

  • access_grant_id (defaults to: nil)

    ID of Access Grant to get.

  • access_grant_key (defaults to: nil)

    Unique key of Access Grant to get.

Returns:



53
54
55
56
57
# File 'lib/seam/routes/access_grants.rb', line 53

def get(access_grant_id: nil, access_grant_key: nil)
  res = @client.post("/access_grants/get", {access_grant_id: access_grant_id, access_grant_key: access_grant_key}.compact)

  Seam::Resources::AccessGrant.load_from_response(res.body["access_grant"])
end

Gets all related resources for one or more Access Grants.

Parameters:

  • access_grant_ids (defaults to: nil)

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

  • access_grant_keys (defaults to: nil)

    Keys of the access grants that you want to get along with their related resources.

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

Returns:



65
66
67
68
69
# File 'lib/seam/routes/access_grants.rb', line 65

def get_related(access_grant_ids: nil, access_grant_keys: nil, exclude: nil, include: nil)
  res = @client.post("/access_grants/get_related", {access_grant_ids: access_grant_ids, access_grant_keys: access_grant_keys, exclude: exclude, include: include}.compact)

  Seam::Resources::Batch.load_from_response(res.body["batch"])
end

#list(access_code_id: nil, access_grant_ids: nil, access_grant_key: nil, acs_entrance_id: nil, acs_system_id: nil, customer_key: nil, device_id: nil, limit: nil, location_id: nil, page_cursor: nil, reservation_key: nil, space_id: nil, user_identity_id: nil) ⇒ Seam::Resources::AccessGrant

Deprecated.

location_id: Use space_id.

Gets an Access Grant.

Parameters:

  • access_code_id (defaults to: nil)

    ID of the access code by which you want to filter the list of Access Grants.

  • access_grant_ids (defaults to: nil)

    IDs of the access grants to retrieve.

  • access_grant_key (defaults to: nil)

    Filter Access Grants by access_grant_key. Use null to filter for Access Grants without an access_grant_key.

  • acs_entrance_id (defaults to: nil)

    ID of the entrance by which you want to filter the list of Access Grants.

  • acs_system_id (defaults to: nil)

    ID of the access system by which you want to filter the list of Access Grants.

  • customer_key (defaults to: nil)

    Customer key for which you want to list access grants.

  • device_id (defaults to: nil)

    ID of the device by which you want to filter the list of Access Grants.

  • limit (defaults to: nil)

    Numerical limit on the number of access grants to return.

  • location_id (defaults to: nil)
  • page_cursor (defaults to: nil)

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

  • reservation_key (defaults to: nil)

    Filter Access Grants by reservation_key.

  • space_id (defaults to: nil)

    ID of the space by which you want to filter the list of Access Grants.

  • user_identity_id (defaults to: nil)

    ID of user identity by which you want to filter the list of Access Grants.

Returns:



87
88
89
90
91
# File 'lib/seam/routes/access_grants.rb', line 87

def list(access_code_id: nil, access_grant_ids: nil, access_grant_key: nil, acs_entrance_id: nil, acs_system_id: nil, customer_key: nil, device_id: nil, limit: nil, location_id: nil, page_cursor: nil, reservation_key: nil, space_id: nil, user_identity_id: nil)
  res = @client.post("/access_grants/list", {access_code_id: access_code_id, access_grant_ids: access_grant_ids, access_grant_key: access_grant_key, acs_entrance_id: acs_entrance_id, acs_system_id: acs_system_id, customer_key: customer_key, device_id: device_id, limit: limit, location_id: location_id, page_cursor: page_cursor, reservation_key: reservation_key, space_id: space_id, user_identity_id: user_identity_id}.compact)

  Seam::Resources::AccessGrant.load_from_response(res.body["access_grants"])
end

#request_access_methods(access_grant_id:, requested_access_methods:) ⇒ Seam::Resources::AccessGrant

Adds additional requested access methods to an existing Access Grant.

Parameters:

  • access_grant_id

    ID of the Access Grant to add access methods to.

  • requested_access_methods

    Array of requested access methods to add to the access grant.

Returns:



97
98
99
100
101
# File 'lib/seam/routes/access_grants.rb', line 97

def request_access_methods(access_grant_id:, requested_access_methods:)
  res = @client.post("/access_grants/request_access_methods", {access_grant_id: access_grant_id, requested_access_methods: requested_access_methods}.compact)

  Seam::Resources::AccessGrant.load_from_response(res.body["access_grant"])
end

#unmanagedObject



11
12
13
# File 'lib/seam/routes/access_grants.rb', line 11

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

#update(access_grant_id: nil, access_grant_key: nil, ends_at: nil, name: nil, starts_at: nil) ⇒ nil

Updates an existing Access Grant's time window.

Parameters:

  • access_grant_id (defaults to: nil)

    ID of the Access Grant to update. Provide either access_grant_id or access_grant_key.

  • access_grant_key (defaults to: nil)

    Key of the Access Grant to update. Provide either access_grant_id or access_grant_key.

  • ends_at (defaults to: nil)

    Date and time at which the validity of the grant ends, in ISO 8601 format. Must be a time in the future and after starts_at.

  • name (defaults to: nil)

    Display name for the access grant.

  • starts_at (defaults to: nil)

    Date and time at which the validity of the grant starts, in ISO 8601 format.

Returns:

  • (nil)

    OK



110
111
112
113
114
# File 'lib/seam/routes/access_grants.rb', line 110

def update(access_grant_id: nil, access_grant_key: nil, ends_at: nil, name: nil, starts_at: nil)
  @client.post("/access_grants/update", {access_grant_id: access_grant_id, access_grant_key: access_grant_key, ends_at: ends_at, name: name, starts_at: starts_at}.compact)

  nil
end