Class: Io::Flow::V0::Models::FreeShippingOrderPromotion

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

Instance Attribute Summary collapse

Attributes inherited from OrderPromotion

#discriminator

Instance Method Summary collapse

Methods inherited from OrderPromotion

from_json, #to_hash

Constructor Details

#initialize(incoming = {}) ⇒ FreeShippingOrderPromotion

Returns a new instance of FreeShippingOrderPromotion.



40308
40309
40310
40311
40312
40313
40314
40315
40316
40317
40318
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 40308

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

Instance Attribute Details

#attributesObject (readonly)

Returns the value of attribute attributes.



40306
40307
40308
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 40306

def attributes
  @attributes
end

#idObject (readonly)

Returns the value of attribute id.



40306
40307
40308
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 40306

def id
  @id
end

#keyObject (readonly)

Returns the value of attribute key.



40306
40307
40308
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 40306

def key
  @key
end

#maxObject (readonly)

Returns the value of attribute max.



40306
40307
40308
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 40306

def max
  @max
end

#orderObject (readonly)

Returns the value of attribute order.



40306
40307
40308
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 40306

def order
  @order
end

#triggerObject (readonly)

Returns the value of attribute trigger.



40306
40307
40308
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 40306

def trigger
  @trigger
end

Instance Method Details

#copy(incoming = {}) ⇒ Object



40324
40325
40326
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 40324

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

#subtype_to_hashObject



40328
40329
40330
40331
40332
40333
40334
40335
40336
40337
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 40328

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_jsonObject



40320
40321
40322
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 40320

def to_json
  JSON.dump(to_hash)
end