Browse Source

加入GetOrders時的特例 (attr 解析)

ANX 5 years ago
parent
commit
41d72dc5b8
2 changed files with 13 additions and 1 deletions
  1. 12 0
      lib/ebaytr.rb
  2. 1 1
      lib/ebaytr/version.rb

+ 12 - 0
lib/ebaytr.rb

@@ -85,6 +85,18 @@ module Ebaytr
     puts "└---------------------------------------"
     
     res = https.request(req)
+
+    # 特例 (attr 解析)
+    if request_name==:GetOrders
+       #e.g. "USD\">151.96"
+       tmp_str = res.body[res.body.index('<Subtotal currencyID').to_i+22..res.body.index('</Subtotal>').to_i-1]
+       if tmp_str.present?
+         #e.g. "USD"
+         attr_currency = tmp_str.split('"').first
+         res.body = res.body.insert(res.body.index('<Subtotal currencyID').to_i, "<SubtotalAttrCurrencyID>#{attr_currency}</SubtotalAttrCurrencyID>")
+       end
+    end
+
     object_hash = Hash.from_xml(res.body)["#{request_name}Response"]
     object_hash
   end

+ 1 - 1
lib/ebaytr/version.rb

@@ -1,3 +1,3 @@
 module Ebaytr
-  VERSION = "1.3.3"
+  VERSION = "1.3.4"
 end