Class: BMLConnect::Models::Transaction

Inherits:
Object
  • Object
show all
Includes:
Crypt::Signature
Defined in:
lib/bml_connect/models/transaction.rb

Constant Summary collapse

REQUIRED_FIELDS =
Set[:amount, :currency]

Instance Attribute Summary collapse

Attributes included from Crypt::Signature

#signature

Instance Method Summary collapse

Methods included from Crypt::Signature

#sign

Constructor Details

#initialize(fields) ⇒ Transaction

Returns a new instance of Transaction.

Raises:

  • (ArgumentError)


15
16
17
18
19
20
21
# File 'lib/bml_connect/models/transaction.rb', line 15

def initialize(fields)
  # check for required fields
  raise ArgumentError.new("Missing Required Fields: [#{REQUIRED_FIELDS.join(', ')}]") unless REQUIRED_FIELDS.subset?(fields.keys.to_set)

  #initialize transaction props
  fields.each { |k,v| public_send("#{k}=", v) }
end

Instance Attribute Details

#amountObject

Returns the value of attribute amount.



13
14
15
# File 'lib/bml_connect/models/transaction.rb', line 13

def amount
  @amount
end

#currencyObject

Returns the value of attribute currency.



13
14
15
# File 'lib/bml_connect/models/transaction.rb', line 13

def currency
  @currency
end

#customerReferenceObject

Returns the value of attribute customerReference.



13
14
15
# File 'lib/bml_connect/models/transaction.rb', line 13

def customerReference
  @customerReference
end

#isPreauthorizationObject

Returns the value of attribute isPreauthorization.



13
14
15
# File 'lib/bml_connect/models/transaction.rb', line 13

def isPreauthorization
  @isPreauthorization
end

#localIdObject

Returns the value of attribute localId.



13
14
15
# File 'lib/bml_connect/models/transaction.rb', line 13

def localId
  @localId
end

#providerObject

Returns the value of attribute provider.



13
14
15
# File 'lib/bml_connect/models/transaction.rb', line 13

def provider
  @provider
end

#redirectUrlObject

Returns the value of attribute redirectUrl.



13
14
15
# File 'lib/bml_connect/models/transaction.rb', line 13

def redirectUrl
  @redirectUrl
end

Instance Method Details

#to_hashObject



23
24
25
# File 'lib/bml_connect/models/transaction.rb', line 23

def to_hash()
  instance_variables.each_with_object({}) { |var, hash| hash[var.to_s.delete("@")] = instance_variable_get(var) }
end