Class: Io::Flow::V0::Models::FreeShippingOrderPromotionForm

Inherits:
OrderPromotionForm show all
Defined in:
lib/flow_commerce/flow_api_v0_client.rb

Instance Attribute Summary collapse

Attributes inherited from OrderPromotionForm

#discriminator

Instance Method Summary collapse

Methods inherited from OrderPromotionForm

from_json, #to_hash

Constructor Details

#initialize(incoming = {}) ⇒ FreeShippingOrderPromotionForm

Returns a new instance of FreeShippingOrderPromotionForm.



38530
38531
38532
38533
38534
38535
38536
38537
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 38530

def initialize(incoming={})
  super(:discriminator => OrderPromotionForm::Types::FREE_SHIPPING_ORDER_PROMOTION_FORM)
  opts = HttpClient::Helper.symbolize_keys(incoming)
  HttpClient::Preconditions.require_keys(opts, [:trigger], 'FreeShippingOrderPromotionForm')
  @trigger = (x = opts.delete(:trigger); x.is_a?(::Io::Flow::V0::Models::PromotionTriggerForm) ? x : ::Io::Flow::V0::Models::PromotionTriggerForm.new(x))
  @max = (x = opts.delete(:max); x.nil? ? nil : (x = x; x.is_a?(::Io::Flow::V0::Models::PriceForm) ? x : ::Io::Flow::V0::Models::PriceForm.new(x)))
  @attributes = (x = opts.delete(:attributes); x.nil? ? nil : HttpClient::Preconditions.assert_class('attributes', x, 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.



38528
38529
38530
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 38528

def attributes
  @attributes
end

#maxObject (readonly)

Returns the value of attribute max.



38528
38529
38530
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 38528

def max
  @max
end

#triggerObject (readonly)

Returns the value of attribute trigger.



38528
38529
38530
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 38528

def trigger
  @trigger
end

Instance Method Details

#copy(incoming = {}) ⇒ Object



38543
38544
38545
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 38543

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

#subtype_to_hashObject



38547
38548
38549
38550
38551
38552
38553
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 38547

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

#to_jsonObject



38539
38540
38541
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 38539

def to_json
  JSON.dump(to_hash)
end