Class: Seam::Clients::UserIdentities
- Inherits:
-
Object
- Object
- Seam::Clients::UserIdentities
- Defined in:
- lib/seam/routes/user_identities.rb
Instance Method Summary collapse
-
#add_acs_user(acs_user_id:, user_identity_id: nil, user_identity_key: nil) ⇒ nil
Adds a specified access system user to a specified user identity.
-
#create(acs_system_ids: nil, email_address: nil, full_name: nil, phone_number: nil, user_identity_key: nil) ⇒ Seam::Resources::UserIdentity
Creates a new user identity.
-
#delete(user_identity_id:) ⇒ nil
Deletes a specified user identity.
-
#generate_instant_key(user_identity_id:, customization_profile_id: nil, max_use_count: nil) ⇒ Seam::Resources::InstantKey
Generates a new instant key for a specified user identity.
-
#get(user_identity_id: nil, user_identity_key: nil) ⇒ Seam::Resources::UserIdentity
Returns a specified user identity.
-
#grant_access_to_device(device_id:, user_identity_id:) ⇒ nil
Grants a specified user identity access to a specified device.
-
#initialize(client:, defaults:) ⇒ UserIdentities
constructor
A new instance of UserIdentities.
-
#list(created_before: nil, credential_manager_acs_system_id: nil, limit: nil, page_cursor: nil, search: nil, user_identity_ids: nil) ⇒ Seam::Resources::UserIdentity
Returns a list of all user identities.
-
#list_accessible_devices(user_identity_id:) ⇒ Seam::Resources::Device
Returns a list of all devices associated with a specified user identity.
-
#list_accessible_entrances(user_identity_id:) ⇒ Seam::Resources::AcsEntrance
Returns a list of all ACS entrances accessible to a specified user identity.
-
#list_acs_systems(user_identity_id:) ⇒ Seam::Resources::AcsSystem
Returns a list of all access systems associated with a specified user identity.
-
#list_acs_users(user_identity_id:) ⇒ Seam::Resources::AcsUser
Returns a list of all access system users assigned to a specified user identity.
-
#merge(merged_user_identity_ids: nil, merged_user_identity_keys: nil, user_identity_id: nil, user_identity_key: nil) ⇒ nil
Merges one or more user identities into a primary user identity, for when the same person ended up with more than one user identity.
-
#remove_acs_user(acs_user_id:, user_identity_id:) ⇒ nil
Removes a specified access system user from a specified user identity.
-
#revoke_access_to_device(device_id:, user_identity_id:) ⇒ nil
Revokes access to a specified device from a specified user identity.
- #unmanaged ⇒ Object
-
#update(user_identity_id:, email_address: nil, full_name: nil, phone_number: nil, user_identity_key: nil) ⇒ nil
Updates a specified user identity.
Constructor Details
#initialize(client:, defaults:) ⇒ UserIdentities
Returns a new instance of UserIdentities.
6 7 8 9 |
# File 'lib/seam/routes/user_identities.rb', line 6 def initialize(client:, defaults:) @client = client @defaults = defaults end |
Instance Method Details
#add_acs_user(acs_user_id:, user_identity_id: nil, user_identity_key: nil) ⇒ nil
Adds a specified access system user to a specified user identity.
You must specify either user_identity_id or user_identity_key to identify the user identity.
If user_identity_key is provided, but the user identity doesn't exist, a new user identity will be created automatically using information from the ACS user.
24 25 26 27 28 |
# File 'lib/seam/routes/user_identities.rb', line 24 def add_acs_user(acs_user_id:, user_identity_id: nil, user_identity_key: nil) @client.put("/user_identities/add_acs_user", {acs_user_id: acs_user_id, user_identity_id: user_identity_id, user_identity_key: user_identity_key}.compact) nil end |
#create(acs_system_ids: nil, email_address: nil, full_name: nil, phone_number: nil, user_identity_key: nil) ⇒ Seam::Resources::UserIdentity
Creates a new user identity.
37 38 39 40 41 |
# File 'lib/seam/routes/user_identities.rb', line 37 def create(acs_system_ids: nil, email_address: nil, full_name: nil, phone_number: nil, user_identity_key: nil) res = @client.post("/user_identities/create", {acs_system_ids: acs_system_ids, email_address: email_address, full_name: full_name, phone_number: phone_number, user_identity_key: user_identity_key}.compact) Seam::Resources::UserIdentity.load_from_response(res.body["user_identity"]) end |
#delete(user_identity_id:) ⇒ nil
Deletes a specified user identity. This deletes the user identity and all associated resources, including any credentials, acs users and client sessions.
46 47 48 49 50 |
# File 'lib/seam/routes/user_identities.rb', line 46 def delete(user_identity_id:) @client.delete("/user_identities/delete", {user_identity_id: user_identity_id}.compact) nil end |
#generate_instant_key(user_identity_id:, customization_profile_id: nil, max_use_count: nil) ⇒ Seam::Resources::InstantKey
Generates a new instant key for a specified user identity.
57 58 59 60 61 |
# File 'lib/seam/routes/user_identities.rb', line 57 def generate_instant_key(user_identity_id:, customization_profile_id: nil, max_use_count: nil) res = @client.post("/user_identities/generate_instant_key", {user_identity_id: user_identity_id, customization_profile_id: customization_profile_id, max_use_count: max_use_count}.compact) Seam::Resources::InstantKey.load_from_response(res.body["instant_key"]) end |
#get(user_identity_id: nil, user_identity_key: nil) ⇒ Seam::Resources::UserIdentity
Returns a specified user identity.
67 68 69 70 71 72 73 74 75 |
# File 'lib/seam/routes/user_identities.rb', line 67 def get(user_identity_id: nil, user_identity_key: nil) if user_identity_id.nil? && user_identity_key.nil? raise TypeError, "At least one parameter is required for /user_identities/get" end res = @client.get("/user_identities/get", {user_identity_id: user_identity_id, user_identity_key: user_identity_key}.compact) Seam::Resources::UserIdentity.load_from_response(res.body["user_identity"]) end |
#grant_access_to_device(device_id:, user_identity_id:) ⇒ nil
Grants a specified user identity access to a specified device.
81 82 83 84 85 |
# File 'lib/seam/routes/user_identities.rb', line 81 def grant_access_to_device(device_id:, user_identity_id:) @client.put("/user_identities/grant_access_to_device", {device_id: device_id, user_identity_id: user_identity_id}.compact) nil end |
#list(created_before: nil, credential_manager_acs_system_id: nil, limit: nil, page_cursor: nil, search: nil, user_identity_ids: nil) ⇒ Seam::Resources::UserIdentity
Returns a list of all user identities.
95 96 97 98 99 |
# File 'lib/seam/routes/user_identities.rb', line 95 def list(created_before: nil, credential_manager_acs_system_id: nil, limit: nil, page_cursor: nil, search: nil, user_identity_ids: nil) res = @client.get("/user_identities/list", {created_before: created_before, credential_manager_acs_system_id: credential_manager_acs_system_id, limit: limit, page_cursor: page_cursor, search: search, user_identity_ids: user_identity_ids}.compact) Seam::Resources::UserIdentity.load_from_response(res.body["user_identities"]) end |
#list_accessible_devices(user_identity_id:) ⇒ Seam::Resources::Device
Returns a list of all devices associated with a specified user identity. This includes devices derived from the access grants assigned to the user identity and devices directly linked to the user identity.
104 105 106 107 108 |
# File 'lib/seam/routes/user_identities.rb', line 104 def list_accessible_devices(user_identity_id:) res = @client.get("/user_identities/list_accessible_devices", {user_identity_id: user_identity_id}.compact) Seam::Resources::Device.load_from_response(res.body["devices"]) end |
#list_accessible_entrances(user_identity_id:) ⇒ Seam::Resources::AcsEntrance
Returns a list of all ACS entrances accessible to a specified user identity. This includes entrances derived from the access grants assigned to the user identity and entrances accessible through ACS users linked to the user identity.
113 114 115 116 117 |
# File 'lib/seam/routes/user_identities.rb', line 113 def list_accessible_entrances(user_identity_id:) res = @client.get("/user_identities/list_accessible_entrances", {user_identity_id: user_identity_id}.compact) Seam::Resources::AcsEntrance.load_from_response(res.body["acs_entrances"]) end |
#list_acs_systems(user_identity_id:) ⇒ Seam::Resources::AcsSystem
Returns a list of all access systems associated with a specified user identity.
122 123 124 125 126 |
# File 'lib/seam/routes/user_identities.rb', line 122 def list_acs_systems(user_identity_id:) res = @client.get("/user_identities/list_acs_systems", {user_identity_id: user_identity_id}.compact) Seam::Resources::AcsSystem.load_from_response(res.body["acs_systems"]) end |
#list_acs_users(user_identity_id:) ⇒ Seam::Resources::AcsUser
Returns a list of all access system users assigned to a specified user identity.
131 132 133 134 135 |
# File 'lib/seam/routes/user_identities.rb', line 131 def list_acs_users(user_identity_id:) res = @client.get("/user_identities/list_acs_users", {user_identity_id: user_identity_id}.compact) Seam::Resources::AcsUser.load_from_response(res.body["acs_users"]) end |
#merge(merged_user_identity_ids: nil, merged_user_identity_keys: nil, user_identity_id: nil, user_identity_key: nil) ⇒ nil
Merges one or more user identities into a primary user identity, for when the same person ended up with more than one user identity.
The primary user identity takes on any email address or phone number it was missing from the user identities merged into it, and the merged user identities are then deleted. Their IDs and keys keep working: looking one up returns the primary user identity, and they are listed on it as merged_user_identity_ids and merged_user_identity_keys.
Access grants, access system users, client sessions and other resources belonging to the merged user identities are moved to the primary user identity.
Identify the user identities either by ID or by key, but not both in the same request. Repeating a merge that has already been applied makes no further changes.
149 150 151 152 153 154 155 156 157 |
# File 'lib/seam/routes/user_identities.rb', line 149 def merge(merged_user_identity_ids: nil, merged_user_identity_keys: nil, user_identity_id: nil, user_identity_key: nil) if merged_user_identity_ids.nil? && merged_user_identity_keys.nil? && user_identity_id.nil? && user_identity_key.nil? raise TypeError, "At least one parameter is required for /user_identities/merge" end @client.post("/user_identities/merge", {merged_user_identity_ids: merged_user_identity_ids, merged_user_identity_keys: merged_user_identity_keys, user_identity_id: user_identity_id, user_identity_key: user_identity_key}.compact) nil end |
#remove_acs_user(acs_user_id:, user_identity_id:) ⇒ nil
Removes a specified access system user from a specified user identity.
163 164 165 166 167 |
# File 'lib/seam/routes/user_identities.rb', line 163 def remove_acs_user(acs_user_id:, user_identity_id:) @client.delete("/user_identities/remove_acs_user", {acs_user_id: acs_user_id, user_identity_id: user_identity_id}.compact) nil end |
#revoke_access_to_device(device_id:, user_identity_id:) ⇒ nil
Revokes access to a specified device from a specified user identity.
173 174 175 176 177 |
# File 'lib/seam/routes/user_identities.rb', line 173 def revoke_access_to_device(device_id:, user_identity_id:) @client.delete("/user_identities/revoke_access_to_device", {device_id: device_id, user_identity_id: user_identity_id}.compact) nil end |
#unmanaged ⇒ Object
11 12 13 |
# File 'lib/seam/routes/user_identities.rb', line 11 def unmanaged @unmanaged ||= Seam::Clients::UserIdentitiesUnmanaged.new(client: @client, defaults: @defaults) end |
#update(user_identity_id:, email_address: nil, full_name: nil, phone_number: nil, user_identity_key: nil) ⇒ nil
Updates a specified user identity.
186 187 188 189 190 |
# File 'lib/seam/routes/user_identities.rb', line 186 def update(user_identity_id:, email_address: nil, full_name: nil, phone_number: nil, user_identity_key: nil) @client.patch("/user_identities/update", {user_identity_id: user_identity_id, email_address: email_address, full_name: full_name, phone_number: phone_number, user_identity_key: user_identity_key}.compact) nil end |