Class: FreightKit::Rate

Inherits:
Model
  • Object
show all
Defined in:
lib/freight_kit/models/rate.rb

Overview

Class representing a shipping option with estimated price.

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from Model

#attributes, #initialize

Constructor Details

This class inherits a constructor from FreightKit::Model

Instance Attribute Details

#carrierFreightKit::Carrier

The carrier.

Returns:

See Also:



55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
# File 'lib/freight_kit/models/rate.rb', line 55

class Rate < Model
  attr_accessor :carrier,
                :carrier_name,
                :estimate_reference,
                :expires_at,
                :prices,
                :scac,
                :service_name,
                :shipment,
                :transit_days,
                :with_excessive_length_fees

  attr_writer :currency

  def currency
    ActiveUtils::CurrencyCode.standardize(@currency)
  end

  # The total price of the shipment in cents.
  # @return [Integer]
  def total_cents
    return 0 if @prices.blank?

    @prices.sum(&:cents)
  end
end

#carrier_nameString

Name of the carrier. It may differ from the ‘Carrier` providing the rate quote when the `Carrier` is acting as a broker.

Returns:

  • (String)


55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
# File 'lib/freight_kit/models/rate.rb', line 55

class Rate < Model
  attr_accessor :carrier,
                :carrier_name,
                :estimate_reference,
                :expires_at,
                :prices,
                :scac,
                :service_name,
                :shipment,
                :transit_days,
                :with_excessive_length_fees

  attr_writer :currency

  def currency
    ActiveUtils::CurrencyCode.standardize(@currency)
  end

  # The total price of the shipment in cents.
  # @return [Integer]
  def total_cents
    return 0 if @prices.blank?

    @prices.sum(&:cents)
  end
end

#currencyString

ISO4217 currency code of the quoted rate estimates (e.g. ‘CAD`, `EUR`, or `USD`)

Returns:

  • (String)

See Also:



55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
# File 'lib/freight_kit/models/rate.rb', line 55

class Rate < Model
  attr_accessor :carrier,
                :carrier_name,
                :estimate_reference,
                :expires_at,
                :prices,
                :scac,
                :service_name,
                :shipment,
                :transit_days,
                :with_excessive_length_fees

  attr_writer :currency

  def currency
    ActiveUtils::CurrencyCode.standardize(@currency)
  end

  # The total price of the shipment in cents.
  # @return [Integer]
  def total_cents
    return 0 if @prices.blank?

    @prices.sum(&:cents)
  end
end

#estimate_referenceString

Quote number.

Returns:

  • (String)


55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
# File 'lib/freight_kit/models/rate.rb', line 55

class Rate < Model
  attr_accessor :carrier,
                :carrier_name,
                :estimate_reference,
                :expires_at,
                :prices,
                :scac,
                :service_name,
                :shipment,
                :transit_days,
                :with_excessive_length_fees

  attr_writer :currency

  def currency
    ActiveUtils::CurrencyCode.standardize(@currency)
  end

  # The total price of the shipment in cents.
  # @return [Integer]
  def total_cents
    return 0 if @prices.blank?

    @prices.sum(&:cents)
  end
end

#expires_atDateTime

When the rate estimate will expire.

Returns:



55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
# File 'lib/freight_kit/models/rate.rb', line 55

class Rate < Model
  attr_accessor :carrier,
                :carrier_name,
                :estimate_reference,
                :expires_at,
                :prices,
                :scac,
                :service_name,
                :shipment,
                :transit_days,
                :with_excessive_length_fees

  attr_writer :currency

  def currency
    ActiveUtils::CurrencyCode.standardize(@currency)
  end

  # The total price of the shipment in cents.
  # @return [Integer]
  def total_cents
    return 0 if @prices.blank?

    @prices.sum(&:cents)
  end
end

#pricesArray<Prices>

Breakdown of a rate estimate’s prices with amounts in cents.

Returns:

  • (Array<Prices>)

See Also:



55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
# File 'lib/freight_kit/models/rate.rb', line 55

class Rate < Model
  attr_accessor :carrier,
                :carrier_name,
                :estimate_reference,
                :expires_at,
                :prices,
                :scac,
                :service_name,
                :shipment,
                :transit_days,
                :with_excessive_length_fees

  attr_writer :currency

  def currency
    ActiveUtils::CurrencyCode.standardize(@currency)
  end

  # The total price of the shipment in cents.
  # @return [Integer]
  def total_cents
    return 0 if @prices.blank?

    @prices.sum(&:cents)
  end
end

#scacString

SCAC code of the carrier. It may differ from the ‘Carrier` providing the rate estimate when the `Carrier` is acting as a broker.

Returns:

  • (String)


55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
# File 'lib/freight_kit/models/rate.rb', line 55

class Rate < Model
  attr_accessor :carrier,
                :carrier_name,
                :estimate_reference,
                :expires_at,
                :prices,
                :scac,
                :service_name,
                :shipment,
                :transit_days,
                :with_excessive_length_fees

  attr_writer :currency

  def currency
    ActiveUtils::CurrencyCode.standardize(@currency)
  end

  # The total price of the shipment in cents.
  # @return [Integer]
  def total_cents
    return 0 if @prices.blank?

    @prices.sum(&:cents)
  end
end

#service_nameString

The name of the shipping service (e.g. ‘First Class Ground’)

Returns:

  • (String)


55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
# File 'lib/freight_kit/models/rate.rb', line 55

class Rate < Model
  attr_accessor :carrier,
                :carrier_name,
                :estimate_reference,
                :expires_at,
                :prices,
                :scac,
                :service_name,
                :shipment,
                :transit_days,
                :with_excessive_length_fees

  attr_writer :currency

  def currency
    ActiveUtils::CurrencyCode.standardize(@currency)
  end

  # The total price of the shipment in cents.
  # @return [Integer]
  def total_cents
    return 0 if @prices.blank?

    @prices.sum(&:cents)
  end
end

#shipmentFreightKit::Shipment

The shipment.



55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
# File 'lib/freight_kit/models/rate.rb', line 55

class Rate < Model
  attr_accessor :carrier,
                :carrier_name,
                :estimate_reference,
                :expires_at,
                :prices,
                :scac,
                :service_name,
                :shipment,
                :transit_days,
                :with_excessive_length_fees

  attr_writer :currency

  def currency
    ActiveUtils::CurrencyCode.standardize(@currency)
  end

  # The total price of the shipment in cents.
  # @return [Integer]
  def total_cents
    return 0 if @prices.blank?

    @prices.sum(&:cents)
  end
end

#transit_daysInteger

Estimated transit days after date of pickup.

Returns:

  • (Integer)


55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
# File 'lib/freight_kit/models/rate.rb', line 55

class Rate < Model
  attr_accessor :carrier,
                :carrier_name,
                :estimate_reference,
                :expires_at,
                :prices,
                :scac,
                :service_name,
                :shipment,
                :transit_days,
                :with_excessive_length_fees

  attr_writer :currency

  def currency
    ActiveUtils::CurrencyCode.standardize(@currency)
  end

  # The total price of the shipment in cents.
  # @return [Integer]
  def total_cents
    return 0 if @prices.blank?

    @prices.sum(&:cents)
  end
end

#with_excessive_length_feesInteger

When the rate estimate ‘Price`s include applicable excessive length fees.

Returns:

  • (Integer)


55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
# File 'lib/freight_kit/models/rate.rb', line 55

class Rate < Model
  attr_accessor :carrier,
                :carrier_name,
                :estimate_reference,
                :expires_at,
                :prices,
                :scac,
                :service_name,
                :shipment,
                :transit_days,
                :with_excessive_length_fees

  attr_writer :currency

  def currency
    ActiveUtils::CurrencyCode.standardize(@currency)
  end

  # The total price of the shipment in cents.
  # @return [Integer]
  def total_cents
    return 0 if @prices.blank?

    @prices.sum(&:cents)
  end
end

Instance Method Details

#total_centsInteger

The total price of the shipment in cents.

Returns:

  • (Integer)


75
76
77
78
79
# File 'lib/freight_kit/models/rate.rb', line 75

def total_cents
  return 0 if @prices.blank?

  @prices.sum(&:cents)
end