Class: Io::Flow::V0::Models::FlatRateForm

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

Instance Attribute Summary collapse

Attributes inherited from TierRuleOutcomeForm

#discriminator

Instance Method Summary collapse

Methods inherited from TierRuleOutcomeForm

from_json, #to_hash

Constructor Details

#initialize(incoming = {}) ⇒ FlatRateForm

Returns a new instance of FlatRateForm.



28686
28687
28688
28689
28690
28691
28692
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 28686

def initialize(incoming={})
  super(:discriminator => TierRuleOutcomeForm::Types::FLAT_RATE_FORM)
  opts = HttpClient::Helper.symbolize_keys(incoming)
  HttpClient::Preconditions.require_keys(opts, [:price], 'FlatRateForm')
  @price = (x = opts.delete(:price); x.is_a?(::Io::Flow::V0::Models::Money) ? x : ::Io::Flow::V0::Models::Money.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.



28684
28685
28686
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 28684

def price
  @price
end

#zero_amount_indicatorObject (readonly)

Returns the value of attribute zero_amount_indicator.



28684
28685
28686
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 28684

def zero_amount_indicator
  @zero_amount_indicator
end

Instance Method Details

#copy(incoming = {}) ⇒ Object



28698
28699
28700
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 28698

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

#subtype_to_hashObject



28702
28703
28704
28705
28706
28707
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 28702

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

#to_jsonObject



28694
28695
28696
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 28694

def to_json
  JSON.dump(to_hash)
end