Class: Io::Flow::V0::Models::FlatRate
- Inherits:
-
TierRuleOutcome
- Object
- TierRuleOutcome
- Io::Flow::V0::Models::FlatRate
- 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
-
#price ⇒ Object
readonly
Returns the value of attribute price.
-
#zero_amount_indicator ⇒ Object
readonly
Returns the value of attribute zero_amount_indicator.
Attributes inherited from TierRuleOutcome
Instance Method Summary collapse
- #copy(incoming = {}) ⇒ Object
-
#initialize(incoming = {}) ⇒ FlatRate
constructor
A new instance of FlatRate.
- #subtype_to_hash ⇒ Object
- #to_json ⇒ Object
Methods inherited from TierRuleOutcome
Constructor Details
#initialize(incoming = {}) ⇒ FlatRate
Returns a new instance of FlatRate.
43237 43238 43239 43240 43241 43242 43243 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 43237 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
#price ⇒ Object (readonly)
Returns the value of attribute price.
43235 43236 43237 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 43235 def price @price end |
#zero_amount_indicator ⇒ Object (readonly)
Returns the value of attribute zero_amount_indicator.
43235 43236 43237 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 43235 def zero_amount_indicator @zero_amount_indicator end |
Instance Method Details
#copy(incoming = {}) ⇒ Object
43249 43250 43251 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 43249 def copy(incoming={}) FlatRate.new(subtype_to_hash.merge(HttpClient::Helper.symbolize_keys(incoming))) end |
#subtype_to_hash ⇒ Object
43253 43254 43255 43256 43257 43258 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 43253 def subtype_to_hash { :price => price.to_hash, :zero_amount_indicator => zero_amount_indicator.nil? ? nil : zero_amount_indicator.value } end |
#to_json ⇒ Object
43245 43246 43247 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 43245 def to_json JSON.dump(to_hash) end |