class Io::Flow::V0::Models::FreeShippingOrderPromotion

Attributes

attributes[R]
id[R]
key[R]
max[R]
order[R]
trigger[R]

Public Class Methods

new(incoming={}) click to toggle source
# File lib/flow_commerce/flow_api_v0_client.rb, line 43527
def initialize(incoming={})
  super(:discriminator => OrderPromotion::Types::FREE_SHIPPING_ORDER_PROMOTION)
  opts = HttpClient::Helper.symbolize_keys(incoming)
  HttpClient::Preconditions.require_keys(opts, [:id, :order, :key, :trigger, :attributes], 'FreeShippingOrderPromotion')
  @id = HttpClient::Preconditions.assert_class('id', opts.delete(:id), String)
  @order = (x = opts.delete(:order); x.is_a?(::Io::Flow::V0::Models::ExpandableOrder) ? x : ::Io::Flow::V0::Models::ExpandableOrder.from_json(x))
  @key = HttpClient::Preconditions.assert_class('key', opts.delete(:key), String)
  @trigger = (x = opts.delete(:trigger); x.is_a?(::Io::Flow::V0::Models::OrderPromotionTrigger) ? x : ::Io::Flow::V0::Models::OrderPromotionTrigger.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)))
  @attributes = HttpClient::Preconditions.assert_class('attributes', opts.delete(:attributes), Hash).inject({}) { |h, d| h[d[0]] = HttpClient::Preconditions.assert_class('attributes', d[1], String); h }
end

Public Instance Methods

copy(incoming={}) click to toggle source
# File lib/flow_commerce/flow_api_v0_client.rb, line 43543
def copy(incoming={})
  FreeShippingOrderPromotion.new(subtype_to_hash.merge(HttpClient::Helper.symbolize_keys(incoming)))
end
subtype_to_hash() click to toggle source
# File lib/flow_commerce/flow_api_v0_client.rb, line 43547
def subtype_to_hash
  {
    :id => id,
    :order => order.to_hash,
    :key => key,
    :trigger => trigger.to_hash,
    :max => max.nil? ? nil : max.to_hash,
    :attributes => attributes
  }
end
to_json() click to toggle source
# File lib/flow_commerce/flow_api_v0_client.rb, line 43539
def to_json
  JSON.dump(to_hash)
end