From d581e48e863c835c700a07f3c7fcb146be3c0d79 Mon Sep 17 00:00:00 2001 From: Ulan Djamanbalaev Date: Thu, 12 Feb 2026 12:02:47 +0000 Subject: [PATCH 01/11] Handle "No Content" response for `get_item_condition_policies` endpoint --- .../metadata/marketplace/get_item_condition_policies.rb | 4 ++++ spec/fixtures/no_content | 2 ++ .../marketplace/get_item_condition_policies/success | 1 - .../marketplace/get_item_condition_policies_spec.rb | 8 ++++++++ 4 files changed, 14 insertions(+), 1 deletion(-) create mode 100644 spec/fixtures/no_content diff --git a/lib/ebay_api/operations/sell/metadata/marketplace/get_item_condition_policies.rb b/lib/ebay_api/operations/sell/metadata/marketplace/get_item_condition_policies.rb index 9d5c38c..be5b19b 100644 --- a/lib/ebay_api/operations/sell/metadata/marketplace/get_item_condition_policies.rb +++ b/lib/ebay_api/operations/sell/metadata/marketplace/get_item_condition_policies.rb @@ -7,6 +7,10 @@ class EbayAPI operation :get_item_condition_policies do path { "get_item_condition_policies" } http_method :get + + # When no policies are available, eBay returns 204 No Content. + # To provide a consistent API, we return an empty array instead. + response(204) { { "itemConditionPolicies" => [] } } end end end diff --git a/spec/fixtures/no_content b/spec/fixtures/no_content new file mode 100644 index 0000000..9a6a236 --- /dev/null +++ b/spec/fixtures/no_content @@ -0,0 +1,2 @@ +HTTP/1.1 204 No Content +Content-Length: 0 diff --git a/spec/fixtures/sell/metadata/marketplace/get_item_condition_policies/success b/spec/fixtures/sell/metadata/marketplace/get_item_condition_policies/success index d2e8a4b..a38e35e 100644 --- a/spec/fixtures/sell/metadata/marketplace/get_item_condition_policies/success +++ b/spec/fixtures/sell/metadata/marketplace/get_item_condition_policies/success @@ -1,5 +1,4 @@ HTTP/1.1 200 OK -Content-Length: 500 Content-Type: application/json { diff --git a/spec/operations/sell/metadata/marketplace/get_item_condition_policies_spec.rb b/spec/operations/sell/metadata/marketplace/get_item_condition_policies_spec.rb index 7f125cc..589405c 100644 --- a/spec/operations/sell/metadata/marketplace/get_item_condition_policies_spec.rb +++ b/spec/operations/sell/metadata/marketplace/get_item_condition_policies_spec.rb @@ -41,5 +41,13 @@ end end end + + context "when no policies are available (204 No Content)" do + let(:response) { open_fixture_file "no_content" } + + it "returns an empty array for itemConditionPolicies" do + expect(subject["itemConditionPolicies"]).to eq([]) + end + end end From 0990dbd0b29abce1cb7b2d8aa026b518a2c912dc Mon Sep 17 00:00:00 2001 From: Ulan Djamanbalaev Date: Thu, 12 Feb 2026 12:05:35 +0000 Subject: [PATCH 02/11] Add `sell.metadata.marketplace.get_category_policies` endpoint --- .../operations/sell/metadata/marketplace.rb | 1 + .../marketplace/get_category_policies.rb | 18 ++++++ .../marketplace/get_category_policies/success | 22 +++++++ .../marketplace/get_category_policies_spec.rb | 57 +++++++++++++++++++ 4 files changed, 98 insertions(+) create mode 100644 lib/ebay_api/operations/sell/metadata/marketplace/get_category_policies.rb create mode 100644 spec/fixtures/sell/metadata/marketplace/get_category_policies/success create mode 100644 spec/operations/sell/metadata/marketplace/get_category_policies_spec.rb diff --git a/lib/ebay_api/operations/sell/metadata/marketplace.rb b/lib/ebay_api/operations/sell/metadata/marketplace.rb index 93add5f..3fff071 100644 --- a/lib/ebay_api/operations/sell/metadata/marketplace.rb +++ b/lib/ebay_api/operations/sell/metadata/marketplace.rb @@ -6,6 +6,7 @@ class EbayAPI option :marketplace_id require_relative "marketplace/get_item_condition_policies" + require_relative "marketplace/get_category_policies" end end end diff --git a/lib/ebay_api/operations/sell/metadata/marketplace/get_category_policies.rb b/lib/ebay_api/operations/sell/metadata/marketplace/get_category_policies.rb new file mode 100644 index 0000000..89a2c77 --- /dev/null +++ b/lib/ebay_api/operations/sell/metadata/marketplace/get_category_policies.rb @@ -0,0 +1,18 @@ +# @see https://developer.ebay.com/api-docs/sell/metadata/resources/marketplace/methods/getCategoryPolicies + +class EbayAPI + scope :sell do + scope :metadata do + scope :marketplace do + operation :get_category_policies do + path { "get_category_policies" } + http_method :get + + # When no policies are available, eBay returns 204 No Content. + # To provide a consistent API, we return an empty array instead. + response(204) { { "categoryPolicies" => [] } } + end + end + end + end +end diff --git a/spec/fixtures/sell/metadata/marketplace/get_category_policies/success b/spec/fixtures/sell/metadata/marketplace/get_category_policies/success new file mode 100644 index 0000000..f4fb42f --- /dev/null +++ b/spec/fixtures/sell/metadata/marketplace/get_category_policies/success @@ -0,0 +1,22 @@ +HTTP/1.1 200 OK +Content-Type: application/json + +{ + "categoryPolicies": [ + { + "categoryId": "625", + "categoryTreeId": "0", + "autoPayEnabled": true, + "orra": true, + "minimumReservePrice": 0.0, + "paymentMethods": ["CASH_ON_PICKUP"], + "intangibleEnabled": false, + "isbnSupport": "DISABLED", + "upcSupport": "ENABLED", + "eanSupport": "DISABLED", + "valueCategory": false + } + ] +} + + diff --git a/spec/operations/sell/metadata/marketplace/get_category_policies_spec.rb b/spec/operations/sell/metadata/marketplace/get_category_policies_spec.rb new file mode 100644 index 0000000..9bb41b2 --- /dev/null +++ b/spec/operations/sell/metadata/marketplace/get_category_policies_spec.rb @@ -0,0 +1,57 @@ +RSpec.describe EbayAPI, ".sell.metadata.marketplace.get_category_policies" do + let(:client) { described_class.new(**settings) } + let(:scope) { client.sell.metadata.marketplace(marketplace_id: "EBAY_US") } + let(:settings) { yaml_fixture_file("settings.valid.yml") } + let(:url) do + "https://api.ebay.com/sell/metadata/v1/marketplace/EBAY_US/get_category_policies" + end + + before { stub_request(:get, url).to_return(response) } + subject { scope.get_category_policies } + + context "success" do + let(:response) do + open_fixture_file "sell/metadata/marketplace/get_category_policies/success" + end + + it "sends a request" do + subject + expect(a_request(:get, url)).to have_been_made + end + + it "returns category policies" do + expect(subject["categoryPolicies"]).to be_an(Array) + expect(subject["categoryPolicies"].count).to eq(1) + end + + describe "category policy" do + let(:policy) { subject["categoryPolicies"].first } + + it "has proper attributes" do + expect(policy["categoryId"]).to eq("625") + expect(policy["categoryTreeId"]).to eq("0") + expect(policy["autoPayEnabled"]).to eq(true) + expect(policy["orra"]).to eq(true) + expect(policy["minimumReservePrice"]).to eq(0.0) + expect(policy["paymentMethods"]).to eq(["CASH_ON_PICKUP"]) + expect(policy["intangibleEnabled"]).to eq(false) + expect(policy["valueCategory"]).to eq(false) + end + + it "has product identifier support attributes" do + expect(policy["isbnSupport"]).to eq("DISABLED") + expect(policy["upcSupport"]).to eq("ENABLED") + expect(policy["eanSupport"]).to eq("DISABLED") + end + end + end + + context "when no policies are available (204 No Content)" do + let(:response) { open_fixture_file "no_content" } + + it "returns an empty array for categoryPolicies" do + expect(subject["categoryPolicies"]).to eq([]) + end + end +end + From 4142885225656572de1f321a0d2d86e1fda9c585 Mon Sep 17 00:00:00 2001 From: Ulan Djamanbalaev Date: Thu, 12 Feb 2026 12:08:37 +0000 Subject: [PATCH 03/11] Add `sell.metadata.marketplace.get_classified_ad_policies` endpoint --- .../operations/sell/metadata/marketplace.rb | 1 + .../marketplace/get_classified_ad_policies.rb | 19 ++++++ .../get_classified_ad_policies/success | 23 +++++++ .../get_classified_ad_policies_spec.rb | 64 +++++++++++++++++++ 4 files changed, 107 insertions(+) create mode 100644 lib/ebay_api/operations/sell/metadata/marketplace/get_classified_ad_policies.rb create mode 100644 spec/fixtures/sell/metadata/marketplace/get_classified_ad_policies/success create mode 100644 spec/operations/sell/metadata/marketplace/get_classified_ad_policies_spec.rb diff --git a/lib/ebay_api/operations/sell/metadata/marketplace.rb b/lib/ebay_api/operations/sell/metadata/marketplace.rb index 3fff071..b70e1db 100644 --- a/lib/ebay_api/operations/sell/metadata/marketplace.rb +++ b/lib/ebay_api/operations/sell/metadata/marketplace.rb @@ -7,6 +7,7 @@ class EbayAPI require_relative "marketplace/get_item_condition_policies" require_relative "marketplace/get_category_policies" + require_relative "marketplace/get_classified_ad_policies" end end end diff --git a/lib/ebay_api/operations/sell/metadata/marketplace/get_classified_ad_policies.rb b/lib/ebay_api/operations/sell/metadata/marketplace/get_classified_ad_policies.rb new file mode 100644 index 0000000..18d856d --- /dev/null +++ b/lib/ebay_api/operations/sell/metadata/marketplace/get_classified_ad_policies.rb @@ -0,0 +1,19 @@ +# @see https://developer.ebay.com/api-docs/sell/metadata/resources/marketplace/methods/getClassifiedAdPolicies + +class EbayAPI + scope :sell do + scope :metadata do + scope :marketplace do + operation :get_classified_ad_policies do + path { "get_classified_ad_policies" } + http_method :get + + # When no policies are available, eBay returns 204 No Content. + # To provide a consistent API, we return an empty array instead. + response(204) { { "classifiedAdPolicies" => [] } } + end + end + end + end +end + diff --git a/spec/fixtures/sell/metadata/marketplace/get_classified_ad_policies/success b/spec/fixtures/sell/metadata/marketplace/get_classified_ad_policies/success new file mode 100644 index 0000000..fc95323 --- /dev/null +++ b/spec/fixtures/sell/metadata/marketplace/get_classified_ad_policies/success @@ -0,0 +1,23 @@ +HTTP/1.1 200 OK +Content-Type: application/json + +{ + "classifiedAdPolicies": [ + { + "categoryId": "625", + "categoryTreeId": "0", + "adFormatEnabled": "Enabled", + "sellerContactDetailsEnabled": true, + "classifiedAdPaymentMethodEnabled": "Enabled", + "classifiedAdShippingMethodEnabled": false, + "classifiedAdBestOfferEnabled": "Enabled", + "classifiedAdCounterOfferEnabled": true, + "classifiedAdContactByPhoneEnabled": true, + "classifiedAdContactByEmailEnabled": true, + "classifiedAdAutoAcceptEnabled": true, + "classifiedAdAutoDeclineEnabled": true + } + ] +} + + diff --git a/spec/operations/sell/metadata/marketplace/get_classified_ad_policies_spec.rb b/spec/operations/sell/metadata/marketplace/get_classified_ad_policies_spec.rb new file mode 100644 index 0000000..53204d8 --- /dev/null +++ b/spec/operations/sell/metadata/marketplace/get_classified_ad_policies_spec.rb @@ -0,0 +1,64 @@ +RSpec.describe EbayAPI, ".sell.metadata.marketplace.get_classified_ad_policies" do + let(:client) { described_class.new(**settings) } + let(:scope) { client.sell.metadata.marketplace(marketplace_id: "EBAY_US") } + let(:settings) { yaml_fixture_file("settings.valid.yml") } + let(:url) do + "https://api.ebay.com/sell/metadata/v1/marketplace/EBAY_US/get_classified_ad_policies" + end + + before { stub_request(:get, url).to_return(response) } + subject { scope.get_classified_ad_policies } + + context "success" do + let(:response) do + open_fixture_file "sell/metadata/marketplace/get_classified_ad_policies/success" + end + + it "sends a request" do + subject + expect(a_request(:get, url)).to have_been_made + end + + it "returns classified ad policies" do + expect(subject["classifiedAdPolicies"]).to be_an(Array) + expect(subject["classifiedAdPolicies"].count).to eq(1) + end + + describe "classified ad policy" do + let(:policy) { subject["classifiedAdPolicies"].first } + + it "has proper attributes" do + expect(policy["categoryId"]).to eq("625") + expect(policy["categoryTreeId"]).to eq("0") + expect(policy["adFormatEnabled"]).to eq("Enabled") + expect(policy["sellerContactDetailsEnabled"]).to eq(true) + end + + it "has payment and shipping attributes" do + expect(policy["classifiedAdPaymentMethodEnabled"]).to eq("Enabled") + expect(policy["classifiedAdShippingMethodEnabled"]).to eq(false) + end + + it "has best offer attributes" do + expect(policy["classifiedAdBestOfferEnabled"]).to eq("Enabled") + expect(policy["classifiedAdCounterOfferEnabled"]).to eq(true) + expect(policy["classifiedAdAutoAcceptEnabled"]).to eq(true) + expect(policy["classifiedAdAutoDeclineEnabled"]).to eq(true) + end + + it "has contact attributes" do + expect(policy["classifiedAdContactByPhoneEnabled"]).to eq(true) + expect(policy["classifiedAdContactByEmailEnabled"]).to eq(true) + end + end + end + + context "when no policies are available (204 No Content)" do + let(:response) { open_fixture_file "no_content" } + + it "returns an empty array for classifiedAdPolicies" do + expect(subject["classifiedAdPolicies"]).to eq([]) + end + end +end + From 374b97b2e42aec747d870ee205e9ab4d50847a90 Mon Sep 17 00:00:00 2001 From: Ulan Djamanbalaev Date: Thu, 12 Feb 2026 12:10:06 +0000 Subject: [PATCH 04/11] Add `sell.metadata.marketplace.get_automotive_parts_compatibility_policies` endpoint --- .../operations/sell/metadata/marketplace.rb | 1 + ...automotive_parts_compatibility_policies.rb | 19 ++++++++ .../success | 16 +++++++ ...otive_parts_compatibility_policies_spec.rb | 48 +++++++++++++++++++ 4 files changed, 84 insertions(+) create mode 100644 lib/ebay_api/operations/sell/metadata/marketplace/get_automotive_parts_compatibility_policies.rb create mode 100644 spec/fixtures/sell/metadata/marketplace/get_automotive_parts_compatibility_policies/success create mode 100644 spec/operations/sell/metadata/marketplace/get_automotive_parts_compatibility_policies_spec.rb diff --git a/lib/ebay_api/operations/sell/metadata/marketplace.rb b/lib/ebay_api/operations/sell/metadata/marketplace.rb index b70e1db..dc7b7c1 100644 --- a/lib/ebay_api/operations/sell/metadata/marketplace.rb +++ b/lib/ebay_api/operations/sell/metadata/marketplace.rb @@ -8,6 +8,7 @@ class EbayAPI require_relative "marketplace/get_item_condition_policies" require_relative "marketplace/get_category_policies" require_relative "marketplace/get_classified_ad_policies" + require_relative "marketplace/get_automotive_parts_compatibility_policies" end end end diff --git a/lib/ebay_api/operations/sell/metadata/marketplace/get_automotive_parts_compatibility_policies.rb b/lib/ebay_api/operations/sell/metadata/marketplace/get_automotive_parts_compatibility_policies.rb new file mode 100644 index 0000000..872a924 --- /dev/null +++ b/lib/ebay_api/operations/sell/metadata/marketplace/get_automotive_parts_compatibility_policies.rb @@ -0,0 +1,19 @@ +# @see https://developer.ebay.com/api-docs/sell/metadata/resources/marketplace/methods/getAutomotivePartsCompatibilityPolicies + +class EbayAPI + scope :sell do + scope :metadata do + scope :marketplace do + operation :get_automotive_parts_compatibility_policies do + path { "get_automotive_parts_compatibility_policies" } + http_method :get + + # When no policies are available, eBay returns 204 No Content. + # To provide a consistent API, we return an empty array instead. + response(204) { { "automotivePartsCompatibilityPolicies" => [] } } + end + end + end + end +end + diff --git a/spec/fixtures/sell/metadata/marketplace/get_automotive_parts_compatibility_policies/success b/spec/fixtures/sell/metadata/marketplace/get_automotive_parts_compatibility_policies/success new file mode 100644 index 0000000..3d58fca --- /dev/null +++ b/spec/fixtures/sell/metadata/marketplace/get_automotive_parts_compatibility_policies/success @@ -0,0 +1,16 @@ +HTTP/1.1 200 OK +Content-Type: application/json + +{ + "automotivePartsCompatibilityPolicies": [ + { + "categoryId": "6028", + "categoryTreeId": "100", + "maxNumberOfCompatibleVehicles": 1000, + "compatibleVehicleTypes": ["US_CARS_TRUCKS", "US_MOTORCYCLES"], + "compatibilityBasedOn": "ASSEMBLY" + } + ] +} + + diff --git a/spec/operations/sell/metadata/marketplace/get_automotive_parts_compatibility_policies_spec.rb b/spec/operations/sell/metadata/marketplace/get_automotive_parts_compatibility_policies_spec.rb new file mode 100644 index 0000000..f802b29 --- /dev/null +++ b/spec/operations/sell/metadata/marketplace/get_automotive_parts_compatibility_policies_spec.rb @@ -0,0 +1,48 @@ +RSpec.describe EbayAPI, ".sell.metadata.marketplace.get_automotive_parts_compatibility_policies" do + let(:client) { described_class.new(**settings) } + let(:scope) { client.sell.metadata.marketplace(marketplace_id: "EBAY_MOTORS_US") } + let(:settings) { yaml_fixture_file("settings.valid.yml") } + let(:url) do + "https://api.ebay.com/sell/metadata/v1/marketplace/EBAY_MOTORS_US/get_automotive_parts_compatibility_policies" + end + + before { stub_request(:get, url).to_return(response) } + subject { scope.get_automotive_parts_compatibility_policies } + + context "success" do + let(:response) do + open_fixture_file "sell/metadata/marketplace/get_automotive_parts_compatibility_policies/success" + end + + it "sends a request" do + subject + expect(a_request(:get, url)).to have_been_made + end + + it "returns automotive parts compatibility policies" do + expect(subject["automotivePartsCompatibilityPolicies"]).to be_an(Array) + expect(subject["automotivePartsCompatibilityPolicies"].count).to eq(1) + end + + describe "automotive parts compatibility policy" do + let(:policy) { subject["automotivePartsCompatibilityPolicies"].first } + + it "has proper attributes" do + expect(policy["categoryId"]).to eq("6028") + expect(policy["categoryTreeId"]).to eq("100") + expect(policy["maxNumberOfCompatibleVehicles"]).to eq(1000) + expect(policy["compatibleVehicleTypes"]).to eq(["US_CARS_TRUCKS", "US_MOTORCYCLES"]) + expect(policy["compatibilityBasedOn"]).to eq("ASSEMBLY") + end + end + end + + context "when no policies are available (204 No Content)" do + let(:response) { open_fixture_file "no_content" } + + it "returns an empty array for automotivePartsCompatibilityPolicies" do + expect(subject["automotivePartsCompatibilityPolicies"]).to eq([]) + end + end +end + From 96f499a58db908b5188147ff058d86d515afa783 Mon Sep 17 00:00:00 2001 From: Ulan Djamanbalaev Date: Thu, 12 Feb 2026 12:11:43 +0000 Subject: [PATCH 05/11] Add `sell.metadata.marketplace.get_listing_structure_policies` endpoint --- .../operations/sell/metadata/marketplace.rb | 1 + .../get_listing_structure_policies.rb | 19 ++++++++ .../get_listing_structure_policies/success | 14 ++++++ .../get_listing_structure_policies_spec.rb | 46 +++++++++++++++++++ 4 files changed, 80 insertions(+) create mode 100644 lib/ebay_api/operations/sell/metadata/marketplace/get_listing_structure_policies.rb create mode 100644 spec/fixtures/sell/metadata/marketplace/get_listing_structure_policies/success create mode 100644 spec/operations/sell/metadata/marketplace/get_listing_structure_policies_spec.rb diff --git a/lib/ebay_api/operations/sell/metadata/marketplace.rb b/lib/ebay_api/operations/sell/metadata/marketplace.rb index dc7b7c1..1eff753 100644 --- a/lib/ebay_api/operations/sell/metadata/marketplace.rb +++ b/lib/ebay_api/operations/sell/metadata/marketplace.rb @@ -9,6 +9,7 @@ class EbayAPI require_relative "marketplace/get_category_policies" require_relative "marketplace/get_classified_ad_policies" require_relative "marketplace/get_automotive_parts_compatibility_policies" + require_relative "marketplace/get_listing_structure_policies" end end end diff --git a/lib/ebay_api/operations/sell/metadata/marketplace/get_listing_structure_policies.rb b/lib/ebay_api/operations/sell/metadata/marketplace/get_listing_structure_policies.rb new file mode 100644 index 0000000..820bf40 --- /dev/null +++ b/lib/ebay_api/operations/sell/metadata/marketplace/get_listing_structure_policies.rb @@ -0,0 +1,19 @@ +# @see https://developer.ebay.com/api-docs/sell/metadata/resources/marketplace/methods/getListingStructurePolicies + +class EbayAPI + scope :sell do + scope :metadata do + scope :marketplace do + operation :get_listing_structure_policies do + path { "get_listing_structure_policies" } + http_method :get + + # When no policies are available, eBay returns 204 No Content. + # To provide a consistent API, we return an empty array instead. + response(204) { { "listingStructurePolicies" => [] } } + end + end + end + end +end + diff --git a/spec/fixtures/sell/metadata/marketplace/get_listing_structure_policies/success b/spec/fixtures/sell/metadata/marketplace/get_listing_structure_policies/success new file mode 100644 index 0000000..e620a97 --- /dev/null +++ b/spec/fixtures/sell/metadata/marketplace/get_listing_structure_policies/success @@ -0,0 +1,14 @@ +HTTP/1.1 200 OK +Content-Type: application/json + +{ + "listingStructurePolicies": [ + { + "categoryId": "625", + "categoryTreeId": "0", + "variationsSupported": true + } + ] +} + + diff --git a/spec/operations/sell/metadata/marketplace/get_listing_structure_policies_spec.rb b/spec/operations/sell/metadata/marketplace/get_listing_structure_policies_spec.rb new file mode 100644 index 0000000..03581a8 --- /dev/null +++ b/spec/operations/sell/metadata/marketplace/get_listing_structure_policies_spec.rb @@ -0,0 +1,46 @@ +RSpec.describe EbayAPI, ".sell.metadata.marketplace.get_listing_structure_policies" do + let(:client) { described_class.new(**settings) } + let(:scope) { client.sell.metadata.marketplace(marketplace_id: "EBAY_US") } + let(:settings) { yaml_fixture_file("settings.valid.yml") } + let(:url) do + "https://api.ebay.com/sell/metadata/v1/marketplace/EBAY_US/get_listing_structure_policies" + end + + before { stub_request(:get, url).to_return(response) } + subject { scope.get_listing_structure_policies } + + context "success" do + let(:response) do + open_fixture_file "sell/metadata/marketplace/get_listing_structure_policies/success" + end + + it "sends a request" do + subject + expect(a_request(:get, url)).to have_been_made + end + + it "returns listing structure policies" do + expect(subject["listingStructurePolicies"]).to be_an(Array) + expect(subject["listingStructurePolicies"].count).to eq(1) + end + + describe "listing structure policy" do + let(:policy) { subject["listingStructurePolicies"].first } + + it "has proper attributes" do + expect(policy["categoryId"]).to eq("625") + expect(policy["categoryTreeId"]).to eq("0") + expect(policy["variationsSupported"]).to eq(true) + end + end + end + + context "when no policies are available (204 No Content)" do + let(:response) { open_fixture_file "no_content" } + + it "returns an empty array for listingStructurePolicies" do + expect(subject["listingStructurePolicies"]).to eq([]) + end + end +end + From d4b1138f117d93e4c96b9b1aede4e7fd45be3669 Mon Sep 17 00:00:00 2001 From: Ulan Djamanbalaev Date: Thu, 12 Feb 2026 12:13:09 +0000 Subject: [PATCH 06/11] Add `sell.metadata.marketplace.get_listing_type_policies` endpoint --- .../operations/sell/metadata/marketplace.rb | 1 + .../marketplace/get_listing_type_policies.rb | 19 ++++++ .../get_listing_type_policies/success | 25 ++++++++ .../get_listing_type_policies_spec.rb | 62 +++++++++++++++++++ 4 files changed, 107 insertions(+) create mode 100644 lib/ebay_api/operations/sell/metadata/marketplace/get_listing_type_policies.rb create mode 100644 spec/fixtures/sell/metadata/marketplace/get_listing_type_policies/success create mode 100644 spec/operations/sell/metadata/marketplace/get_listing_type_policies_spec.rb diff --git a/lib/ebay_api/operations/sell/metadata/marketplace.rb b/lib/ebay_api/operations/sell/metadata/marketplace.rb index 1eff753..e46ea2c 100644 --- a/lib/ebay_api/operations/sell/metadata/marketplace.rb +++ b/lib/ebay_api/operations/sell/metadata/marketplace.rb @@ -10,6 +10,7 @@ class EbayAPI require_relative "marketplace/get_classified_ad_policies" require_relative "marketplace/get_automotive_parts_compatibility_policies" require_relative "marketplace/get_listing_structure_policies" + require_relative "marketplace/get_listing_type_policies" end end end diff --git a/lib/ebay_api/operations/sell/metadata/marketplace/get_listing_type_policies.rb b/lib/ebay_api/operations/sell/metadata/marketplace/get_listing_type_policies.rb new file mode 100644 index 0000000..df4d59f --- /dev/null +++ b/lib/ebay_api/operations/sell/metadata/marketplace/get_listing_type_policies.rb @@ -0,0 +1,19 @@ +# @see https://developer.ebay.com/api-docs/sell/metadata/resources/marketplace/methods/getListingTypePolicies + +class EbayAPI + scope :sell do + scope :metadata do + scope :marketplace do + operation :get_listing_type_policies do + path { "get_listing_type_policies" } + http_method :get + + # When no policies are available, eBay returns 204 No Content. + # To provide a consistent API, we return an empty array instead. + response(204) { { "listingTypePolicies" => [] } } + end + end + end + end +end + diff --git a/spec/fixtures/sell/metadata/marketplace/get_listing_type_policies/success b/spec/fixtures/sell/metadata/marketplace/get_listing_type_policies/success new file mode 100644 index 0000000..62fda7b --- /dev/null +++ b/spec/fixtures/sell/metadata/marketplace/get_listing_type_policies/success @@ -0,0 +1,25 @@ +HTTP/1.1 200 OK +Content-Type: application/json + +{ + "listingTypePolicies": [ + { + "categoryId": "625", + "categoryTreeId": "0", + "listingDurations": [ + { + "listingType": "AUCTION", + "durationValues": ["DAYS_3", "DAYS_5", "DAYS_7", "DAYS_10"] + }, + { + "listingType": "FIXED_PRICE_ITEM", + "durationValues": ["GTC"] + } + ], + "pickupDropOffEnabled": false, + "digitalGoodDeliveryEnabled": false + } + ] +} + + diff --git a/spec/operations/sell/metadata/marketplace/get_listing_type_policies_spec.rb b/spec/operations/sell/metadata/marketplace/get_listing_type_policies_spec.rb new file mode 100644 index 0000000..39d7437 --- /dev/null +++ b/spec/operations/sell/metadata/marketplace/get_listing_type_policies_spec.rb @@ -0,0 +1,62 @@ +RSpec.describe EbayAPI, ".sell.metadata.marketplace.get_listing_type_policies" do + let(:client) { described_class.new(**settings) } + let(:scope) { client.sell.metadata.marketplace(marketplace_id: "EBAY_US") } + let(:settings) { yaml_fixture_file("settings.valid.yml") } + let(:url) do + "https://api.ebay.com/sell/metadata/v1/marketplace/EBAY_US/get_listing_type_policies" + end + + before { stub_request(:get, url).to_return(response) } + subject { scope.get_listing_type_policies } + + context "success" do + let(:response) do + open_fixture_file "sell/metadata/marketplace/get_listing_type_policies/success" + end + + it "sends a request" do + subject + expect(a_request(:get, url)).to have_been_made + end + + it "returns listing type policies" do + expect(subject["listingTypePolicies"]).to be_an(Array) + expect(subject["listingTypePolicies"].count).to eq(1) + end + + describe "listing type policy" do + let(:policy) { subject["listingTypePolicies"].first } + + it "has proper attributes" do + expect(policy["categoryId"]).to eq("625") + expect(policy["categoryTreeId"]).to eq("0") + expect(policy["pickupDropOffEnabled"]).to eq(false) + expect(policy["digitalGoodDeliveryEnabled"]).to eq(false) + end + + it "has listing durations" do + expect(policy["listingDurations"]).to be_an(Array) + expect(policy["listingDurations"].count).to eq(2) + end + + it "has auction listing duration with proper attributes" do + auction = policy["listingDurations"].find { |ld| ld["listingType"] == "AUCTION" } + expect(auction["durationValues"]).to eq(["DAYS_3", "DAYS_5", "DAYS_7", "DAYS_10"]) + end + + it "has fixed price listing duration with proper attributes" do + fixed_price = policy["listingDurations"].find { |ld| ld["listingType"] == "FIXED_PRICE_ITEM" } + expect(fixed_price["durationValues"]).to eq(["GTC"]) + end + end + end + + context "when no policies are available (204 No Content)" do + let(:response) { open_fixture_file "no_content" } + + it "returns an empty array for listingTypePolicies" do + expect(subject["listingTypePolicies"]).to eq([]) + end + end +end + From f4ebbd8d19b5173669e1ce18028cc7e6bc92be71 Mon Sep 17 00:00:00 2001 From: Ulan Djamanbalaev Date: Thu, 12 Feb 2026 12:15:12 +0000 Subject: [PATCH 07/11] Add `sell.metadata.marketplace.get_motors_listing_policies` endpoint --- .../operations/sell/metadata/marketplace.rb | 1 + .../get_motors_listing_policies.rb | 19 ++++++ .../get_motors_listing_policies/success | 23 +++++++ .../get_motors_listing_policies_spec.rb | 61 +++++++++++++++++++ 4 files changed, 104 insertions(+) create mode 100644 lib/ebay_api/operations/sell/metadata/marketplace/get_motors_listing_policies.rb create mode 100644 spec/fixtures/sell/metadata/marketplace/get_motors_listing_policies/success create mode 100644 spec/operations/sell/metadata/marketplace/get_motors_listing_policies_spec.rb diff --git a/lib/ebay_api/operations/sell/metadata/marketplace.rb b/lib/ebay_api/operations/sell/metadata/marketplace.rb index e46ea2c..14ce202 100644 --- a/lib/ebay_api/operations/sell/metadata/marketplace.rb +++ b/lib/ebay_api/operations/sell/metadata/marketplace.rb @@ -11,6 +11,7 @@ class EbayAPI require_relative "marketplace/get_automotive_parts_compatibility_policies" require_relative "marketplace/get_listing_structure_policies" require_relative "marketplace/get_listing_type_policies" + require_relative "marketplace/get_motors_listing_policies" end end end diff --git a/lib/ebay_api/operations/sell/metadata/marketplace/get_motors_listing_policies.rb b/lib/ebay_api/operations/sell/metadata/marketplace/get_motors_listing_policies.rb new file mode 100644 index 0000000..3e95755 --- /dev/null +++ b/lib/ebay_api/operations/sell/metadata/marketplace/get_motors_listing_policies.rb @@ -0,0 +1,19 @@ +# @see https://developer.ebay.com/api-docs/sell/metadata/resources/marketplace/methods/getMotorsListingPolicies + +class EbayAPI + scope :sell do + scope :metadata do + scope :marketplace do + operation :get_motors_listing_policies do + path { "get_motors_listing_policies" } + http_method :get + + # When no policies are available, eBay returns 204 No Content. + # To provide a consistent API, we return an empty array instead. + response(204) { { "motorsListingPolicies" => [] } } + end + end + end + end +end + diff --git a/spec/fixtures/sell/metadata/marketplace/get_motors_listing_policies/success b/spec/fixtures/sell/metadata/marketplace/get_motors_listing_policies/success new file mode 100644 index 0000000..52d2fbc --- /dev/null +++ b/spec/fixtures/sell/metadata/marketplace/get_motors_listing_policies/success @@ -0,0 +1,23 @@ +HTTP/1.1 200 OK +Content-Type: application/json + +{ + "motorsListingPolicies": [ + { + "categoryId": "6028", + "categoryTreeId": "100", + "vinSupported": true, + "vrmSupported": false, + "kTypeSupported": true, + "epidSupported": true, + "depositSupported": true, + "minItemCompatibility": 1, + "maxItemCompatibility": 1000, + "ebayMotorsProAdFormatEnabled": "Disabled", + "localMarketAdFormatEnabled": "Disabled", + "sellerProvidedTitleSupported": true + } + ] +} + + diff --git a/spec/operations/sell/metadata/marketplace/get_motors_listing_policies_spec.rb b/spec/operations/sell/metadata/marketplace/get_motors_listing_policies_spec.rb new file mode 100644 index 0000000..d26e957 --- /dev/null +++ b/spec/operations/sell/metadata/marketplace/get_motors_listing_policies_spec.rb @@ -0,0 +1,61 @@ +RSpec.describe EbayAPI, ".sell.metadata.marketplace.get_motors_listing_policies" do + let(:client) { described_class.new(**settings) } + let(:scope) { client.sell.metadata.marketplace(marketplace_id: "EBAY_MOTORS_US") } + let(:settings) { yaml_fixture_file("settings.valid.yml") } + let(:url) do + "https://api.ebay.com/sell/metadata/v1/marketplace/EBAY_MOTORS_US/get_motors_listing_policies" + end + + before { stub_request(:get, url).to_return(response) } + subject { scope.get_motors_listing_policies } + + context "success" do + let(:response) do + open_fixture_file "sell/metadata/marketplace/get_motors_listing_policies/success" + end + + it "sends a request" do + subject + expect(a_request(:get, url)).to have_been_made + end + + it "returns motors listing policies" do + expect(subject["motorsListingPolicies"]).to be_an(Array) + expect(subject["motorsListingPolicies"].count).to eq(1) + end + + describe "motors listing policy" do + let(:policy) { subject["motorsListingPolicies"].first } + + it "has proper attributes" do + expect(policy["categoryId"]).to eq("6028") + expect(policy["categoryTreeId"]).to eq("100") + expect(policy["vinSupported"]).to eq(true) + expect(policy["vrmSupported"]).to eq(false) + expect(policy["kTypeSupported"]).to eq(true) + expect(policy["epidSupported"]).to eq(true) + expect(policy["depositSupported"]).to eq(true) + end + + it "has compatibility attributes" do + expect(policy["minItemCompatibility"]).to eq(1) + expect(policy["maxItemCompatibility"]).to eq(1000) + end + + it "has ad format attributes" do + expect(policy["ebayMotorsProAdFormatEnabled"]).to eq("Disabled") + expect(policy["localMarketAdFormatEnabled"]).to eq("Disabled") + expect(policy["sellerProvidedTitleSupported"]).to eq(true) + end + end + end + + context "when no policies are available (204 No Content)" do + let(:response) { open_fixture_file "no_content" } + + it "returns an empty array for motorsListingPolicies" do + expect(subject["motorsListingPolicies"]).to eq([]) + end + end +end + From d79bb0cfd50bafeae1b806d7ddee2b2386de5ed7 Mon Sep 17 00:00:00 2001 From: Ulan Djamanbalaev Date: Thu, 12 Feb 2026 12:16:43 +0000 Subject: [PATCH 08/11] Add `sell.metadata.marketplace.get_negotiated_price_policies` endpoint --- .../operations/sell/metadata/marketplace.rb | 1 + .../get_negotiated_price_policies.rb | 18 +++++++ .../get_negotiated_price_policies/success | 16 +++++++ .../get_negotiated_price_policies_spec.rb | 48 +++++++++++++++++++ 4 files changed, 83 insertions(+) create mode 100644 lib/ebay_api/operations/sell/metadata/marketplace/get_negotiated_price_policies.rb create mode 100644 spec/fixtures/sell/metadata/marketplace/get_negotiated_price_policies/success create mode 100644 spec/operations/sell/metadata/marketplace/get_negotiated_price_policies_spec.rb diff --git a/lib/ebay_api/operations/sell/metadata/marketplace.rb b/lib/ebay_api/operations/sell/metadata/marketplace.rb index 14ce202..2c0d32c 100644 --- a/lib/ebay_api/operations/sell/metadata/marketplace.rb +++ b/lib/ebay_api/operations/sell/metadata/marketplace.rb @@ -12,6 +12,7 @@ class EbayAPI require_relative "marketplace/get_listing_structure_policies" require_relative "marketplace/get_listing_type_policies" require_relative "marketplace/get_motors_listing_policies" + require_relative "marketplace/get_negotiated_price_policies" end end end diff --git a/lib/ebay_api/operations/sell/metadata/marketplace/get_negotiated_price_policies.rb b/lib/ebay_api/operations/sell/metadata/marketplace/get_negotiated_price_policies.rb new file mode 100644 index 0000000..7a8c5e5 --- /dev/null +++ b/lib/ebay_api/operations/sell/metadata/marketplace/get_negotiated_price_policies.rb @@ -0,0 +1,18 @@ +# @see https://developer.ebay.com/api-docs/sell/metadata/resources/marketplace/methods/getNegotiatedPricePolicies + +class EbayAPI + scope :sell do + scope :metadata do + scope :marketplace do + operation :get_negotiated_price_policies do + path { "get_negotiated_price_policies" } + http_method :get + + # When no policies are available, eBay returns 204 No Content. + # To provide a consistent API, we return an empty array instead. + response(204) { { "negotiatedPricePolicies" => [] } } + end + end + end + end +end diff --git a/spec/fixtures/sell/metadata/marketplace/get_negotiated_price_policies/success b/spec/fixtures/sell/metadata/marketplace/get_negotiated_price_policies/success new file mode 100644 index 0000000..25bc387 --- /dev/null +++ b/spec/fixtures/sell/metadata/marketplace/get_negotiated_price_policies/success @@ -0,0 +1,16 @@ +HTTP/1.1 200 OK +Content-Type: application/json + +{ + "negotiatedPricePolicies": [ + { + "categoryId": "625", + "categoryTreeId": "0", + "bestOfferAutoAcceptEnabled": true, + "bestOfferAutoDeclineEnabled": true, + "bestOfferCounterEnabled": true + } + ] +} + + diff --git a/spec/operations/sell/metadata/marketplace/get_negotiated_price_policies_spec.rb b/spec/operations/sell/metadata/marketplace/get_negotiated_price_policies_spec.rb new file mode 100644 index 0000000..c6a1f54 --- /dev/null +++ b/spec/operations/sell/metadata/marketplace/get_negotiated_price_policies_spec.rb @@ -0,0 +1,48 @@ +RSpec.describe EbayAPI, ".sell.metadata.marketplace.get_negotiated_price_policies" do + let(:client) { described_class.new(**settings) } + let(:scope) { client.sell.metadata.marketplace(marketplace_id: "EBAY_US") } + let(:settings) { yaml_fixture_file("settings.valid.yml") } + let(:url) do + "https://api.ebay.com/sell/metadata/v1/marketplace/EBAY_US/get_negotiated_price_policies" + end + + before { stub_request(:get, url).to_return(response) } + subject { scope.get_negotiated_price_policies } + + context "success" do + let(:response) do + open_fixture_file "sell/metadata/marketplace/get_negotiated_price_policies/success" + end + + it "sends a request" do + subject + expect(a_request(:get, url)).to have_been_made + end + + it "returns negotiated price policies" do + expect(subject["negotiatedPricePolicies"]).to be_an(Array) + expect(subject["negotiatedPricePolicies"].count).to eq(1) + end + + describe "negotiated price policy" do + let(:policy) { subject["negotiatedPricePolicies"].first } + + it "has proper attributes" do + expect(policy["categoryId"]).to eq("625") + expect(policy["categoryTreeId"]).to eq("0") + expect(policy["bestOfferAutoAcceptEnabled"]).to eq(true) + expect(policy["bestOfferAutoDeclineEnabled"]).to eq(true) + expect(policy["bestOfferCounterEnabled"]).to eq(true) + end + end + end + + context "when no policies are available (204 No Content)" do + let(:response) { open_fixture_file "no_content" } + + it "returns an empty array for negotiatedPricePolicies" do + expect(subject["negotiatedPricePolicies"]).to eq([]) + end + end +end + From bd4d47da555316258ff8c25746fbc4968d2dd225 Mon Sep 17 00:00:00 2001 From: Ulan Djamanbalaev Date: Thu, 12 Feb 2026 12:18:07 +0000 Subject: [PATCH 09/11] Add `sell.metadata.marketplace.get_return_policies` endpoint --- .../operations/sell/metadata/marketplace.rb | 1 + .../marketplace/get_return_policies.rb | 19 ++++++ .../marketplace/get_return_policies/success | 34 ++++++++++ .../marketplace/get_return_policies_spec.rb | 63 +++++++++++++++++++ 4 files changed, 117 insertions(+) create mode 100644 lib/ebay_api/operations/sell/metadata/marketplace/get_return_policies.rb create mode 100644 spec/fixtures/sell/metadata/marketplace/get_return_policies/success create mode 100644 spec/operations/sell/metadata/marketplace/get_return_policies_spec.rb diff --git a/lib/ebay_api/operations/sell/metadata/marketplace.rb b/lib/ebay_api/operations/sell/metadata/marketplace.rb index 2c0d32c..9559dae 100644 --- a/lib/ebay_api/operations/sell/metadata/marketplace.rb +++ b/lib/ebay_api/operations/sell/metadata/marketplace.rb @@ -13,6 +13,7 @@ class EbayAPI require_relative "marketplace/get_listing_type_policies" require_relative "marketplace/get_motors_listing_policies" require_relative "marketplace/get_negotiated_price_policies" + require_relative "marketplace/get_return_policies" end end end diff --git a/lib/ebay_api/operations/sell/metadata/marketplace/get_return_policies.rb b/lib/ebay_api/operations/sell/metadata/marketplace/get_return_policies.rb new file mode 100644 index 0000000..05bd332 --- /dev/null +++ b/lib/ebay_api/operations/sell/metadata/marketplace/get_return_policies.rb @@ -0,0 +1,19 @@ +# @see https://developer.ebay.com/api-docs/sell/metadata/resources/marketplace/methods/getReturnPolicies + +class EbayAPI + scope :sell do + scope :metadata do + scope :marketplace do + operation :get_return_policies do + path { "get_return_policies" } + http_method :get + + # When no policies are available, eBay returns 204 No Content. + # To provide a consistent API, we return an empty array instead. + response(204) { { "returnPolicies" => [] } } + end + end + end + end +end + diff --git a/spec/fixtures/sell/metadata/marketplace/get_return_policies/success b/spec/fixtures/sell/metadata/marketplace/get_return_policies/success new file mode 100644 index 0000000..02a9633 --- /dev/null +++ b/spec/fixtures/sell/metadata/marketplace/get_return_policies/success @@ -0,0 +1,34 @@ +HTTP/1.1 200 OK +Content-Type: application/json + +{ + "returnPolicies": [ + { + "categoryId": "625", + "categoryTreeId": "0", + "domestic": { + "returnsAcceptanceEnabled": true, + "policyDescriptionEnabled": false, + "returnShippingCostPayers": ["SELLER", "BUYER"], + "refundMethods": ["MONEY_BACK"], + "returnMethods": ["REPLACEMENT"], + "returnPeriods": [ + {"value": 14, "unit": "CALENDAR_DAY"}, + {"value": 30, "unit": "CALENDAR_DAY"} + ] + }, + "international": { + "returnsAcceptanceEnabled": true, + "policyDescriptionEnabled": false, + "returnShippingCostPayers": ["BUYER"], + "refundMethods": ["MONEY_BACK"], + "returnMethods": ["REPLACEMENT"], + "returnPeriods": [ + {"value": 30, "unit": "CALENDAR_DAY"} + ] + } + } + ] +} + + diff --git a/spec/operations/sell/metadata/marketplace/get_return_policies_spec.rb b/spec/operations/sell/metadata/marketplace/get_return_policies_spec.rb new file mode 100644 index 0000000..fbd0292 --- /dev/null +++ b/spec/operations/sell/metadata/marketplace/get_return_policies_spec.rb @@ -0,0 +1,63 @@ +RSpec.describe EbayAPI, ".sell.metadata.marketplace.get_return_policies" do + let(:client) { described_class.new(**settings) } + let(:scope) { client.sell.metadata.marketplace(marketplace_id: "EBAY_US") } + let(:settings) { yaml_fixture_file("settings.valid.yml") } + let(:url) do + "https://api.ebay.com/sell/metadata/v1/marketplace/EBAY_US/get_return_policies" + end + + before { stub_request(:get, url).to_return(response) } + subject { scope.get_return_policies } + + context "success" do + let(:response) do + open_fixture_file "sell/metadata/marketplace/get_return_policies/success" + end + + it "sends a request" do + subject + expect(a_request(:get, url)).to have_been_made + end + + it "returns return policies" do + expect(subject["returnPolicies"]).to be_an(Array) + expect(subject["returnPolicies"].count).to eq(1) + end + + describe "return policy" do + let(:policy) { subject["returnPolicies"].first } + + it "has proper attributes" do + expect(policy["categoryId"]).to eq("625") + expect(policy["categoryTreeId"]).to eq("0") + expect(policy["domestic"]).to be_a(Hash) + expect(policy["international"]).to be_a(Hash) + end + + it "has domestic policy with proper attributes" do + domestic = policy["domestic"] + expect(domestic["returnsAcceptanceEnabled"]).to eq(true) + expect(domestic["policyDescriptionEnabled"]).to eq(false) + expect(domestic["returnShippingCostPayers"]).to eq(["SELLER", "BUYER"]) + expect(domestic["refundMethods"]).to eq(["MONEY_BACK"]) + expect(domestic["returnMethods"]).to eq(["REPLACEMENT"]) + expect(domestic["returnPeriods"]).to be_an(Array) + end + + it "has return periods with proper attributes" do + period = policy["domestic"]["returnPeriods"].first + expect(period["value"]).to eq(14) + expect(period["unit"]).to eq("CALENDAR_DAY") + end + end + end + + context "when no policies are available (204 No Content)" do + let(:response) { open_fixture_file "no_content" } + + it "returns an empty array for returnPolicies" do + expect(subject["returnPolicies"]).to eq([]) + end + end +end + From a3e160a4e0c5b3522ddf589113b6293b05bb6739 Mon Sep 17 00:00:00 2001 From: Ulan Djamanbalaev Date: Thu, 12 Feb 2026 12:19:23 +0000 Subject: [PATCH 10/11] Add `sell.metadata.marketplace.get_shipping_policies` endpoint --- .../operations/sell/metadata/marketplace.rb | 1 + .../marketplace/get_shipping_policies.rb | 19 +++++++ .../marketplace/get_shipping_policies/success | 20 +++++++ .../marketplace/get_shipping_policies_spec.rb | 54 +++++++++++++++++++ 4 files changed, 94 insertions(+) create mode 100644 lib/ebay_api/operations/sell/metadata/marketplace/get_shipping_policies.rb create mode 100644 spec/fixtures/sell/metadata/marketplace/get_shipping_policies/success create mode 100644 spec/operations/sell/metadata/marketplace/get_shipping_policies_spec.rb diff --git a/lib/ebay_api/operations/sell/metadata/marketplace.rb b/lib/ebay_api/operations/sell/metadata/marketplace.rb index 9559dae..61a5bfc 100644 --- a/lib/ebay_api/operations/sell/metadata/marketplace.rb +++ b/lib/ebay_api/operations/sell/metadata/marketplace.rb @@ -14,6 +14,7 @@ class EbayAPI require_relative "marketplace/get_motors_listing_policies" require_relative "marketplace/get_negotiated_price_policies" require_relative "marketplace/get_return_policies" + require_relative "marketplace/get_shipping_policies" end end end diff --git a/lib/ebay_api/operations/sell/metadata/marketplace/get_shipping_policies.rb b/lib/ebay_api/operations/sell/metadata/marketplace/get_shipping_policies.rb new file mode 100644 index 0000000..c0243f6 --- /dev/null +++ b/lib/ebay_api/operations/sell/metadata/marketplace/get_shipping_policies.rb @@ -0,0 +1,19 @@ +# @see https://developer.ebay.com/api-docs/sell/metadata/resources/marketplace/methods/getShippingPolicies + +class EbayAPI + scope :sell do + scope :metadata do + scope :marketplace do + operation :get_shipping_policies do + path { "get_shipping_policies" } + http_method :get + + # When no policies are available, eBay returns 204 No Content. + # To provide a consistent API, we return an empty array instead. + response(204) { { "shippingPolicies" => [] } } + end + end + end + end +end + diff --git a/spec/fixtures/sell/metadata/marketplace/get_shipping_policies/success b/spec/fixtures/sell/metadata/marketplace/get_shipping_policies/success new file mode 100644 index 0000000..815b5b5 --- /dev/null +++ b/spec/fixtures/sell/metadata/marketplace/get_shipping_policies/success @@ -0,0 +1,20 @@ +HTTP/1.1 200 OK +Content-Type: application/json + +{ + "shippingPolicies": [ + { + "categoryId": "625", + "categoryTreeId": "0", + "shippingTermsRequired": true, + "handlingTimeEnabled": true, + "globalShippingEnabled": true, + "maxFlatShippingCost": { + "value": "20.0", + "currency": "USD" + } + } + ] +} + + diff --git a/spec/operations/sell/metadata/marketplace/get_shipping_policies_spec.rb b/spec/operations/sell/metadata/marketplace/get_shipping_policies_spec.rb new file mode 100644 index 0000000..d6462aa --- /dev/null +++ b/spec/operations/sell/metadata/marketplace/get_shipping_policies_spec.rb @@ -0,0 +1,54 @@ +RSpec.describe EbayAPI, ".sell.metadata.marketplace.get_shipping_policies" do + let(:client) { described_class.new(**settings) } + let(:scope) { client.sell.metadata.marketplace(marketplace_id: "EBAY_US") } + let(:settings) { yaml_fixture_file("settings.valid.yml") } + let(:url) do + "https://api.ebay.com/sell/metadata/v1/marketplace/EBAY_US/get_shipping_policies" + end + + before { stub_request(:get, url).to_return(response) } + subject { scope.get_shipping_policies } + + context "success" do + let(:response) do + open_fixture_file "sell/metadata/marketplace/get_shipping_policies/success" + end + + it "sends a request" do + subject + expect(a_request(:get, url)).to have_been_made + end + + it "returns shipping policies" do + expect(subject["shippingPolicies"]).to be_an(Array) + expect(subject["shippingPolicies"].count).to eq(1) + end + + describe "shipping policy" do + let(:policy) { subject["shippingPolicies"].first } + + it "has proper attributes" do + expect(policy["categoryId"]).to eq("625") + expect(policy["categoryTreeId"]).to eq("0") + expect(policy["shippingTermsRequired"]).to eq(true) + expect(policy["handlingTimeEnabled"]).to eq(true) + expect(policy["globalShippingEnabled"]).to eq(true) + end + + it "has max flat shipping cost with proper attributes" do + max_cost = policy["maxFlatShippingCost"] + expect(max_cost["value"]).to eq("20.0") + expect(max_cost["currency"]).to eq("USD") + end + end + end + + context "when no policies are available (204 No Content)" do + let(:response) { open_fixture_file "no_content" } + + it "returns an empty array for shippingPolicies" do + expect(subject["shippingPolicies"]).to eq([]) + end + end +end + From 2dae63d47faa920cda8dcec9c154e1ceed06f6ab Mon Sep 17 00:00:00 2001 From: Ulan Djamanbalaev Date: Thu, 12 Feb 2026 12:20:44 +0000 Subject: [PATCH 11/11] Add `sell.metadata.marketplace.get_site_visibility_policies` endpoint --- .../operations/sell/metadata/marketplace.rb | 1 + .../get_site_visibility_policies.rb | 19 ++++++++ .../get_site_visibility_policies/success | 14 ++++++ .../get_site_visibility_policies_spec.rb | 47 +++++++++++++++++++ 4 files changed, 81 insertions(+) create mode 100644 lib/ebay_api/operations/sell/metadata/marketplace/get_site_visibility_policies.rb create mode 100644 spec/fixtures/sell/metadata/marketplace/get_site_visibility_policies/success create mode 100644 spec/operations/sell/metadata/marketplace/get_site_visibility_policies_spec.rb diff --git a/lib/ebay_api/operations/sell/metadata/marketplace.rb b/lib/ebay_api/operations/sell/metadata/marketplace.rb index 61a5bfc..1f430ed 100644 --- a/lib/ebay_api/operations/sell/metadata/marketplace.rb +++ b/lib/ebay_api/operations/sell/metadata/marketplace.rb @@ -15,6 +15,7 @@ class EbayAPI require_relative "marketplace/get_negotiated_price_policies" require_relative "marketplace/get_return_policies" require_relative "marketplace/get_shipping_policies" + require_relative "marketplace/get_site_visibility_policies" end end end diff --git a/lib/ebay_api/operations/sell/metadata/marketplace/get_site_visibility_policies.rb b/lib/ebay_api/operations/sell/metadata/marketplace/get_site_visibility_policies.rb new file mode 100644 index 0000000..e3c6459 --- /dev/null +++ b/lib/ebay_api/operations/sell/metadata/marketplace/get_site_visibility_policies.rb @@ -0,0 +1,19 @@ +# @see https://developer.ebay.com/api-docs/sell/metadata/resources/marketplace/methods/getSiteVisibilityPolicies + +class EbayAPI + scope :sell do + scope :metadata do + scope :marketplace do + operation :get_site_visibility_policies do + path { "get_site_visibility_policies" } + http_method :get + + # When no policies are available, eBay returns 204 No Content. + # To provide a consistent API, we return an empty array instead. + response(204) { { "siteVisibilityPolicies" => [] } } + end + end + end + end +end + diff --git a/spec/fixtures/sell/metadata/marketplace/get_site_visibility_policies/success b/spec/fixtures/sell/metadata/marketplace/get_site_visibility_policies/success new file mode 100644 index 0000000..d1ca753 --- /dev/null +++ b/spec/fixtures/sell/metadata/marketplace/get_site_visibility_policies/success @@ -0,0 +1,14 @@ +HTTP/1.1 200 OK +Content-Type: application/json + +{ + "siteVisibilityPolicies": [ + { + "categoryId": "625", + "categoryTreeId": "0", + "crossBorderTradeNorthAmericaEnabled": true, + "crossBorderTradeGBEnabled": false, + "crossBorderTradeAustraliaEnabled": false + } + ] +} diff --git a/spec/operations/sell/metadata/marketplace/get_site_visibility_policies_spec.rb b/spec/operations/sell/metadata/marketplace/get_site_visibility_policies_spec.rb new file mode 100644 index 0000000..8a373c7 --- /dev/null +++ b/spec/operations/sell/metadata/marketplace/get_site_visibility_policies_spec.rb @@ -0,0 +1,47 @@ +RSpec.describe EbayAPI, ".sell.metadata.marketplace.get_site_visibility_policies" do + let(:client) { described_class.new(**settings) } + let(:scope) { client.sell.metadata.marketplace(marketplace_id: "EBAY_US") } + let(:settings) { yaml_fixture_file("settings.valid.yml") } + let(:url) do + "https://api.ebay.com/sell/metadata/v1/marketplace/EBAY_US/get_site_visibility_policies" + end + + before { stub_request(:get, url).to_return(response) } + subject { scope.get_site_visibility_policies } + + context "success" do + let(:response) do + open_fixture_file "sell/metadata/marketplace/get_site_visibility_policies/success" + end + + it "sends a request" do + subject + expect(a_request(:get, url)).to have_been_made + end + + it "returns site visibility policies" do + expect(subject["siteVisibilityPolicies"]).to be_an(Array) + expect(subject["siteVisibilityPolicies"].count).to eq(1) + end + + describe "site visibility policy" do + let(:policy) { subject["siteVisibilityPolicies"].first } + + it "has proper attributes" do + expect(policy["categoryId"]).to eq("625") + expect(policy["categoryTreeId"]).to eq("0") + expect(policy["crossBorderTradeNorthAmericaEnabled"]).to eq(true) + expect(policy["crossBorderTradeGBEnabled"]).to eq(false) + expect(policy["crossBorderTradeAustraliaEnabled"]).to eq(false) + end + end + end + + context "when no policies are available (204 No Content)" do + let(:response) { open_fixture_file "no_content" } + + it "returns an empty array for siteVisibilityPolicies" do + expect(subject["siteVisibilityPolicies"]).to eq([]) + end + end +end