Class: Io::Flow::V0::Models::QuoteEstimate

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

Returns a new instance of QuoteEstimate.



16228
16229
16230
16231
16232
16233
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 16228

def initialize(incoming={})
  opts = HttpClient::Helper.symbolize_keys(incoming)
  HttpClient::Preconditions.require_keys(opts, [:destination, :deliveries], 'QuoteEstimate')
  @destination = (x = opts.delete(:destination); x.is_a?(::Io::Flow::V0::Models::Address) ? x : ::Io::Flow::V0::Models::Address.new(x))
  @deliveries = HttpClient::Preconditions.assert_class('deliveries', opts.delete(:deliveries), Array).map { |v| (x = v; x.is_a?(::Io::Flow::V0::Models::DeliveryEstimate) ? x : ::Io::Flow::V0::Models::DeliveryEstimate.new(x)) }
end

Instance Attribute Details

#deliveriesObject (readonly)

Returns the value of attribute deliveries.



16226
16227
16228
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 16226

def deliveries
  @deliveries
end

#destinationObject (readonly)

Returns the value of attribute destination.



16226
16227
16228
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 16226

def destination
  @destination
end

Instance Method Details

#copy(incoming = {}) ⇒ Object



16239
16240
16241
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 16239

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

#to_hashObject



16243
16244
16245
16246
16247
16248
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 16243

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

#to_jsonObject



16235
16236
16237
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 16235

def to_json
  JSON.dump(to_hash)
end