etsy icon indicating copy to clipboard operation
etsy copied to clipboard

Listing.find_all_by_shop_id() throws error with state=sold

Open sarahbwalsh opened this issue 11 years ago • 3 comments

Listing.find_all_by_shop_id() is throwing Etsy::EtsyJSONInvalid when the state is set to sold.

Example:

access = { :access_token => 'mytoken', :access_secret => 'mysecret' }
listings = Etsy::Listing.find_all_by_shop_id(myshop_id, access.merge(:state => :sold, :limit => 100, :offset => 0))

All other valid states (active, inactive, expired, featured) work as expected.

sarahbwalsh avatar Oct 31 '14 03:10 sarahbwalsh

I wonder if they changed the name of the state from sold to sold_out?

https://www.etsy.com/developers/documentation/reference/listing#section_listing_states

kytrinyx avatar Oct 31 '14 04:10 kytrinyx

So I poked through the listings.rb file and found:

if state == :sold
  sold_listings(shop_id, options)
else
  get_all("/shops/#{shop_id}/listings/#{state}", options)
end

So passing sold doesn't actually use that as state parameter to pull listings. sold_listings() actually calls Etsy::Transaction.find_all_by_shop_id() to pull the sold out listings. I get the same Etsy::EtsyJSONInvalid error trying to call either of the Transaction methods (find_all_by_shop_id and find_all_by_buyer_id) directly, so it looks like the issue is with transactions. Note that I do have listings_r included in my oauth permission scope, so that isn't the problem.

sarahbwalsh avatar Oct 31 '14 05:10 sarahbwalsh

Got it, it looks like you're right, that the transactions are the problem. I'll dig into this, thanks for reporting it.

kytrinyx avatar Oct 31 '14 11:10 kytrinyx