lib/shippinglogic/fedex/rate.rb in binarylogic-shippinglogic-1.0.8 vs lib/shippinglogic/fedex/rate.rb in binarylogic-shippinglogic-1.1.0

- old
+ new

@@ -85,11 +85,11 @@ # # to show accessor methods # rates.first.name # # => "First Overnight" class Rate < Service # Each rate result is an object of this class - class Service; attr_accessor :name, :type, :saturday, :delivered_by, :rate, :currency; end + class Service; attr_accessor :name, :type, :saturday, :delivered_by, :speed, :rate, :currency; end VERSION = {:major => 6, :intermediate => 0, :minor => 0} # shipper options attribute :shipper_streets, :string @@ -174,16 +174,25 @@ response[:rate_reply_details].collect do |details| shipment_detail = details[:rated_shipment_details].is_a?(Array) ? details[:rated_shipment_details].first : details[:rated_shipment_details] cost = shipment_detail[:shipment_rate_detail][:total_net_charge] delivered_by = details[:delivery_timestamp] && Time.parse(details[:delivery_timestamp]) + speed = case details[:service_type] + when /overnight/i + 1.day + when /2_day/i + 2.days + else + 3.days + end if meets_deadline?(delivered_by) service = Service.new service.name = details[:service_type].titleize service.type = details[:service_type] service.saturday = details[:applied_options] == "SATURDAY_DELIVERY" service.delivered_by = delivered_by + service.speed = speed service.rate = BigDecimal.new(cost[:amount]) service.currency = cost[:currency] service end end.compact \ No newline at end of file