Sha256: 85bc7347d4311d41f3ee22dab6bcc2c34fd79320526a11cf3fd01b08172ce5f3

Contents?: true

Size: 1.38 KB

Versions: 5

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(body = {})
        request_seam_object(
          :post,
          "/locks/list",
          Seam::Device,
          "locks",
          body: body
        )
      end

      def get(device_or_id)
        request_seam_object(
          :post,
          "/locks/get",
          Seam::Device,
          "lock",
          body: {
            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

5 entries across 5 versions & 1 rubygems

Version Path
seamapi-2.0.0 lib/seam/clients/locks.rb
seamapi-1.17.0 lib/seam/clients/locks.rb
seamapi-1.16.1 lib/seam/clients/locks.rb
seamapi-1.16.0 lib/seam/clients/locks.rb
seamapi-1.15.0 lib/seam/clients/locks.rb