Class: Aspire::API::Base

Inherits:
Object
  • Object
show all
Defined in:
lib/aspire/api/base.rb

Overview

The base class for Aspire API wrappers

Direct Known Subclasses

JSON, LinkedData

Constant Summary collapse

TALIS_DOMAIN =

Domain names

'talis.com'.freeze
ASPIRE_DOMAIN =
"rl.#{TALIS_DOMAIN}".freeze
ASPIRE_AUTH_DOMAIN =
"users.#{TALIS_DOMAIN}".freeze
SCHEME =

The default URL scheme

'http'.freeze
SSL_OPTS =

SSL options

i[ssl_ca_file ssl_ca_path ssl_cert_store].freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(tenancy_code, **opts) ⇒ Base

Initialises a new API instance

Parameters:

  • tenancy_code (String)
  • opts (Hash)

    a customizable set of options

Options Hash (**opts):

  • :logger (Logger)

    the API activity logger

  • :timeout (Integer)

    the API timeout in seconds

  • :ssl_ca_file (String)

    the certificate authority filename

  • :ssl_ca_path (String)

    the certificate authority directory

  • :ssl_cert_store (String)

    the certificate authority store



46
47
48
49
50
51
52
53
54
55
56
# File 'lib/aspire/api/base.rb', line 46

def initialize(tenancy_code, **opts)
  self.logger = opts[:logger]
  self.tenancy_code = tenancy_code
  self.timeout = opts[:timeout] || 0
  # Retry options
  initialize_retry(opts)
  # SSL options
  initialize_ssl(opts)
  # Set the RestClient logger
  RestClient.log = logger if logger
end

Instance Attribute Details

#loggerLogger

Returns a logger for activity logging.

Returns:

  • (Logger)

    a logger for activity logging



25
26
27
# File 'lib/aspire/api/base.rb', line 25

def logger
  @logger
end

#sslHash

Returns SSL options.

Returns:

  • (Hash)

    SSL options



29
30
31
# File 'lib/aspire/api/base.rb', line 29

def ssl
  @ssl
end

#tenancy_codeString

Returns the Aspire short tenancy code.

Returns:

  • (String)

    the Aspire short tenancy code



33
34
35
# File 'lib/aspire/api/base.rb', line 33

def tenancy_code
  @tenancy_code
end

#timeoutInteger

Returns the timeout period in seconds for API calls.

Returns:

  • (Integer)

    the timeout period in seconds for API calls



37
38
39
# File 'lib/aspire/api/base.rb', line 37

def timeout
  @timeout
end

Instance Method Details

#api_url(path) ⇒ String

This method is abstract.

Subclasses must implement this method

Returns a full API URL from a partial path

Parameters:

  • path (String)

    a full or partial API URL

Returns:

  • (String)

    the full API URL



62
63
64
# File 'lib/aspire/api/base.rb', line 62

def api_url(path)
  path
end