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.



16046
16047
16048
16049
16050
16051
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 16046

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

Instance Attribute Details

#priceObject (readonly)

Returns the value of attribute price.



16044
16045
16046
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 16044

def price
  @price
end

Instance Method Details

#copy(incoming = {}) ⇒ Object



16057
16058
16059
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 16057

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

#subtype_to_hashObject



16061
16062
16063
16064
16065
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 16061

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

#to_jsonObject



16053
16054
16055
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 16053

def to_json
  JSON.dump(to_hash)
end