Ver código fonte

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

ANX 6 anos atrás
pai
commit
41d72dc5b8
2 arquivos alterados com 13 adições e 1 exclusões
  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