Class: SkullIsland::APIClient

Inherits:
APIClientBase show all
Includes:
Singleton
Defined in:
lib/skull_island/api_client.rb

Overview

The API Client Singleton class

Instance Attribute Summary

Attributes inherited from APIClientBase

#base_uri, #password, #server, #username

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from APIClientBase

#api_uri, #authenticated?, #configured?, #delete, #get, #json_headers, #patch, #post, #put

Methods included from Helpers::APIClient

#about_service, #cache, #invalidate_cache_for, #json_escape, #lru_cache, #raw, #server_status, #version

Methods included from Validations::APIClient

#validate_creds, #validate_opts, #validate_server

Class Method Details

.about_serviceObject



12
13
14
# File 'lib/skull_island/api_client.rb', line 12

def self.about_service
  instance.about_service
end

.configure(opts = {}) ⇒ Object



8
9
10
# File 'lib/skull_island/api_client.rb', line 8

def self.configure(opts = {})
  instance.configure(opts)
end

.lru_cacheObject



16
17
18
# File 'lib/skull_island/api_client.rb', line 16

def self.lru_cache
  instance.lru_cache
end

.server_statusObject



20
21
22
# File 'lib/skull_island/api_client.rb', line 20

def self.server_status
  instance.server_status
end

Instance Method Details

#configure(opts = {}) ⇒ Object



24
25
26
27
28
29
30
31
32
33
34
# File 'lib/skull_island/api_client.rb', line 24

def configure(opts = {})
  # validations
  validate_opts(opts)

  # Set up the client's state
  @server     = opts[:server] || 'http://localhost:8001'
  @username   = opts[:username]
  @password   = opts[:password]
  @cache      = LRUCache.new(1000) # LRU cache of up to 1000 items
  @configured = true
end