Class: Io::Flow::V0::Models::OrderWithDiscountsForm

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(incoming = {}) ⇒ OrderWithDiscountsForm

Returns a new instance of OrderWithDiscountsForm.



50707
50708
50709
50710
50711
50712
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 50707

def initialize(incoming={})
  opts = HttpClient::Helper.symbolize_keys(incoming)
  HttpClient::Preconditions.require_keys(opts, [:order], 'OrderWithDiscountsForm')
  @order = (x = opts.delete(:order); x.is_a?(::Io::Flow::V0::Models::OrderForm) ? x : ::Io::Flow::V0::Models::OrderForm.new(x))
  @discounts = HttpClient::Preconditions.assert_class('discounts', (x = opts.delete(:discounts); x.nil? ? [] : x), Array).map { |v| HttpClient::Preconditions.assert_class('discounts', v, String) }
end

Instance Attribute Details

#discountsObject (readonly)

Returns the value of attribute discounts.



50705
50706
50707
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 50705

def discounts
  @discounts
end

#orderObject (readonly)

Returns the value of attribute order.



50705
50706
50707
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 50705

def order
  @order
end

Instance Method Details

#copy(incoming = {}) ⇒ Object



50718
50719
50720
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 50718

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

#to_hashObject



50722
50723
50724
50725
50726
50727
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 50722

def to_hash
  {
    :order => order.to_hash,
    :discounts => discounts
  }
end

#to_jsonObject



50714
50715
50716
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 50714

def to_json
  JSON.dump(to_hash)
end