Class: Io::Flow::V0::Models::Pricing

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

Overview

Pricing determines how the item price is calculated when items are requests via the experience.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(incoming = {}) ⇒ Pricing

Returns a new instance of Pricing.



18414
18415
18416
18417
18418
18419
18420
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 18414

def initialize(incoming={})
  opts = HttpClient::Helper.symbolize_keys(incoming)
  HttpClient::Preconditions.require_keys(opts, [:vat, :duty], 'Pricing')
  @vat = (x = opts.delete(:vat); x.is_a?(::Io::Flow::V0::Models::PricingLevySetting) ? x : ::Io::Flow::V0::Models::PricingLevySetting.apply(x))
  @duty = (x = opts.delete(:duty); x.is_a?(::Io::Flow::V0::Models::PricingLevySetting) ? x : ::Io::Flow::V0::Models::PricingLevySetting.apply(x))
  @rounding = (x = opts.delete(:rounding); x.nil? ? nil : (x = x; x.is_a?(::Io::Flow::V0::Models::Rounding) ? x : ::Io::Flow::V0::Models::Rounding.new(x)))
end

Instance Attribute Details

#duty ⇒ Object (readonly)

Returns the value of attribute duty.



18412
18413
18414
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 18412

def duty
  @duty
end

#rounding ⇒ Object (readonly)

Returns the value of attribute rounding.



18412
18413
18414
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 18412

def rounding
  @rounding
end

#vat ⇒ Object (readonly)

Returns the value of attribute vat.



18412
18413
18414
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 18412

def vat
  @vat
end

Instance Method Details

#copy(incoming = {}) ⇒ Object



18426
18427
18428
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 18426

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

#to_hash ⇒ Object



18430
18431
18432
18433
18434
18435
18436
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 18430

def to_hash
  {
    :vat => vat.value,
    :duty => duty.value,
    :rounding => rounding.nil? ? nil : rounding.to_hash
  }
end

#to_json ⇒ Object



18422
18423
18424
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 18422

def to_json
  JSON.dump(to_hash)
end