Class: Adp::Connection::ApiConnectionFactory

Inherits:
Object
  • Object
show all
Defined in:
lib/adp/api_connection_factory.rb

Class Method Summary collapse

Class Method Details

.createConnection(connectionCfg) ⇒ ADPApiConnection

Parameters:

  • connectionCfg (Object)

Returns:

  • (ADPApiConnection)


13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/adp/api_connection_factory.rb', line 13

def self.createConnection( connectionCfg )

  if connectionCfg.nil?
    raise ConnectionException, "Configuration object expected, none provided"
  else
    classname = connectionCfg.class.name.split('::').last

    case classname
      when "AuthorizationCodeConfiguration"
        return  AuthorizationCodeConnection.new(connectionCfg)
      when "ClientCredentialConfiguration"
        return  ClientCredentialConnection.new(connectionCfg)
      else
        raise ADPConnectionException, "Grant type / Configuration type not implemented. #{connectionCfg.grantType}"
    end
  end
end