Class: SecureTrading::Connection

Inherits:
Object
  • Object
show all
Defined in:
lib/secure_trading/connection.rb

Defined Under Namespace

Classes: CertificateFileNotFound

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(xpay_client, site_reference, certificate_path, options = {}) ⇒ Connection

Returns a new instance of Connection.



8
9
10
11
12
13
14
# File 'lib/secure_trading/connection.rb', line 8

def initialize(xpay_client, site_reference, certificate_path, options = {})
  @xpay_client          = xpay_client
  @site_reference       = site_reference
  @certificate_path     = certificate_path
  @options              = options
  @options[:request_cache_path] ||= File.join('', 'tmp', 'securetrading', 'requests')
end

Instance Attribute Details

#certificate_pathObject (readonly)

Returns the value of attribute certificate_path.



6
7
8
# File 'lib/secure_trading/connection.rb', line 6

def certificate_path
  @certificate_path
end

#site_referenceObject (readonly)

Returns the value of attribute site_reference.



6
7
8
# File 'lib/secure_trading/connection.rb', line 6

def site_reference
  @site_reference
end

#xpay_clientObject (readonly)

Returns the value of attribute xpay_client.



6
7
8
# File 'lib/secure_trading/connection.rb', line 6

def xpay_client
  @xpay_client
end

Instance Method Details

#certificateObject



16
17
18
19
20
21
22
# File 'lib/secure_trading/connection.rb', line 16

def certificate
  if File.exist?(self.certificate_path)
    File.read(self.certificate_path)
  else
    raise CertificateFileNotFound, "Certificate file was not located at #{self.certificate_path}"
  end
end

#optionsObject



24
25
26
# File 'lib/secure_trading/connection.rb', line 24

def options
  @options
end