Class: Io::Flow::V0::Models::RefundCapture

Inherits:
Object
  • Object
show all
Defined in:
lib/flow_commerce/flow_api_v0_client.rb

Overview

Refund captures provide the detailed information on the amount refunded against a specific capture

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(incoming = {}) ⇒ RefundCapture

Returns a new instance of RefundCapture.



28671
28672
28673
28674
28675
28676
28677
28678
28679
28680
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 28671

def initialize(incoming={})
  opts = HttpClient::Helper.symbolize_keys(incoming)
  HttpClient::Preconditions.require_keys(opts, [:id, :refund, :capture, :amount, :currency, :base], 'RefundCapture')
  @id = HttpClient::Preconditions.assert_class('id', opts.delete(:id), String)
  @refund = (x = opts.delete(:refund); x.is_a?(::Io::Flow::V0::Models::Refund) ? x : ::Io::Flow::V0::Models::Refund.new(x))
  @capture = (x = opts.delete(:capture); x.is_a?(::Io::Flow::V0::Models::Capture) ? x : ::Io::Flow::V0::Models::Capture.new(x))
  @amount = HttpClient::Preconditions.assert_class('amount', HttpClient::Helper.to_big_decimal(opts.delete(:amount)), BigDecimal)
  @currency = HttpClient::Preconditions.assert_class('currency', opts.delete(:currency), String)
  @base = (x = opts.delete(:base); x.is_a?(::Io::Flow::V0::Models::Money) ? x : ::Io::Flow::V0::Models::Money.new(x))
end

Instance Attribute Details

#amountObject (readonly)

Returns the value of attribute amount.



28669
28670
28671
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 28669

def amount
  @amount
end

#baseObject (readonly)

Returns the value of attribute base.



28669
28670
28671
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 28669

def base
  @base
end

#captureObject (readonly)

Returns the value of attribute capture.



28669
28670
28671
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 28669

def capture
  @capture
end

#currencyObject (readonly)

Returns the value of attribute currency.



28669
28670
28671
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 28669

def currency
  @currency
end

#idObject (readonly)

Returns the value of attribute id.



28669
28670
28671
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 28669

def id
  @id
end

#refundObject (readonly)

Returns the value of attribute refund.



28669
28670
28671
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 28669

def refund
  @refund
end

Instance Method Details

#copy(incoming = {}) ⇒ Object



28686
28687
28688
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 28686

def copy(incoming={})
  RefundCapture.new(to_hash.merge(HttpClient::Helper.symbolize_keys(incoming)))
end

#to_hashObject



28690
28691
28692
28693
28694
28695
28696
28697
28698
28699
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 28690

def to_hash
  {
    :id => id,
    :refund => refund.to_hash,
    :capture => capture.to_hash,
    :amount => amount,
    :currency => currency,
    :base => base.to_hash
  }
end

#to_jsonObject



28682
28683
28684
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 28682

def to_json
  JSON.dump(to_hash)
end