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.



9867
9868
9869
9870
9871
9872
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 9867

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.



9865
9866
9867
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 9865

def items
  @items
end

#optionsObject (readonly)

Returns the value of attribute options.



9865
9866
9867
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 9865

def options
  @options
end

Instance Method Details

#copy(incoming = {}) ⇒ Object



9878
9879
9880
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 9878

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

#to_hashObject



9882
9883
9884
9885
9886
9887
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 9882

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

#to_jsonObject



9874
9875
9876
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 9874

def to_json
  JSON.dump(to_hash)
end