Class: Io::Flow::V0::Models::OrderEstimateForm

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

Overview

Form to get a lightweight estimate of an order.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(incoming = {}) ⇒ OrderEstimateForm

Returns a new instance of OrderEstimateForm.



21638
21639
21640
21641
21642
21643
21644
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 21638

def initialize(incoming={})
  opts = HttpClient::Helper.symbolize_keys(incoming)
  HttpClient::Preconditions.require_keys(opts, [:items], 'OrderEstimateForm')
  @items = HttpClient::Preconditions.assert_class('items', opts.delete(:items), Array).map { |v| (x = v; x.is_a?(::Io::Flow::V0::Models::LineItemForm) ? x : ::Io::Flow::V0::Models::LineItemForm.new(x)) }
  @destination = (x = opts.delete(:destination); x.nil? ? nil : (x = x; x.is_a?(::Io::Flow::V0::Models::OrderAddress) ? x : ::Io::Flow::V0::Models::OrderAddress.new(x)))
  @selections = (x = opts.delete(:selections); x.nil? ? nil : HttpClient::Preconditions.assert_class('selections', x, Array).map { |v| HttpClient::Preconditions.assert_class('selections', v, String) })
end

Instance Attribute Details

#destinationObject (readonly)

Returns the value of attribute destination.



21636
21637
21638
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 21636

def destination
  @destination
end

#itemsObject (readonly)

Returns the value of attribute items.



21636
21637
21638
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 21636

def items
  @items
end

#selectionsObject (readonly)

Returns the value of attribute selections.



21636
21637
21638
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 21636

def selections
  @selections
end

Instance Method Details

#copy(incoming = {}) ⇒ Object



21650
21651
21652
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 21650

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

#to_hashObject



21654
21655
21656
21657
21658
21659
21660
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 21654

def to_hash
  {
    :items => items.map { |o| o.to_hash },
    :destination => destination.nil? ? nil : destination.to_hash,
    :selections => selections.nil? ? nil : selections
  }
end

#to_jsonObject



21646
21647
21648
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 21646

def to_json
  JSON.dump(to_hash)
end