Class: EwayRapid::InternalModels::Transaction

Inherits:
Object
  • Object
show all
Defined in:
lib/eway_rapid/models/internal_models.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#authorisation_codeObject

Returns the value of attribute authorisation_code.



322
323
324
# File 'lib/eway_rapid/models/internal_models.rb', line 322

def authorisation_code
  @authorisation_code
end

#beagle_scoreObject

Returns the value of attribute beagle_score.



331
332
333
# File 'lib/eway_rapid/models/internal_models.rb', line 331

def beagle_score
  @beagle_score
end

#beagle_verificationObject

Returns the value of attribute beagle_verification.



336
337
338
# File 'lib/eway_rapid/models/internal_models.rb', line 336

def beagle_verification
  @beagle_verification
end

#currency_codeObject

Returns the value of attribute currency_code.



343
344
345
# File 'lib/eway_rapid/models/internal_models.rb', line 343

def currency_code
  @currency_code
end

#customerObject

Returns the value of attribute customer.



334
335
336
# File 'lib/eway_rapid/models/internal_models.rb', line 334

def customer
  @customer
end

#customer_noteObject

Returns the value of attribute customer_note.



321
322
323
# File 'lib/eway_rapid/models/internal_models.rb', line 321

def customer_note
  @customer_note
end

#errorsObject

Returns the value of attribute errors.



344
345
346
# File 'lib/eway_rapid/models/internal_models.rb', line 344

def errors
  @errors
end

#fraud_actionObject

Returns the value of attribute fraud_action.



342
343
344
# File 'lib/eway_rapid/models/internal_models.rb', line 342

def fraud_action
  @fraud_action
end

#invoice_numberObject

Returns the value of attribute invoice_number.



325
326
327
# File 'lib/eway_rapid/models/internal_models.rb', line 325

def invoice_number
  @invoice_number
end

#invoice_referenceObject

Returns the value of attribute invoice_reference.



326
327
328
# File 'lib/eway_rapid/models/internal_models.rb', line 326

def invoice_reference
  @invoice_reference
end

#max_refundObject

Returns the value of attribute max_refund.



340
341
342
# File 'lib/eway_rapid/models/internal_models.rb', line 340

def max_refund
  @max_refund
end

#optionsObject

Returns the value of attribute options.



332
333
334
# File 'lib/eway_rapid/models/internal_models.rb', line 332

def options
  @options
end

#original_transaction_idObject

Returns the value of attribute original_transaction_id.



341
342
343
# File 'lib/eway_rapid/models/internal_models.rb', line 341

def original_transaction_id
  @original_transaction_id
end

#response_codeObject

Returns the value of attribute response_code.



323
324
325
# File 'lib/eway_rapid/models/internal_models.rb', line 323

def response_code
  @response_code
end

#response_messageObject

Returns the value of attribute response_message.



324
325
326
# File 'lib/eway_rapid/models/internal_models.rb', line 324

def response_message
  @response_message
end

#shipping_addressObject

Returns the value of attribute shipping_address.



335
336
337
# File 'lib/eway_rapid/models/internal_models.rb', line 335

def shipping_address
  @shipping_address
end

#sourceObject

Returns the value of attribute source.



339
340
341
# File 'lib/eway_rapid/models/internal_models.rb', line 339

def source
  @source
end

#token_customer_idObject

Returns the value of attribute token_customer_id.



330
331
332
# File 'lib/eway_rapid/models/internal_models.rb', line 330

def token_customer_id
  @token_customer_id
end

#total_amountObject

Returns the value of attribute total_amount.



327
328
329
# File 'lib/eway_rapid/models/internal_models.rb', line 327

def total_amount
  @total_amount
end

#transaction_capturedObject

Returns the value of attribute transaction_captured.



338
339
340
# File 'lib/eway_rapid/models/internal_models.rb', line 338

def transaction_captured
  @transaction_captured
end

#transaction_date_timeObject

Returns the value of attribute transaction_date_time.



337
338
339
# File 'lib/eway_rapid/models/internal_models.rb', line 337

def transaction_date_time
  @transaction_date_time
end

#transaction_idObject

Returns the value of attribute transaction_id.



328
329
330
# File 'lib/eway_rapid/models/internal_models.rb', line 328

def transaction_id
  @transaction_id
end

#transaction_statusObject

Returns the value of attribute transaction_status.



329
330
331
# File 'lib/eway_rapid/models/internal_models.rb', line 329

def transaction_status
  @transaction_status
end

#verificationObject

Returns the value of attribute verification.



333
334
335
# File 'lib/eway_rapid/models/internal_models.rb', line 333

def verification
  @verification
end

Class Method Details

.from_array(array) ⇒ Object



408
409
410
411
412
413
414
415
# 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) ⇒ Object



379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
# 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) ⇒ Object



374
375
376
377
# File 'lib/eway_rapid/models/internal_models.rb', line 374

def self.from_json(json)
  hash = JSON.parse(json)
  from_hash(hash)
end

Instance Method Details

#to_json(opts = {}) ⇒ Object



346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
# 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