Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
tree: 69eb43a299
Fetching contributors…

Cannot retrieve contributors at this time

44 lines (36 sloc) 1.052 kb
require 'bigdecimal'
module Fedex::WebServices
module Service
class Rate < Base
def get_rates(service_type, rate_request_type, from, to, weight, &process_contents)
request = GetRates.new(self,
service_type,
rate_request_type,
from,
to,
weight
)
response = issue_request(request, &process_contents)
return [ Rate.rate_for(response, rate_request_type), response ]
end
def service_id
:crs
end
def service_version
13
end
def self.rate_for(response, rate_request_type)
details = response.rateReplyDetails.first.ratedShipmentDetails.select do |detail|
detail.shipmentRateDetail.rateType == "PAYOR_#{rate_request_type}_PACKAGE"
end
details.inject(0) do |acc, detail|
acc + BigDecimal.new(detail.shipmentRateDetail.totalNetCharge.amount)
end
end
protected
def port
RatePortType.new(service_url)
end
end
end
end
Jump to Line
Something went wrong with that request. Please try again.