Sha256: cc047ecd0a01dedaa530669a39372e3784dfaf80449b81b8eb0301302d5622c9

Contents?: true

Size: 1010 Bytes

Versions: 1

Compression:

Stored size: 1010 Bytes

Contents

require 'adp/client_credential_configuration'
require 'adp/authorization_code_configuration'
require 'adp/client_credential_connection'
require 'adp/authorization_code_connection'

module Adp
  module Connection
    class ApiConnectionFactory


      # @param [Object] connectionCfg
      # @return [ADPApiConnection]
      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 ConnectionException, "Grant type / Configuration type not implemented. #{connectionCfg.grantType}"
          end
        end
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
adp-connection-0.1.5 lib/adp/api_connection_factory.rb