Sha256: 73589826973f912bcd5bd99acd2ee5a23a499155e33f581869b25e761cda83f8

Contents?: true

Size: 1.38 KB

Versions: 20

Compression:

Stored size: 1.38 KB

Contents

# frozen_string_literal: true

module Seam
  module Clients
    class Locks < BaseClient
      # Unlocks a door
      #
      # @param [String] device_id
      # @return [Seam::ActionAttempt]
      def unlock_door(device_or_id)
        request_seam_object(
          :post,
          "/locks/unlock_door",
          Seam::ActionAttempt,
          "action_attempt",
          body: {
            device_id: device_id(device_or_id)
          }
        )
      end

      # Locks a door
      #
      # @param [String] device_id
      # @return [Seam::ActionAttempt]
      def lock_door(device_or_id)
        request_seam_object(
          :post,
          "/locks/lock_door",
          Seam::ActionAttempt,
          "action_attempt",
          body: {
            device_id: device_id(device_or_id)
          }
        )
      end

      def list(params = {})
        request_seam_object(
          :get,
          "/locks/list",
          Seam::Device,
          "locks",
          params: params
        )
      end

      def get(device_or_id)
        request_seam_object(
          :get,
          "/locks/get",
          Seam::Device,
          "lock",
          params: {
            device_id: device_id(device_or_id)
          }
        )
      end

      protected

      def device_id(device_or_id)
        device_or_id.is_a?(Seam::Device) ? device_or_id.device_id : device_or_id
      end
    end
  end
end

Version data entries

20 entries across 20 versions & 1 rubygems

Version Path
seamapi-1.14.0 lib/seam/clients/locks.rb
seamapi-1.13.0 lib/seam/clients/locks.rb
seamapi-1.12.1 lib/seam/clients/locks.rb
seamapi-1.12.0 lib/seam/clients/locks.rb
seamapi-1.11.2 lib/seam/clients/locks.rb
seamapi-1.11.1 lib/seam/clients/locks.rb
seamapi-1.11.0 lib/seam/clients/locks.rb
seamapi-1.10.0 lib/seam/clients/locks.rb
seamapi-1.9.0 lib/seam/clients/locks.rb
seamapi-1.8.0 lib/seam/clients/locks.rb
seamapi-1.7.0 lib/seam/clients/locks.rb
seamapi-1.6.0 lib/seam/clients/locks.rb
seamapi-1.5.0 lib/seam/clients/locks.rb
seamapi-1.4.0 lib/seam/clients/locks.rb
seamapi-1.3.2 lib/seam/clients/locks.rb
seamapi-1.3.1 lib/seam/clients/locks.rb
seamapi-0.1.0 lib/seam/clients/locks.rb
seamapi-0.0.5 lib/seam/clients/locks.rb
seamapi-0.0.4 lib/seam/clients/locks.rb
seamapi-0.0.3 lib/seam/clients/locks.rb