Class: Seam::Clients::Locks

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

Instance Method Summary collapse

Constructor Details

#initialize(client:, defaults:) ⇒ Locks

Returns a new instance of Locks.



8
9
10
11
# File 'lib/seam/routes/locks.rb', line 8

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

Instance Method Details

#configure_auto_lock(auto_lock_enabled:, device_id:, auto_lock_delay_seconds: nil, wait_for_action_attempt: nil) ⇒ Seam::Resources::ActionAttempt

Configures the auto-lock setting for a specified lock.

Parameters:

  • auto_lock_enabled (Boolean)

    Whether to enable or disable auto-lock.

  • device_id (String)

    ID of the lock for which you want to configure the auto-lock.

  • auto_lock_delay_seconds (Float, nil) (defaults to: nil)

    Delay in seconds before the lock automatically locks. Required when enabling auto-lock. Must be between 1 and 60.

Returns:



22
23
24
25
26
27
28
# File 'lib/seam/routes/locks.rb', line 22

def configure_auto_lock(auto_lock_enabled:, device_id:, auto_lock_delay_seconds: nil, wait_for_action_attempt: nil)
  res = @client.post("/locks/configure_auto_lock", {auto_lock_enabled: auto_lock_enabled, device_id: device_id, auto_lock_delay_seconds: auto_lock_delay_seconds}.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(device_id: nil, name: nil) ⇒ Seam::Resources::Device

Deprecated.

Use /devices/get instead.

Returns a specified lock.

Parameters:

  • device_id (String, nil) (defaults to: nil)

    ID of the lock that you want to get.

  • name (String, nil) (defaults to: nil)

    Name of the lock that you want to get.

Returns:



35
36
37
38
39
40
41
42
43
# File 'lib/seam/routes/locks.rb', line 35

def get(device_id: nil, name: nil)
  if device_id.nil? && name.nil?
    raise TypeError, "At least one parameter is required for /locks/get"
  end

  res = @client.get("/locks/get", {device_id: device_id, name: name}.compact)

  Seam::Resources::Device.load_from_response(res.body["device"])
end

#list(connect_webview_id: nil, connected_account_id: nil, customer_key: nil, device_type: nil, device_types: nil, manufacturer: nil) ⇒ Seam::Resources::Device

Returns a list of all locks.

Parameters:

  • connect_webview_id (String, nil) (defaults to: nil)

    ID of the Connect Webview for which you want to list devices.

  • connected_account_id (String, nil) (defaults to: nil)

    ID of the connected account for which you want to list devices.

  • customer_key (String, nil) (defaults to: nil)

    Customer key for which you want to list devices.

  • device_type (String, nil) (defaults to: nil)

    Device type of the locks that you want to list.

  • device_types (Array<String>, nil) (defaults to: nil)

    Device types of the locks that you want to list.

  • manufacturer (String, nil) (defaults to: nil)

    Manufacturer of the locks that you want to list.

Returns:



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

def list(connect_webview_id: nil, connected_account_id: nil, customer_key: nil, device_type: nil, device_types: nil, manufacturer: nil)
  res = @client.post("/locks/list", {connect_webview_id: connect_webview_id, connected_account_id: , customer_key: customer_key, device_type: device_type, device_types: device_types, manufacturer: manufacturer}.compact)

  Seam::Resources::Device.load_from_response(res.body["devices"])
end

#lock_door(device_id:, wait_for_action_attempt: nil) ⇒ Seam::Resources::ActionAttempt

Parameters:

  • device_id (String)

    ID of the lock that you want to lock.

Returns:



62
63
64
65
66
67
68
# File 'lib/seam/routes/locks.rb', line 62

def lock_door(device_id:, wait_for_action_attempt: nil)
  res = @client.post("/locks/lock_door", {device_id: device_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

#simulateObject



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

def simulate
  @simulate ||= Seam::Clients::LocksSimulate.new(client: @client, defaults: @defaults)
end

#unlock_door(device_id:, wait_for_action_attempt: nil) ⇒ Seam::Resources::ActionAttempt

Parameters:

  • device_id (String)

    ID of the lock that you want to unlock.

Returns:



73
74
75
76
77
78
79
# File 'lib/seam/routes/locks.rb', line 73

def unlock_door(device_id:, wait_for_action_attempt: nil)
  res = @client.post("/locks/unlock_door", {device_id: device_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