class UPS::Parsers::RateParser

Attributes

rate[R]

Public Class Methods

new(rate) click to toggle source
# File lib/ups/parsers/rate_parser.rb, line 9
def initialize(rate)
  @rate = rate
end

Public Instance Methods

rate_service_code() click to toggle source
# File lib/ups/parsers/rate_parser.rb, line 26
def rate_service_code
  rate_service[:Code]
end
rate_service_name() click to toggle source
# File lib/ups/parsers/rate_parser.rb, line 22
def rate_service_name
  UPS::SERVICES[rate_service_code]
end
to_h() click to toggle source
# File lib/ups/parsers/rate_parser.rb, line 13
def to_h
  {
    service_code: rate_service_code,
    service_name: rate_service_name,
    warnings:     rate_warnings,
    total:        rate_total
  }
end

Private Instance Methods

negotiated_rates() click to toggle source
# File lib/ups/parsers/rate_parser.rb, line 54
def negotiated_rates
  rate[:NegotiatedRates]
end
rate_service() click to toggle source
# File lib/ups/parsers/rate_parser.rb, line 42
def rate_service
  rate[:Service]
end
rate_total() click to toggle source
# File lib/ups/parsers/rate_parser.rb, line 32
def rate_total
  return total_charges[:MonetaryValue] unless negotiated_rates

  negotiated_rates[:NetSummaryCharges][:GrandTotal][:MonetaryValue]
end
rate_warnings() click to toggle source
# File lib/ups/parsers/rate_parser.rb, line 38
def rate_warnings
  rated_shipment_warning.is_a?(Array) ? rated_shipment_warning : [rated_shipment_warning]
end
rated_shipment_warning() click to toggle source
# File lib/ups/parsers/rate_parser.rb, line 46
def rated_shipment_warning
  rate[:RatedShipmentWarning]
end
total_charges() click to toggle source
# File lib/ups/parsers/rate_parser.rb, line 50
def total_charges
  rate[:TotalCharges]
end