Class: Io::Flow::V0::Models::FreeShipping

Inherits:
Promotion
  • Object
show all
Defined in:
lib/flow_commerce/flow_api_v0_client.rb

Instance Attribute Summary collapse

Attributes inherited from Promotion

#discriminator

Instance Method Summary collapse

Methods inherited from Promotion

from_json, #to_hash

Constructor Details

#initialize(incoming = {}) ⇒ FreeShipping



32959
32960
32961
32962
32963
32964
32965
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 32959

def initialize(incoming={})
  super(:discriminator => Promotion::Types::FREE_SHIPPING)
  opts = HttpClient::Helper.symbolize_keys(incoming)
  HttpClient::Preconditions.require_keys(opts, [:trigger], 'FreeShipping')
  @trigger = (x = opts.delete(:trigger); x.is_a?(::Io::Flow::V0::Models::PromotionTrigger) ? x : ::Io::Flow::V0::Models::PromotionTrigger.new(x))
  @max = (x = opts.delete(:max); x.nil? ? nil : (x = x; x.is_a?(::Io::Flow::V0::Models::Price) ? x : ::Io::Flow::V0::Models::Price.new(x)))
end

Instance Attribute Details

#maxObject (readonly)

Returns the value of attribute max.



32957
32958
32959
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 32957

def max
  @max
end

#triggerObject (readonly)

Returns the value of attribute trigger.



32957
32958
32959
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 32957

def trigger
  @trigger
end

Instance Method Details

#copy(incoming = {}) ⇒ Object



32971
32972
32973
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 32971

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

#subtype_to_hashObject



32975
32976
32977
32978
32979
32980
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 32975

def subtype_to_hash
  {
    :trigger => trigger.to_hash,
    :max => max.nil? ? nil : max.to_hash
  }
end

#to_jsonObject



32967
32968
32969
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 32967

def to_json
  JSON.dump(to_hash)
end