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.



13625
13626
13627
13628
13629
13630
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 13625

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

#priceObject (readonly)

Returns the value of attribute price.



13623
13624
13625
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 13623

def price
  @price
end

Instance Method Details

#copy(incoming = {}) ⇒ Object



13636
13637
13638
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 13636

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

#subtype_to_hashObject



13640
13641
13642
13643
13644
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 13640

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

#to_jsonObject



13632
13633
13634
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 13632

def to_json
  JSON.dump(to_hash)
end