Sha256: c279417266d7b7a4b8d1db08e3d6d39202606b04f0bb8ebc4f34cd0cb960049b

Contents?: true

Size: 1.37 KB

Versions: 3

Compression:

Stored size: 1.37 KB

Contents

# frozen_string_literal: true

module Seam
  class Client
    attr_accessor :api_key, :base_uri, :debug

    def initialize(api_key:, base_uri: "https://connect.getseam.com", debug: false)
      @api_key = api_key
      @base_uri = base_uri
      @debug = debug
    end

    def health
      request_seam(:get, "/health")
    end

    def locks
      @locks ||= Seam::Clients::Locks.new(self)
    end

    def devices
      @devices ||= Seam::Clients::Devices.new(self)
    end

    def action_attempts
      @action_attempts ||= Seam::Clients::ActionAttempts.new(self)
    end

    def access_codes
      @access_codes ||= Seam::Clients::AccessCodes.new(self)
    end

    def connect_webviews
      @connect_webviews ||= Seam::Clients::ConnectWebviews.new(self)
    end

    def connected_accounts
      @connected_accounts ||= Seam::Clients::ConnectedAccounts.new(self)
    end

    def workspaces
      @workspaces ||= Seam::Clients::Workspaces.new(self)
    end

    def request_seam_object(method, path, klass, inner_object, config = {})
      response = request_seam(method, path, config)

      data = response[inner_object]

      klass.load_from_response(data, self)
    end

    def request_seam(method, path, config = {})
      Seam::Request.new(
        api_key: api_key,
        base_uri: base_uri,
        debug: debug
      ).perform(
        method, path, config
      )
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
seamapi-0.0.5 lib/seam/client.rb
seamapi-0.0.4 lib/seam/client.rb
seamapi-0.0.3 lib/seam/client.rb