lineofflight / peddler

Amazon Selling Partner API (SP-API) in Ruby
MIT License
307 stars 130 forks source link

Is this a bug? #115

Closed johnnncodes closed 6 years ago

johnnncodes commented 6 years ago

An amazon order w/ 2 order items is weird in the value returned by client.list_order_items("<amazon_order_id>").

The amazon order has 2 order items but instead of having 2 "OrderItem" under "OrderItems", there's only 1 "OrderItem". And that single "OrderItem" has 2 objects inside it.

See below:

(byebug) order_items = client.list_order_items(orders.second['AmazonOrderId'])

(byebug) order_items.data

PRETTYFIED JSON:

{
   "OrderItems"   =>   {
      "OrderItem"      =>      [
         {
            "QuantityOrdered"            =>"1",
            "Title"            =>"Firestone Winterforce Winter Radial Tire - 195/65R15 91S",
            "ShippingTax"            =>            {
               "CurrencyCode"               =>"USD",
               "Amount"               =>"0.00"
            },
            "PromotionDiscount"            =>            {
               "CurrencyCode"               =>"USD",
               "Amount"               =>"0.00"
            },
            "ConditionId"            =>"New",
            "IsGift"            =>"false",
            "ASIN"            =>"B01IHLIAKU",
            "SellerSKU"            =>"Firestone1140281956515",
            "OrderItemId"            =>"15468334030090",
            "ProductInfo"            =>            {
               "NumberOfItems"               =>"1"
            },
            "GiftWrapTax"            =>            {
               "CurrencyCode"               =>"USD",
               "Amount"               =>"0.00"
            },
            "QuantityShipped"            =>"0",
            "ShippingPrice"            =>            {
               "CurrencyCode"               =>"USD",
               "Amount"               =>"0.00"
            },
            "GiftWrapPrice"            =>            {
               "CurrencyCode"               =>"USD",
               "Amount"               =>"0.00"
            },
            "ConditionSubtypeId"            =>"New",
            "ItemPrice"            =>            {
               "CurrencyCode"               =>"USD",
               "Amount"               =>"1.00"
            },
            "ItemTax"            =>            {
               "CurrencyCode"               =>"USD",
               "Amount"               =>"0.00"
            },
            "ShippingDiscount"            =>            {
               "CurrencyCode"               =>"USD",
               "Amount"               =>"0.00"
            }
         },
         {
            "QuantityOrdered"            =>"1",
            "Title"            =>"Mastercraft SRT Touring All-Season Radial Tire - 205/65R16 95H",
            "ShippingTax"            =>            {
               "CurrencyCode"               =>"USD",
               "Amount"               =>"0.00"
            },
            "PromotionDiscount"            =>            {
               "CurrencyCode"               =>"USD",
               "Amount"               =>"0.00"
            },
            "ConditionId"            =>"New",
            "IsGift"            =>"false",
            "ASIN"            =>"B00UOKT5DY",
            "SellerSKU"            =>"Mastercraft900000212652056516",
            "OrderItemId"            =>"54755441779362",
            "ProductInfo"            =>            {
               "NumberOfItems"               =>"1"
            },
            "GiftWrapTax"            =>            {
               "CurrencyCode"               =>"USD",
               "Amount"               =>"0.00"
            },
            "QuantityShipped"            =>"0",
            "ShippingPrice"            =>            {
               "CurrencyCode"               =>"USD",
               "Amount"               =>"0.00"
            },
            "GiftWrapPrice"            =>            {
               "CurrencyCode"               =>"USD",
               "Amount"               =>"0.00"
            },
            "ConditionSubtypeId"            =>"New",
            "ItemPrice"            =>            {
               "CurrencyCode"               =>"USD",
               "Amount"               =>"1.00"
            },
            "ItemTax"            =>            {
               "CurrencyCode"               =>"USD",
               "Amount"               =>"0.00"
            },
            "ShippingDiscount"            =>            {
               "CurrencyCode"               =>"USD",
               "Amount"               =>"0.00"
            }
         }
      ]
   },
   "AmazonOrderId"   =>"113-1928597-8397869"
}

Is that unexpected? Or it's how peddler really works?

hakanensari commented 6 years ago

Unfortunately that's how Amazon structures the data.

If you're looking for a more intuitive representation, check out this parser. It sits on top of Peddler.