Class: Square::Connect::Refund

Inherits:
Node
  • Object
show all
Defined in:
lib/square/connect/refund.rb

Instance Attribute Summary collapse

Attributes inherited from Node

#access_token, #endpoint, #identifier

Instance Method Summary collapse

Methods inherited from Node

#fetch

Constructor Details

#initialize(*args) ⇒ Refund

Returns a new instance of Refund.



6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/square/connect/refund.rb', line 6

def initialize(*args)
  super do |attributes|
    self.type = attributes[:type]
    self.reason = attributes[:reason]
    self.refunded_money = if attributes[:refunded_money].present?
      Money.new attributes[:refunded_money]
    end
    [
      :created_at,
      :processed_at
    ].each do |time_key|
      if attributes[time_key]
        self.send "#{time_key}=", Time.parse(attributes[time_key])
      end
    end
    self.payment = attributes[:payment] || attributes[:payment_id] && Payment.new(attributes[:payment_id])
  end
end

Instance Attribute Details

#created_atObject

Returns the value of attribute created_at.



4
5
6
# File 'lib/square/connect/refund.rb', line 4

def created_at
  @created_at
end

#paymentObject

Returns the value of attribute payment.



4
5
6
# File 'lib/square/connect/refund.rb', line 4

def payment
  @payment
end

#processed_atObject

Returns the value of attribute processed_at.



4
5
6
# File 'lib/square/connect/refund.rb', line 4

def processed_at
  @processed_at
end

#reasonObject

Returns the value of attribute reason.



4
5
6
# File 'lib/square/connect/refund.rb', line 4

def reason
  @reason
end

#refunded_moneyObject

Returns the value of attribute refunded_money.



4
5
6
# File 'lib/square/connect/refund.rb', line 4

def refunded_money
  @refunded_money
end

#typeObject

Returns the value of attribute type.



4
5
6
# File 'lib/square/connect/refund.rb', line 4

def type
  @type
end