Class: Afterpay::PaymentEvent

Inherits:
Object
  • Object
show all
Defined in:
lib/afterpay/payment_event.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(attributes = {}) ⇒ PaymentEvent

Returns a new instance of PaymentEvent.



7
8
9
10
11
12
13
14
# File 'lib/afterpay/payment_event.rb', line 7

def initialize(attributes = {})
  @id = attributes[:id] || ""
  @created = attributes[:created] || ""
  @expires = attributes[:expires] || ""
  @type = attributes[:type] || ""
  @amount = attributes[:amount] || Money.from_amount(0)
  @payment_event_merchant_reference = attributes[:payment_event_merchant_reference] || ""
end

Instance Attribute Details

#amountObject

Returns the value of attribute amount.



5
6
7
# File 'lib/afterpay/payment_event.rb', line 5

def amount
  @amount
end

#createdObject

Returns the value of attribute created.



5
6
7
# File 'lib/afterpay/payment_event.rb', line 5

def created
  @created
end

#expiresObject

Returns the value of attribute expires.



5
6
7
# File 'lib/afterpay/payment_event.rb', line 5

def expires
  @expires
end

#idObject

Returns the value of attribute id.



5
6
7
# File 'lib/afterpay/payment_event.rb', line 5

def id
  @id
end

#payment_event_merchant_referenceObject

Returns the value of attribute payment_event_merchant_reference.



5
6
7
# File 'lib/afterpay/payment_event.rb', line 5

def payment_event_merchant_reference
  @payment_event_merchant_reference
end

#typeObject

Returns the value of attribute type.



5
6
7
# File 'lib/afterpay/payment_event.rb', line 5

def type
  @type
end

Class Method Details

.from_response(response) ⇒ Object

Builds PaymentEvent from response



17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/afterpay/payment_event.rb', line 17

def self.from_response(response)
  return nil if response.nil?

  new(
    id: response[:id],
    created: response[:created],
    expires: response[:expires],
    type: response[:type],
    amount: Utils::Money.from_response(response[:amount]),
    payment_event_merchant_reference: response[:paymentEventMerchantReference]
  )
end