bjjb / ebayr

A small library to help using the eBay Trading API with Ruby
MIT License
60 stars 49 forks source link

xml attributes are not returned #15

Closed jogaco closed 6 years ago

jogaco commented 9 years ago

If the ebay API returns

<SellingStatus>
      <BidCount>3</BidCount>
      <BidIncrement currencyID="GBP">0.2</BidIncrement>
...

req[:item][:selling_status] will not contain attribute info.

bjjb commented 9 years ago

@jogaco could you post the full XML response? And which version of eBayr are you using? I'll see if I can reproduce it.

jogaco commented 9 years ago
<?xml version="1.0" encoding="UTF-8"?>
<GetItemResponse xmlns="urn:ebay:apis:eBLBaseComponents">
  <Timestamp>2015-09-02T12:57:18.495Z</Timestamp>
  <Ack>Success</Ack>
  <Version>933</Version>
  <Build>E933_CORE_API_17621244_R1</Build>
  <Item>
    <Country>GB</Country>
    <Currency>GBP</Currency>
    <Description>&amp;nbsp;measures 20" pit to pit when laid flat&lt;br&gt;</Description>
    <ItemID>351489938299</ItemID>
    <ListingDetails>
      <ConvertedBuyItNowPrice currencyID="USD">0.0</ConvertedBuyItNowPrice>
      <ConvertedStartPrice currencyID="USD">7.65</ConvertedStartPrice>
      <StartTime>2015-08-23T12:54:37.000Z</StartTime>
      <EndTime>2015-09-02T12:54:37.000Z</EndTime>
    </ListingDetails>
    <ListingType>Chinese</ListingType>
    <SellingStatus>
      <BidCount>3</BidCount>
      <ConvertedCurrentPrice currencyID="USD">13.79</ConvertedCurrentPrice>
      <CurrentPrice currencyID="GBP">9.0</CurrentPrice>
      <QuantitySold>1</QuantitySold>
    </SellingStatus>
    <Title>New York Giants american football shirt Reebok Jeremy Shockey small</Title>
    <PictureDetails>
      <GalleryURL>http://i.ebayimg.com/00/s/MTAyNFg3Njg=/z/~ooAAOSwDNdV2cH4/$_1.JPG?set_id=880000500F</GalleryURL>
    </PictureDetails>
  </Item>
</GetItemResponse>
req[:item][:listing_details] => {:converted_buy_it_now_price=>"0.0", :converted_start_price=>"9.18", :start_time=>"2015-08-23T11:15:07.000Z", :end_time=>"2015-09-02T11:15:07.000Z"} 

I need the currencyID attributes!

Currently using ebayr 0.0.9

jogaco commented 9 years ago

This would probably require an xml parser such as https://github.com/johannesthoma/libxml-to-hash

bjjb commented 9 years ago

The attributes are rarely relevant in an eBayResponse. How about a method (Ebayr::Response#attributes, say) that can reparse the body XML specifically to extract the attributes?

jogaco commented 8 years ago

Maybe it could parse upfront for attributes by passing an optional param in Ebayr::Request#send(with_attributes = nil)

bjjb commented 6 years ago

Closing due to lack of activity. Feel free to re-open if this is still an issue for somebody.