Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

upgrading fedex rate api to use version 13 so that we can get transit…

… time in the rate request
  • Loading branch information...
commit d07fa0e7ef33566ab0fae1cd62e466de5957dbed 1 parent 28a6b7a
@ricaurte ricaurte authored
Showing with 5 additions and 3 deletions.
  1. +2 −1  lib/fedex/rate.rb
  2. +3 −2 lib/fedex/request/rate.rb
View
3  lib/fedex/rate.rb
@@ -18,7 +18,7 @@ class Rate
# @total_net_freight #The freight charge minus dicounts
# @total_surcharges #The total amount of all surcharges applied to this shipment
# @total_base_charge #The total base charge
- attr_accessor :rate_type, :rate_zone, :total_bilint_weight, :total_freight_discounts, :total_net_charge, :total_taxes, :total_net_freight, :total_surcharges, :total_base_charge
+ attr_accessor :rate_type, :rate_zone, :total_bilint_weight, :total_freight_discounts, :total_net_charge, :total_taxes, :total_net_freight, :total_surcharges, :total_base_charge, :response_details
def initialize(options = {})
@rate_type = options[:rate_type]
@rate_zone = options[:rate_zone]
@@ -31,6 +31,7 @@ def initialize(options = {})
@total_base_charge = options[:total_base_charge][:amount]
@total_net_fedex_charge = (options[:total_net_fe_dex_charge]||{})[:amount]
@total_rebates = (options[:total_rebates]||{})[:amount]
+ @response_details = options[:response_details]
end
end
end
View
5 lib/fedex/request/rate.rb
@@ -10,7 +10,7 @@ def process_request
response = parse_response(api_response)
if success?(response)
rate_details = [response[:rate_reply][:rate_reply_details][:rated_shipment_details]].flatten.first[:shipment_rate_detail]
- Fedex::Rate.new(rate_details)
+ Fedex::Rate.new(rate_details.merge(response_details: response[:rate_reply]))

I'm not following why this merge is needed - would you be able to enlighten me? If it is needed, could you revert the hash syntax to 1.8.7's style since the rest of the module is compatible with 1.8.7?

@ricaurte Owner

It's because the returned transit time is contained within response[:rate_reply][:rate_reply_details][:transit_time], so instead of just picking out that one piece of information and combining it into the rate_details hash, I merged the entire response[:rate_reply] over in case there is other information someone might want.

Yeah, I can convert it back to 1.8.7 has syntax to make it compatible.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
else
error_message = if response[:rate_reply]
[response[:rate_reply][:notifications]].flatten.first[:message]
@@ -46,6 +46,7 @@ def build_xml
add_web_authentication_detail(xml)
add_client_detail(xml)
add_version(xml)
+ xml.ReturnTransitAndCommit true
add_requested_shipment(xml)
}
end
@@ -53,7 +54,7 @@ def build_xml
end
def service
- { :id => 'crs', :version => 10 }
+ { :id => 'crs', :version => 13 }
end
# Successful request
@jlambert121

I'm not following why this merge is needed - would you be able to enlighten me? If it is needed, could you revert the hash syntax to 1.8.7's style since the rest of the module is compatible with 1.8.7?

@ricaurte

It's because the returned transit time is contained within response[:rate_reply][:rate_reply_details][:transit_time], so instead of just picking out that one piece of information and combining it into the rate_details hash, I merged the entire response[:rate_reply] over in case there is other information someone might want.

Yeah, I can convert it back to 1.8.7 has syntax to make it compatible.

Please sign in to comment.
Something went wrong with that request. Please try again.