Sha256: f0244e4a52fa8d0a023073d4c88866e953eb5a20d4cca9abe9d661cf3fc88c3e

Contents?: true

Size: 1.38 KB

Versions: 2

Compression:

Stored size: 1.38 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, @client)
    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

2 entries across 2 versions & 1 rubygems

Version Path
seamapi-0.0.2 lib/seam/client.rb
seamapi-0.0.1 lib/seam/client.rb