Class: KnuVerse::Knufactor::APIClient

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

Overview

The API Client Singleton class

Instance Attribute Summary

Attributes inherited from APIClientBase

#account, #apikey, #base_uri, #secret, #server

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from APIClientBase

#about_service, #api_uri, #authenticated?, #configured?, #get, #json_headers, #patch, #post, #put, #refresh_auth, #refresh_auth_bearer

Methods included from Helpers::APIClient

#json_escape, #raw, #version

Methods included from Validations::APIClient

#validate_creds, #validate_opts, #validate_server

Class Method Details

.about_serviceObject



11
12
13
# File 'lib/knuverse/knufactor/api_client.rb', line 11

def self.about_service
  instance.about_service
end

.configure(opts = {}) ⇒ Object



7
8
9
# File 'lib/knuverse/knufactor/api_client.rb', line 7

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

Instance Method Details

#configure(opts = {}) ⇒ Object



15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/knuverse/knufactor/api_client.rb', line 15

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

  # Set up the client's state
  @server     = opts[:server] || 'https://cloud.knuverse.com'
  @apikey     = opts[:apikey]
  @secret     = opts[:secret]
  @base_uri   = opts[:base_uri] || '/api/v1/'
  @last_auth  = nil
  @auth_token = nil
  @configured = true
end