class EwayRapid::InternalModels::Transaction

Attributes

authorisation_code[RW]
beagle_score[RW]
beagle_verification[RW]
currency_code[RW]
customer[RW]
customer_note[RW]
errors[RW]
fraud_action[RW]
invoice_number[RW]
invoice_reference[RW]
max_refund[RW]
options[RW]
original_transaction_id[RW]
response_code[RW]
response_message[RW]
shipping_address[RW]
source[RW]
token_customer_id[RW]
total_amount[RW]
transaction_captured[RW]
transaction_date_time[RW]
transaction_id[RW]
transaction_status[RW]
verification[RW]

Public Class Methods

from_array(array) click to toggle source
# File lib/eway_rapid/models/internal_models.rb, line 408
def self.from_array(array)
  transactions = []
  array.each {|transaction_hash|
    obj = from_hash(transaction_hash)
    transactions.push(obj)
  }
  transactions
end
from_hash(hash) click to toggle source
# File lib/eway_rapid/models/internal_models.rb, line 379
def self.from_hash(hash)
  transaction = Transaction.new
  transaction.customer_note = hash[Constants::CUSTOMER_NOTE]
  transaction.authorisation_code = hash[Constants::AUTHORISATION_CODE]
  transaction.response_code = hash[Constants::RESPONSE_CODE]
  transaction.response_message = hash[Constants::RESPONSE_MESSAGE]
  transaction.invoice_number = hash[Constants::INVOICE_NUMBER]
  transaction.invoice_reference = hash[Constants::INVOICE_REFERENCE]
  transaction.total_amount = hash[Constants::TOTAL_AMOUNT]
  transaction.transaction_id = hash[Constants::TRANSACTION_ID]
  transaction.transaction_status = hash[Constants::TRANSACTION_STATUS]
  transaction.token_customer_id = hash[Constants::TOKEN_CUSTOMER_ID]
  transaction.beagle_score = hash[Constants::BEAGLE_SCORE]
  transaction.options = Option.from_array(hash[Constants::OPTIONS])
  transaction.verification = Verification.from_hash(hash[Constants::VERIFICATION])
  transaction.customer = Customer.from_hash(hash[Constants::CUSTOMER])
  transaction.shipping_address = ShippingAddress.from_hash(hash[Constants::SHIPPING_ADDRESS])
  transaction.beagle_verification = BeagleVerification.from_hash(hash[Constants::BEAGLE_VERIFICATION])
  transaction.transaction_date_time = hash[Constants::TRANSACTION_DATE]
  transaction.transaction_captured = hash[Constants::TRANSACTION_CAPTURED]
  transaction.source = hash[Constants::SOURCE]
  transaction.max_refund = hash[Constants::MAX_REFUND]
  transaction.original_transaction_id = hash[Constants::ORIGINAL_TRANSACTION]
  transaction.fraud_action = hash[Constants::FRAUD_ACTION]
  transaction.currency_code = hash[Constants::CURRENCY_CODE]
  transaction.errors = hash[Constants::ERRORS]
  transaction
end
from_json(json) click to toggle source
# File lib/eway_rapid/models/internal_models.rb, line 374
def self.from_json(json)
  hash = JSON.parse(json)
  from_hash(hash)
end

Public Instance Methods

to_json(opts={}) click to toggle source
# File lib/eway_rapid/models/internal_models.rb, line 346
def to_json(opts={})
  hash = {}
  hash[Constants::CUSTOMER_NOTE] = customer_note if customer_note
  hash[Constants::AUTHORISATION_CODE] = authorisation_code if authorisation_code
  hash[Constants::RESPONSE_CODE] = response_code if response_code
  hash[Constants::RESPONSE_MESSAGE] = response_message if response_message
  hash[Constants::INVOICE_NUMBER] = invoice_number if invoice_number
  hash[Constants::INVOICE_REFERENCE] = invoice_reference if invoice_reference
  hash[Constants::TOTAL_AMOUNT] = total_amount if total_amount
  hash[Constants::TRANSACTION_ID] = transaction_id if transaction_id
  hash[Constants::TRANSACTION_STATUS] = transaction_status if transaction_status
  hash[Constants::TOKEN_CUSTOMER_ID] = token_customer_id if token_customer_id
  hash[Constants::BEAGLE_SCORE] = beagle_score if beagle_score
  hash[Constants::OPTIONS] = options if options
  hash[Constants::VERIFICATION] = verification if verification
  hash[Constants::CUSTOMER] = customer if customer
  hash[Constants::SHIPPING_ADDRESS] = shipping_address if shipping_address
  hash[Constants::TRANSACTION_DATE] = transaction_date_time if transaction_date_time
  hash[Constants::TRANSACTION_CAPTURED] = transaction_captured if transaction_captured
  hash[Constants::SOURCE] = source if source
  hash[Constants::MAX_REFUND] = max_refund if max_refund
  hash[Constants::ORIGINAL_TRANSACTION] = original_transaction_id if original_transaction_id
  hash[Constants::FRAUD_ACTION] = fraud_action if fraud_action
  hash[Constants::CURRENCY_CODE] = currency_code if currency_code
  hash[Constants::ERRORS] = errors if errors
  hash.to_json
end