Class: Io::Flow::V0::Models::RatecardEstimateV1

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

Overview

Represents a summary of a cost estimate based on rate card data for an origin/destination and weight, either gravitational or dimensional

Instance Attribute Summary collapse

Attributes inherited from RatecardEstimate

#discriminator

Instance Method Summary collapse

Methods inherited from RatecardEstimate

from_json, #to_hash

Constructor Details

#initialize(incoming = {}) ⇒ RatecardEstimateV1

Returns a new instance of RatecardEstimateV1.



57293
57294
57295
57296
57297
57298
57299
57300
57301
57302
57303
57304
57305
57306
57307
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 57293

def initialize(incoming={})
  super(:discriminator => RatecardEstimate::Types::RATECARD_ESTIMATE_V1)
  opts = HttpClient::Helper.symbolize_keys(incoming)
  HttpClient::Preconditions.require_keys(opts, [:service, :shipment_window, :currency, :amount, :fees, :total, :delivered_duty], 'RatecardEstimateV1')
  @service = (x = opts.delete(:service); x.is_a?(::Io::Flow::V0::Models::RatecardServiceSummary) ? x : ::Io::Flow::V0::Models::RatecardServiceSummary.new(x))
  @shipment_window = (x = opts.delete(:shipment_window); x.is_a?(::Io::Flow::V0::Models::ShipmentWindow) ? x : ::Io::Flow::V0::Models::ShipmentWindow.new(x))
  @currency = HttpClient::Preconditions.assert_class('currency', opts.delete(:currency), String)
  @amount = HttpClient::Preconditions.assert_class('amount', opts.delete(:amount), Numeric)
  @fees = HttpClient::Preconditions.assert_class('fees', opts.delete(:fees), Array).map { |v| (x = v; x.is_a?(::Io::Flow::V0::Models::RatecardFee) ? x : ::Io::Flow::V0::Models::RatecardFee.from_json(x)) }
  @total = HttpClient::Preconditions.assert_class('total', opts.delete(:total), Numeric)
  @delivered_duty = (x = opts.delete(:delivered_duty); x.is_a?(::Io::Flow::V0::Models::DeliveredDuty) ? x : ::Io::Flow::V0::Models::DeliveredDuty.apply(x))
  @dimensional_weight = (x = opts.delete(:dimensional_weight); x.nil? ? nil : (x = x; x.is_a?(::Io::Flow::V0::Models::Measurement) ? x : ::Io::Flow::V0::Models::Measurement.new(x)))
  @gravitational_weight = (x = opts.delete(:gravitational_weight); x.nil? ? nil : (x = x; x.is_a?(::Io::Flow::V0::Models::Measurement) ? x : ::Io::Flow::V0::Models::Measurement.new(x)))
  @line_items = (x = opts.delete(:line_items); x.nil? ? nil : HttpClient::Preconditions.assert_class('line_items', x, 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

#amountObject (readonly)

Returns the value of attribute amount.



57291
57292
57293
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 57291

def amount
  @amount
end

#currencyObject (readonly)

Returns the value of attribute currency.



57291
57292
57293
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 57291

def currency
  @currency
end

#delivered_dutyObject (readonly)

Returns the value of attribute delivered_duty.



57291
57292
57293
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 57291

def delivered_duty
  @delivered_duty
end

#dimensional_weightObject (readonly)

Returns the value of attribute dimensional_weight.



57291
57292
57293
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 57291

def dimensional_weight
  @dimensional_weight
end

#feesObject (readonly)

Returns the value of attribute fees.



57291
57292
57293
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 57291

def fees
  @fees
end

#gravitational_weightObject (readonly)

Returns the value of attribute gravitational_weight.



57291
57292
57293
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 57291

def gravitational_weight
  @gravitational_weight
end

#line_itemsObject (readonly)

Returns the value of attribute line_items.



57291
57292
57293
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 57291

def line_items
  @line_items
end

#serviceObject (readonly)

Returns the value of attribute service.



57291
57292
57293
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 57291

def service
  @service
end

#shipment_windowObject (readonly)

Returns the value of attribute shipment_window.



57291
57292
57293
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 57291

def shipment_window
  @shipment_window
end

#totalObject (readonly)

Returns the value of attribute total.



57291
57292
57293
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 57291

def total
  @total
end

Instance Method Details

#copy(incoming = {}) ⇒ Object



57313
57314
57315
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 57313

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

#subtype_to_hashObject



57317
57318
57319
57320
57321
57322
57323
57324
57325
57326
57327
57328
57329
57330
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 57317

def subtype_to_hash
  {
    :service => service.to_hash,
    :shipment_window => shipment_window.to_hash,
    :currency => currency,
    :amount => amount,
    :fees => fees.map { |o| o.to_hash },
    :total => total,
    :delivered_duty => delivered_duty.value,
    :dimensional_weight => dimensional_weight.nil? ? nil : dimensional_weight.to_hash,
    :gravitational_weight => gravitational_weight.nil? ? nil : gravitational_weight.to_hash,
    :line_items => line_items.nil? ? nil : line_items.map { |o| o.to_hash }
  }
end

#to_jsonObject



57309
57310
57311
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 57309

def to_json
  JSON.dump(to_hash)
end