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

#to_hash

Constructor Details

#initialize(incoming = {}) ⇒ FlatRateForm

Returns a new instance of FlatRateForm.



12638
12639
12640
12641
12642
12643
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 12638

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))
end

Instance Attribute Details

#price ⇒ Object (readonly)

Returns the value of attribute price.



12636
12637
12638
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 12636

def price
  @price
end

Instance Method Details

#copy(incoming = {}) ⇒ Object



12649
12650
12651
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 12649

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

#subtype_to_hash ⇒ Object



12653
12654
12655
12656
12657
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 12653

def subtype_to_hash
  {
    :price => price.to_hash
  }
end

#to_json ⇒ Object



12645
12646
12647
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 12645

def to_json
  JSON.dump(to_hash)
end