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.



13473
13474
13475
13476
13477
13478
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 13473

def initialize(incoming={})
  opts = HttpClient::Helper.symbolize_keys(incoming)
  HttpClient::Preconditions.require_keys(opts, [:destination, :items], 'OrderEstimateForm')
  @destination = (x = opts.delete(:destination); x.is_a?(::Io::Flow::V0::Models::Address) ? x : ::Io::Flow::V0::Models::Address.new(x))
  @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)) }
end

Instance Attribute Details

#destinationObject (readonly)

Returns the value of attribute destination.



13471
13472
13473
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 13471

def destination
  @destination
end

#itemsObject (readonly)

Returns the value of attribute items.



13471
13472
13473
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 13471

def items
  @items
end

Instance Method Details

#copy(incoming = {}) ⇒ Object



13484
13485
13486
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 13484

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

#to_hashObject



13488
13489
13490
13491
13492
13493
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 13488

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

#to_jsonObject



13480
13481
13482
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 13480

def to_json
  JSON.dump(to_hash)
end