Class: Io::Flow::V0::Models::FlatRate

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

Overview

Rule outcome where shipping surfaced in quote is pre-defined flat rate

Instance Attribute Summary collapse

Attributes inherited from TierRuleOutcome

#discriminator

Instance Method Summary collapse

Methods inherited from TierRuleOutcome

from_json, #to_hash

Constructor Details

#initialize(incoming = {}) ⇒ FlatRate

Returns a new instance of FlatRate.



28657
28658
28659
28660
28661
28662
28663
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 28657

def initialize(incoming={})
  super(:discriminator => TierRuleOutcome::Types::FLAT_RATE)
  opts = HttpClient::Helper.symbolize_keys(incoming)
  HttpClient::Preconditions.require_keys(opts, [:price], 'FlatRate')
  @price = (x = opts.delete(:price); x.is_a?(::Io::Flow::V0::Models::Price) ? x : ::Io::Flow::V0::Models::Price.new(x))
  @zero_amount_indicator = (x = opts.delete(:zero_amount_indicator); x.nil? ? nil : (x = x; x.is_a?(::Io::Flow::V0::Models::ZeroAmountIndicator) ? x : ::Io::Flow::V0::Models::ZeroAmountIndicator.apply(x)))
end

Instance Attribute Details

#priceObject (readonly)

Returns the value of attribute price.



28655
28656
28657
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 28655

def price
  @price
end

#zero_amount_indicatorObject (readonly)

Returns the value of attribute zero_amount_indicator.



28655
28656
28657
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 28655

def zero_amount_indicator
  @zero_amount_indicator
end

Instance Method Details

#copy(incoming = {}) ⇒ Object



28669
28670
28671
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 28669

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

#subtype_to_hashObject



28673
28674
28675
28676
28677
28678
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 28673

def subtype_to_hash
  {
    :price => price.to_hash,
    :zero_amount_indicator => zero_amount_indicator.nil? ? nil : zero_amount_indicator.value
  }
end

#to_jsonObject



28665
28666
28667
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 28665

def to_json
  JSON.dump(to_hash)
end