diff --git a/lib/ebay_api/operations/commerce/taxonomy/category_tree/get_item_aspects_for_category.rb b/lib/ebay_api/operations/commerce/taxonomy/category_tree/get_item_aspects_for_category.rb index 829ea8e..bd8dd94 100644 --- a/lib/ebay_api/operations/commerce/taxonomy/category_tree/get_item_aspects_for_category.rb +++ b/lib/ebay_api/operations/commerce/taxonomy/category_tree/get_item_aspects_for_category.rb @@ -9,6 +9,11 @@ class EbayAPI path { "get_item_aspects_for_category" } query { { category_id: category_id } } http_method :get + + # When no aspects are available for the category, eBay returns 204 No Content. + # Without this override, consumers would receive "true" as the response body. + # To provide a consistent API, we return an empty aspects array instead. + response(204) { { "aspects" => [] } } end end end diff --git a/spec/fixtures/commerce/taxonomy/category_tree/get_item_aspects_for_category/no_content b/spec/fixtures/commerce/taxonomy/category_tree/get_item_aspects_for_category/no_content new file mode 100644 index 0000000..5ae7a89 --- /dev/null +++ b/spec/fixtures/commerce/taxonomy/category_tree/get_item_aspects_for_category/no_content @@ -0,0 +1,3 @@ +HTTP/1.1 204 OK +Content-Type: application/json + diff --git a/spec/operations/commerce/taxonomy/category_tree/get_item_aspects_for_category_spec.rb b/spec/operations/commerce/taxonomy/category_tree/get_item_aspects_for_category_spec.rb index 6a656e4..bb15ea8 100644 --- a/spec/operations/commerce/taxonomy/category_tree/get_item_aspects_for_category_spec.rb +++ b/spec/operations/commerce/taxonomy/category_tree/get_item_aspects_for_category_spec.rb @@ -21,4 +21,14 @@ expect(a_request(:get, url)).to have_been_made end end + + context "when no aspects are available" do + let(:response) do + open_fixture_file "commerce/taxonomy/category_tree/get_item_aspects_for_category/no_content" + end + + it "returns empty aspects array" do + expect(subject).to eq({ "aspects" => [] }) + end + end end