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.



24091
24092
24093
24094
24095
24096
24097
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 24091

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

#dutyObject (readonly)

Returns the value of attribute duty.



24089
24090
24091
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 24089

def duty
  @duty
end

#roundingObject (readonly)

Returns the value of attribute rounding.



24089
24090
24091
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 24089

def rounding
  @rounding
end

#vatObject (readonly)

Returns the value of attribute vat.



24089
24090
24091
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 24089

def vat
  @vat
end

Instance Method Details

#copy(incoming = {}) ⇒ Object



24103
24104
24105
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 24103

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

#to_hashObject



24107
24108
24109
24110
24111
24112
24113
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 24107

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

#to_jsonObject



24099
24100
24101
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 24099

def to_json
  JSON.dump(to_hash)
end