Sha256: 216e00e155554282a8ef630388264f73266a3e108b393f44b5ab541742e1283f

Contents?: true

Size: 1.92 KB

Versions: 1

Compression:

Stored size: 1.92 KB

Contents

module StarkitBanking
  class Environment
    def self.build(credentials)   
      if credentials.decrypt_username == 'DEMO'
        ApiBanking::Environment::LOCAL.new(ENV['LOCAL_API_HOST'],ENV['LOCAL_API_PORT'])
      else
        if credentials.environment.try(:upcase) == 'UAT'
          if credentials.bank_name == 'YBL'
            ::ApiBanking::Environment::YBL::UAT.new(
              credentials.decrypt_username,
              credentials.password,
              credentials.decrypt_client_id,
              credentials.decrypt_client_secret
            )
          else
            ::ApiBanking::Environment::RBL::UAT.new(
              credentials.decrypt_username,
              credentials.password,
              credentials.decrypt_client_id,
              credentials.decrypt_client_secret,
              credentials.client_certificate.path, 
              credentials.client_private_key.path,
              credentials.decrypt_client_private_key_pwd
            )
          end
        elsif credentials.environment.try(:upcase) == 'PROD'
          if credentials.bank_name == 'YBL'
            ::ApiBanking::Environment::YBL::PRD.new(
              credentials.decrypt_username,
              credentials.password,
              credentials.decrypt_client_id,
              credentials.decrypt_client_secret,
              credentials.client_certificate.path,
              credentials.client_private_key.path,
              credentials.decrypt_client_private_key_pwd
            )
          else
            ::ApiBanking::Environment::RBL::PROD.new(
              credentials.decrypt_username,
              credentials.password,
              credentials.decrypt_client_id,
              credentials.decrypt_client_secret,
              credentials.client_certificate.path, 
              credentials.client_private_key.path,
              credentials.decrypt_client_private_key_pwd
            )
          end
        end
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
starkit_banking-0.1.26 lib/starkit_banking/api/environment.rb