Class: Seam::Client

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(api_key: nil, base_uri: "https://connect.getseam.com", debug: false) ⇒ Client

Returns a new instance of Client.

Raises:

  • (ArgumentError)


7
8
9
10
11
12
13
# File 'lib/seam/client.rb', line 7

def initialize(api_key: nil, base_uri: "https://connect.getseam.com", debug: false)
  @api_key = api_key || ENV.fetch("SEAM_API_KEY", nil)
  @base_uri = base_uri
  @debug = debug

  raise ArgumentError, "SEAM_API_KEY not found in environment, and api_key not provided" unless @api_key
end

Instance Attribute Details

#api_keyObject

Returns the value of attribute api_key.



5
6
7
# File 'lib/seam/client.rb', line 5

def api_key
  @api_key
end

#base_uriObject

Returns the value of attribute base_uri.



5
6
7
# File 'lib/seam/client.rb', line 5

def base_uri
  @base_uri
end

#debugObject

Returns the value of attribute debug.



5
6
7
# File 'lib/seam/client.rb', line 5

def debug
  @debug
end

Instance Method Details

#access_codesObject



35
36
37
# File 'lib/seam/client.rb', line 35

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

#action_attemptsObject



31
32
33
# File 'lib/seam/client.rb', line 31

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

#connect_webviewsObject



43
44
45
# File 'lib/seam/client.rb', line 43

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

#connected_accountsObject



47
48
49
# File 'lib/seam/client.rb', line 47

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

#devicesObject



23
24
25
# File 'lib/seam/client.rb', line 23

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

#eventsObject



55
56
57
# File 'lib/seam/client.rb', line 55

def events
  @events ||= Seam::Clients::Events.new(self)
end

#healthObject



15
16
17
# File 'lib/seam/client.rb', line 15

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

#locksObject



19
20
21
# File 'lib/seam/client.rb', line 19

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

#request_seam(method, path, config = {}) ⇒ Object



67
68
69
70
71
72
73
74
75
# File 'lib/seam/client.rb', line 67

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

#request_seam_object(method, path, klass, inner_object, config = {}) ⇒ Object



59
60
61
62
63
64
65
# File 'lib/seam/client.rb', line 59

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

#unmanaged_access_codesObject



39
40
41
# File 'lib/seam/client.rb', line 39

def unmanaged_access_codes
  @unmanaged_access_codes ||= Seam::Clients::UnmanagedAccessCodes.new(self)
end

#unmanaged_devicesObject



27
28
29
# File 'lib/seam/client.rb', line 27

def unmanaged_devices
  @unmanaged_devices ||= Seam::Clients::UnmanagedDevices.new(self)
end

#workspacesObject



51
52
53
# File 'lib/seam/client.rb', line 51

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