2017-04-02 21 views
0

我正在使用Ruby gem'fedex',https://github.com/jazminschroeder/fedex。 我已經爲開發模式設置了我的代碼,並且正在測試發貨。Fedex Ruby寶石:海關價值是必需的 - 如何添加?

然而,我被卡住,出現以下錯誤:

C:/Ruby22/lib/ruby/gems/2.2.0/gems/fedex-.10.1/lib/fedex/request/shipment.rb: 134:在'failure_response':海關值是必需的。 (Fedex :: RateError)從C:/Ruby22/lib/ruby/gems/2.2.0/gems/fedex-.10.1/lib/fedex/request/shipment.rb:32:在'process_request'從C:/ Ruby22 /lib/ruby/gems/2.2.0/gems/fedex-3.10.1/lib/fedex/shipment.rb:57:in'ship'from C:/Ruby22/bin/css_fedex_v1.rb:92:in''

看來我需要解析'海關價值',可能是我的'包'散列的一部分。但是,我無法找到相關字段供我輸入。經驗豐富並找到解決方案的任何人?

謝謝 馬丁

我的代碼如下:

require 'fedex' 

fedex = Fedex::Shipment.new(:key => '***', 
         :password => '***', 
         :account_number => '***', 
         :meter => '***', 
         :mode => 'development') 

shipper = { :name => "***", 
     :company => "***", 
     :phone_number => "***", 
     :address => "***", 
     :city => "***", 
     :postal_code => "***", 
     :country_code => "DK" } 

recipient = { :name => "***", 
      :company => "***", 
      :phone_number => "***", 
      :address => "***", 
      :city => "***", 
      :postal_code => "***", 
      :country_code => "GB", 
      :residential => "false" } 

packages = [] 
packages << {:weight => {:units => "LB", :value => 1}} 

shipping_options = {:packaging_type => "YOUR_PACKAGING", 
:drop_off_type => "REGULAR_PICKUP"} 

rate = fedex.rate(:shipper=>shipper, 
       :recipient => recipient, 
       :packages => packages, 
       :shipping_options => shipping_options) 

ship = fedex.ship(:shipper=>shipper, 
       :recipient => recipient, 
       :packages => packages, 
       :service_type => "INTERNATIONAL_PRIORITY", 
       :shipping_options => shipping_options) 
puts ship[:completed_shipment_detail][:operational_detail][:transit_time] 

回答

1

完稅價格被宣佈在他們的文檔: https://github.com/jazminschroeder/fedex/commit/9f1d4c67b829aaa4eeba9090c1a45d3bd507aab3#diff-4f122efb7c0d98120d8b7f0cd00998e4R106

customs_value = { :currency => "USD", 
        :amount => "200" } 

據我瞭解,你可以通過它進入大宗商品哈希或保持分開。

+0

嗯我試着審查文檔並直接添加customs_value作爲fedex.ship函數的一部分以及部分商品。但是,它似乎沒有任何工作。你偶然有一個使用國際市場上的fedex.ship功能的代碼的工作示例? – Martin