benbuckman / nodejs-ebay-api

[No longer maintained] eBay API Client for Node.js
MIT License
155 stars 104 forks source link

GetNotificationPreferences doesn't properly convert xml to json #37

Open 1mike12 opened 8 years ago

1mike12 commented 8 years ago

I put a breakpoint on xml-converter.js, and the xmlBody is passed in correctly, but somewhere it will drop all the notificationEnable entries

raw xml received from ebay

<?xml version="1.0" encoding="UTF-8"?>
<GetNotificationPreferencesResponse xmlns="urn:ebay:apis:eBLBaseComponents">
   <Timestamp>2016-10-03T03:22:21.880Z</Timestamp>
   <Ack>Success</Ack>
   <Version>967</Version>
   <Build>E967_CORE_APINOTIFY_18003059_R1</Build>
   <UserDeliveryPreferenceArray>
      <NotificationEnable>
         <EventType>EndOfAuction</EventType>
         <EventEnable>Disable</EventEnable>
      </NotificationEnable>
      <NotificationEnable>
         <EventType>AuctionCheckoutComplete</EventType>
         <EventEnable>Enable</EventEnable>
      </NotificationEnable>
      <NotificationEnable>
         <EventType>Feedback</EventType>
         <EventEnable>Disable</EventEnable>
      </NotificationEnable>
      <NotificationEnable>
         <EventType>FixedPriceTransaction</EventType>
         <EventEnable>Enable</EventEnable>
      </NotificationEnable>
      <NotificationEnable>
         <EventType>ItemListed</EventType>
         <EventEnable>Disable</EventEnable>
      </NotificationEnable>
      <NotificationEnable>
         <EventType>MyMessagesM2MMessage</EventType>
         <EventEnable>Disable</EventEnable>
      </NotificationEnable>
      <NotificationEnable>
         <EventType>BidReceived</EventType>
         <EventEnable>Disable</EventEnable>
      </NotificationEnable>
      <NotificationEnable>
         <EventType>FeedbackReceived</EventType>
         <EventEnable>Enable</EventEnable>
      </NotificationEnable>
   </UserDeliveryPreferenceArray>
</GetNotificationPreferencesResponse>

after conversion

{
  "$": {
    "xmlns": "urn:ebay:apis:eBLBaseComponents"
  },
  "Timestamp": "2016-10-03T03:22:21.880Z",
  "Ack": "Success",
  "Version": "967",
  "Build": "E967_CORE_APINOTIFY_18003059_R1",
  "UserDeliveryPreferences": []
}
1mike12 commented 8 years ago

so looks like the culprit is inside the default json parser in json-parser.js. There's a flattening function that destroys the data inside the UserDeliveryPreferences array.

1mike12 commented 8 years ago

made a fix that now FINALLY gets this api call working. https://github.com/benbuckman/nodejs-ebay-api/pull/38 . hopefully the maintainer can get this in there

Also PS , if this call also doesn't work if you're in sandbox mode, go figure...... #justebaythings

{
  "$": {
    "xmlns": "urn:ebay:apis:eBLBaseComponents"
  },
  "Timestamp": "2016-10-03T03:58:53.722Z",
  "Ack": "Success",
  "Version": "967",
  "Build": "E967_CORE_APINOTIFY_18003059_R1",
  "UserDeliveryPreferences": [
    {
      "EventType": "EndOfAuction",
      "EventEnable": "Disable"
    },
    {
      "EventType": "AuctionCheckoutComplete",
      "EventEnable": "Enable"
    },
    {
      "EventType": "Feedback",
      "EventEnable": "Disable"
    },
    {
      "EventType": "FixedPriceTransaction",
      "EventEnable": "Enable"
    },
    {
      "EventType": "ItemListed",
      "EventEnable": "Disable"
    },
    {
      "EventType": "MyMessagesM2MMessage",
      "EventEnable": "Disable"
    },
    {
      "EventType": "BidReceived",
      "EventEnable": "Disable"
    },
    {
      "EventType": "FeedbackReceived",
      "EventEnable": "Enable"
    }
  ]
}
benbuckman commented 8 years ago

Thank you @1mike12 , I left some comments on the PR.

benbuckman commented 8 years ago

https://github.com/benbuckman/nodejs-ebay-api/pull/38