Class: Io::Flow::V0::Models::OrderRefundSummaryAmounts

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

Overview

Detailed examples of amount to refund following common e-commerce use cases.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(incoming = {}) ⇒ OrderRefundSummaryAmounts

Returns a new instance of OrderRefundSummaryAmounts.



49825
49826
49827
49828
49829
49830
49831
49832
49833
49834
49835
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 49825

def initialize(incoming={})
  opts = HttpClient::Helper.symbolize_keys(incoming)
  HttpClient::Preconditions.require_keys(opts, [:balance, :item_subtotal, :refund_total, :shipping, :vat, :duty], 'OrderRefundSummaryAmounts')
  @balance = HttpClient::Preconditions.assert_class('balance', HttpClient::Helper.to_big_decimal(opts.delete(:balance)), BigDecimal)
  @item_subtotal = HttpClient::Preconditions.assert_class('item_subtotal', HttpClient::Helper.to_big_decimal(opts.delete(:item_subtotal)), BigDecimal)
  @discount = (x = opts.delete(:discount); x.nil? ? nil : HttpClient::Preconditions.assert_class('discount', HttpClient::Helper.to_big_decimal(x), BigDecimal))
  @refund_total = HttpClient::Preconditions.assert_class('refund_total', HttpClient::Helper.to_big_decimal(opts.delete(:refund_total)), BigDecimal)
  @shipping = HttpClient::Preconditions.assert_class('shipping', HttpClient::Helper.to_big_decimal(opts.delete(:shipping)), BigDecimal)
  @vat = HttpClient::Preconditions.assert_class('vat', HttpClient::Helper.to_big_decimal(opts.delete(:vat)), BigDecimal)
  @duty = HttpClient::Preconditions.assert_class('duty', HttpClient::Helper.to_big_decimal(opts.delete(:duty)), BigDecimal)
end

Instance Attribute Details

#balanceObject (readonly)

Returns the value of attribute balance.



49823
49824
49825
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 49823

def balance
  @balance
end

#discountObject (readonly)

Returns the value of attribute discount.



49823
49824
49825
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 49823

def discount
  @discount
end

#dutyObject (readonly)

Returns the value of attribute duty.



49823
49824
49825
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 49823

def duty
  @duty
end

#item_subtotalObject (readonly)

Returns the value of attribute item_subtotal.



49823
49824
49825
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 49823

def item_subtotal
  @item_subtotal
end

#refund_totalObject (readonly)

Returns the value of attribute refund_total.



49823
49824
49825
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 49823

def refund_total
  @refund_total
end

#shippingObject (readonly)

Returns the value of attribute shipping.



49823
49824
49825
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 49823

def shipping
  @shipping
end

#vatObject (readonly)

Returns the value of attribute vat.



49823
49824
49825
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 49823

def vat
  @vat
end

Instance Method Details

#copy(incoming = {}) ⇒ Object



49841
49842
49843
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 49841

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

#to_hashObject



49845
49846
49847
49848
49849
49850
49851
49852
49853
49854
49855
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 49845

def to_hash
  {
    :balance => balance.to_f.to_s,
    :item_subtotal => item_subtotal.to_f.to_s,
    :discount => discount.to_f.to_s,
    :refund_total => refund_total.to_f.to_s,
    :shipping => shipping.to_f.to_s,
    :vat => vat.to_f.to_s,
    :duty => duty.to_f.to_s
  }
end

#to_jsonObject



49837
49838
49839
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 49837

def to_json
  JSON.dump(to_hash)
end