Class: Io::Flow::V0::Models::PriceDetails

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

Overview

Detailed information for the pricing of a given item within an experience.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(incoming = {}) ⇒ PriceDetails

Returns a new instance of PriceDetails.



22302
22303
22304
22305
22306
22307
22308
22309
22310
22311
22312
22313
22314
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 22302

def initialize(incoming={})
  opts = HttpClient::Helper.symbolize_keys(incoming)
  HttpClient::Preconditions.require_keys(opts, [:currency, :item_price, :margins, :vat, :duty, :rounding, :price, :total], 'PriceDetails')
  @currency = HttpClient::Preconditions.assert_class('currency', opts.delete(:currency), String)
  @item_price = (x = opts.delete(:item_price); x.is_a?(::Io::Flow::V0::Models::PriceDetail) ? x : ::Io::Flow::V0::Models::PriceDetail.new(x))
  @margins = (x = opts.delete(:margins); x.is_a?(::Io::Flow::V0::Models::PriceDetail) ? x : ::Io::Flow::V0::Models::PriceDetail.new(x))
  @vat = (x = opts.delete(:vat); x.is_a?(::Io::Flow::V0::Models::PriceDetail) ? x : ::Io::Flow::V0::Models::PriceDetail.new(x))
  @duty = (x = opts.delete(:duty); x.is_a?(::Io::Flow::V0::Models::PriceDetail) ? x : ::Io::Flow::V0::Models::PriceDetail.new(x))
  @rounding = (x = opts.delete(:rounding); x.is_a?(::Io::Flow::V0::Models::PriceDetail) ? x : ::Io::Flow::V0::Models::PriceDetail.new(x))
  @price = (x = opts.delete(:price); x.is_a?(::Io::Flow::V0::Models::Price) ? x : ::Io::Flow::V0::Models::Price.new(x))
  @total = (x = opts.delete(:total); x.is_a?(::Io::Flow::V0::Models::Price) ? x : ::Io::Flow::V0::Models::Price.new(x))
  @adjustment = (x = opts.delete(:adjustment); x.nil? ? nil : (x = x; x.is_a?(::Io::Flow::V0::Models::PriceDetail) ? x : ::Io::Flow::V0::Models::PriceDetail.new(x)))
end

Instance Attribute Details

#adjustmentObject (readonly)

Returns the value of attribute adjustment.



22300
22301
22302
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 22300

def adjustment
  @adjustment
end

#currencyObject (readonly)

Returns the value of attribute currency.



22300
22301
22302
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 22300

def currency
  @currency
end

#dutyObject (readonly)

Returns the value of attribute duty.



22300
22301
22302
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 22300

def duty
  @duty
end

#item_priceObject (readonly)

Returns the value of attribute item_price.



22300
22301
22302
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 22300

def item_price
  @item_price
end

#marginsObject (readonly)

Returns the value of attribute margins.



22300
22301
22302
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 22300

def margins
  @margins
end

#priceObject (readonly)

Returns the value of attribute price.



22300
22301
22302
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 22300

def price
  @price
end

#roundingObject (readonly)

Returns the value of attribute rounding.



22300
22301
22302
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 22300

def rounding
  @rounding
end

#totalObject (readonly)

Returns the value of attribute total.



22300
22301
22302
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 22300

def total
  @total
end

#vatObject (readonly)

Returns the value of attribute vat.



22300
22301
22302
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 22300

def vat
  @vat
end

Instance Method Details

#copy(incoming = {}) ⇒ Object



22320
22321
22322
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 22320

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

#to_hashObject



22324
22325
22326
22327
22328
22329
22330
22331
22332
22333
22334
22335
22336
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 22324

def to_hash
  {
    :currency => currency,
    :item_price => item_price.to_hash,
    :margins => margins.to_hash,
    :vat => vat.to_hash,
    :duty => duty.to_hash,
    :rounding => rounding.to_hash,
    :price => price.to_hash,
    :total => total.to_hash,
    :adjustment => adjustment.nil? ? nil : adjustment.to_hash
  }
end

#to_jsonObject



22316
22317
22318
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 22316

def to_json
  JSON.dump(to_hash)
end