Class: ApiClient::Configuration

Inherits:
Object
  • Object
show all
Defined in:
lib/api-client/configuration.rb

Overview

ApiClient::Configuration provides a way to configure ApiClient globally.

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#headerObject

Returns the value of attribute header


5
6
7
# File 'lib/api-client/configuration.rb', line 5

def header
  @header
end

#hydraObject

Returns the value of attribute hydra


4
5
6
# File 'lib/api-client/configuration.rb', line 4

def hydra
  @hydra
end

#mockObject

Returns the value of attribute mock


4
5
6
# File 'lib/api-client/configuration.rb', line 4

def mock
  @mock
end

Instance Method Details

#basic_auth(account, password) ⇒ Object

Set a basic authentication for all requisitions.

Parameters:

  • account (String)

    the user for requisitions.

  • password (String)

    the password for requisitions.


50
51
52
# File 'lib/api-client/configuration.rb', line 50

def basic_auth(, password)
  @header.merge!({ 'Authorization' => "Basic #{["#{}:#{password}"].pack('m').delete("\r\n")}" })
end

#pathString

Return the api url.

Returns:

  • (String)

    the api url.


10
11
12
13
14
15
# File 'lib/api-client/configuration.rb', line 10

def path
  @paths.each do |name, path|
    raise Exceptions::BadlyConfigured.new(name) unless path.size > 1
  end
  @paths
end

#path=(path) ⇒ Object

Set the api url.

Parameters:

  • path (String)

    api url.


20
21
22
23
# File 'lib/api-client/configuration.rb', line 20

def path=(path)
  path = "#{path}/" unless path[path.size - 1, 1] == '/'
  @paths = { :default => path }
end

#paths=(paths = {}) ⇒ Object

Set several api urls.

Parameters:

  • paths (Hash) (defaults to: {})

    hash with paths to api urls.


28
29
30
31
32
33
34
35
36
37
# File 'lib/api-client/configuration.rb', line 28

def paths=(paths = {})
  @paths = {}
  paths.each do |name, path|
    if path[path.size - 1, 1] == '/'
      @paths[name] = path
    else
      @paths[name] = "#{path}/"
    end
  end
end