Class: Io::Flow::V0::Models::OrderPriceDetails

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

Overview

Represents the price details for the entire order.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(incoming = {}) ⇒ OrderPriceDetails

Returns a new instance of OrderPriceDetails.



13098
13099
13100
13101
13102
13103
13104
13105
13106
13107
13108
13109
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 13098

def initialize(incoming={})
  opts = HttpClient::Helper.symbolize_keys(incoming)
  HttpClient::Preconditions.require_keys(opts, [:subtotal, :vat, :duty, :shipping, :insurance, :discounts, :adjustments, :total], 'OrderPriceDetails')
  @subtotal = (x = opts.delete(:subtotal); x.is_a?(::Io::Flow::V0::Models::OrderPriceDetail) ? x : ::Io::Flow::V0::Models::OrderPriceDetail.new(x))
  @vat = (x = opts.delete(:vat); x.is_a?(::Io::Flow::V0::Models::OrderPriceDetail) ? x : ::Io::Flow::V0::Models::OrderPriceDetail.new(x))
  @duty = (x = opts.delete(:duty); x.is_a?(::Io::Flow::V0::Models::OrderPriceDetail) ? x : ::Io::Flow::V0::Models::OrderPriceDetail.new(x))
  @shipping = (x = opts.delete(:shipping); x.is_a?(::Io::Flow::V0::Models::OrderPriceDetail) ? x : ::Io::Flow::V0::Models::OrderPriceDetail.new(x))
  @insurance = (x = opts.delete(:insurance); x.is_a?(::Io::Flow::V0::Models::OrderPriceDetail) ? x : ::Io::Flow::V0::Models::OrderPriceDetail.new(x))
  @discounts = (x = opts.delete(:discounts); x.is_a?(::Io::Flow::V0::Models::OrderPriceDetail) ? x : ::Io::Flow::V0::Models::OrderPriceDetail.new(x))
  @adjustments = (x = opts.delete(:adjustments); x.is_a?(::Io::Flow::V0::Models::OrderPriceDetail) ? x : ::Io::Flow::V0::Models::OrderPriceDetail.new(x))
  @total = (x = opts.delete(:total); x.is_a?(::Io::Flow::V0::Models::PriceWithBase) ? x : ::Io::Flow::V0::Models::PriceWithBase.new(x))
end

Instance Attribute Details

#adjustmentsObject (readonly)

Returns the value of attribute adjustments.



13096
13097
13098
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 13096

def adjustments
  @adjustments
end

#discountsObject (readonly)

Returns the value of attribute discounts.



13096
13097
13098
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 13096

def discounts
  @discounts
end

#dutyObject (readonly)

Returns the value of attribute duty.



13096
13097
13098
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 13096

def duty
  @duty
end

#insuranceObject (readonly)

Returns the value of attribute insurance.



13096
13097
13098
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 13096

def insurance
  @insurance
end

#shippingObject (readonly)

Returns the value of attribute shipping.



13096
13097
13098
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 13096

def shipping
  @shipping
end

#subtotalObject (readonly)

Returns the value of attribute subtotal.



13096
13097
13098
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 13096

def subtotal
  @subtotal
end

#totalObject (readonly)

Returns the value of attribute total.



13096
13097
13098
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 13096

def total
  @total
end

#vatObject (readonly)

Returns the value of attribute vat.



13096
13097
13098
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 13096

def vat
  @vat
end

Instance Method Details

#copy(incoming = {}) ⇒ Object



13115
13116
13117
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 13115

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

#to_hashObject



13119
13120
13121
13122
13123
13124
13125
13126
13127
13128
13129
13130
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 13119

def to_hash
  {
    :subtotal => subtotal.to_hash,
    :vat => vat.to_hash,
    :duty => duty.to_hash,
    :shipping => shipping.to_hash,
    :insurance => insurance.to_hash,
    :discounts => discounts.to_hash,
    :adjustments => adjustments.to_hash,
    :total => total.to_hash
  }
end

#to_jsonObject



13111
13112
13113
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 13111

def to_json
  JSON.dump(to_hash)
end