Class: Seam::Clients::AccessMethods

Inherits:
Object
  • Object
show all
Defined in:
lib/seam/routes/clients/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/clients/access_methods.rb', line 8

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

Instance Method Details

#assign_card(access_method_id:, card_number:) ⇒ Object



17
18
19
20
21
# File 'lib/seam/routes/clients/access_methods.rb', line 17

def assign_card(access_method_id:, card_number:)
  res = @client.post("/access_methods/assign_card", {access_method_id: access_method_id, card_number: card_number}.compact)

  Seam::Resources::AccessMethod.load_from_response(res.body["access_method"])
end

#delete(access_method_id: nil, access_grant_id: nil, reservation_key: nil) ⇒ Object



23
24
25
26
27
# File 'lib/seam/routes/clients/access_methods.rb', line 23

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) ⇒ Object



29
30
31
32
33
34
35
# File 'lib/seam/routes/clients/access_methods.rb', line 29

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:) ⇒ Object



37
38
39
40
41
# File 'lib/seam/routes/clients/access_methods.rb', line 37

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


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

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, space_id: nil) ⇒ Object



49
50
51
52
53
# File 'lib/seam/routes/clients/access_methods.rb', line 49

def list(access_code_id: nil, access_grant_id: nil, access_grant_key: nil, acs_entrance_id: nil, device_id: 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, 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) ⇒ Object



55
56
57
58
59
60
61
# File 'lib/seam/routes/clients/access_methods.rb', line 55

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/clients/access_methods.rb', line 13

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