Class: Io::Flow::V0::Models::DeliveryEstimate

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 = {}) ⇒ DeliveryEstimate

Returns a new instance of DeliveryEstimate.



8471
8472
8473
8474
8475
8476
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 8471

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

Instance Attribute Details

#itemsObject (readonly)

Returns the value of attribute items.



8469
8470
8471
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 8469

def items
  @items
end

#optionsObject (readonly)

Returns the value of attribute options.



8469
8470
8471
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 8469

def options
  @options
end

Instance Method Details

#copy(incoming = {}) ⇒ Object



8482
8483
8484
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 8482

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

#to_hashObject



8486
8487
8488
8489
8490
8491
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 8486

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

#to_jsonObject



8478
8479
8480
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 8478

def to_json
  JSON.dump(to_hash)
end