From a36412ba39ba54be2e25a572f64511f6b98792b9 Mon Sep 17 00:00:00 2001 From: Yevhen Viktorov <62760+yevgenko@users.noreply.github.com> Date: Thu, 4 Jun 2026 17:50:09 +0100 Subject: [PATCH] Add `sell.account.rate_table.index` endpoint To retrieve a seller's shipping rate tables --- lib/ebay_api/operations/sell/account.rb | 1 + .../operations/sell/account/rate_table.rb | 11 +++++++ .../sell/account/rate_table/index.rb | 16 ++++++++++ .../sell/account/rate_table/index/success | 6 ++++ .../sell/account/rate_table/index/success.yml | 6 ++++ .../sell/account/rate_table/index_spec.rb | 32 +++++++++++++++++++ 6 files changed, 72 insertions(+) create mode 100644 lib/ebay_api/operations/sell/account/rate_table.rb create mode 100644 lib/ebay_api/operations/sell/account/rate_table/index.rb create mode 100644 spec/fixtures/sell/account/rate_table/index/success create mode 100644 spec/fixtures/sell/account/rate_table/index/success.yml create mode 100644 spec/operations/sell/account/rate_table/index_spec.rb diff --git a/lib/ebay_api/operations/sell/account.rb b/lib/ebay_api/operations/sell/account.rb index 10e2596..5dd9c27 100644 --- a/lib/ebay_api/operations/sell/account.rb +++ b/lib/ebay_api/operations/sell/account.rb @@ -12,6 +12,7 @@ class EbayAPI require_relative "account/return_policy" require_relative "account/payment_policy" require_relative "account/payments_program" + require_relative "account/rate_table" end end end diff --git a/lib/ebay_api/operations/sell/account/rate_table.rb b/lib/ebay_api/operations/sell/account/rate_table.rb new file mode 100644 index 0000000..381be8f --- /dev/null +++ b/lib/ebay_api/operations/sell/account/rate_table.rb @@ -0,0 +1,11 @@ +class EbayAPI + scope :sell do + scope :account do + scope :rate_table do + path { "rate_table" } + end + end + end +end + +require_relative "rate_table/index" \ No newline at end of file diff --git a/lib/ebay_api/operations/sell/account/rate_table/index.rb b/lib/ebay_api/operations/sell/account/rate_table/index.rb new file mode 100644 index 0000000..e3b0f74 --- /dev/null +++ b/lib/ebay_api/operations/sell/account/rate_table/index.rb @@ -0,0 +1,16 @@ +class EbayAPI + scope :sell do + scope :account do + scope :rate_table do + # @see https://developer.ebay.com/api-docs/sell/account/resources/rate_table/methods/getRateTables + operation :index do + option :site, Site + + path { "/" } + query { { marketplace_id: site.key } } + http_method :get + end + end + end + end +end diff --git a/spec/fixtures/sell/account/rate_table/index/success b/spec/fixtures/sell/account/rate_table/index/success new file mode 100644 index 0000000..1f7eb80 --- /dev/null +++ b/spec/fixtures/sell/account/rate_table/index/success @@ -0,0 +1,6 @@ +HTTP/1.1 200 OK +Content-Length: 135 +Content-Type: application/json + +{"rateTables":[{"rateTableId":"5048772018","countryCode":"GB","name":"Domestic_Default","locality":"DOMESTIC"}]} + diff --git a/spec/fixtures/sell/account/rate_table/index/success.yml b/spec/fixtures/sell/account/rate_table/index/success.yml new file mode 100644 index 0000000..6f563e8 --- /dev/null +++ b/spec/fixtures/sell/account/rate_table/index/success.yml @@ -0,0 +1,6 @@ +--- +rateTables: + - rateTableId: "5048772018" + countryCode: "GB" + name: "Domestic_Default" + locality: "DOMESTIC" diff --git a/spec/operations/sell/account/rate_table/index_spec.rb b/spec/operations/sell/account/rate_table/index_spec.rb new file mode 100644 index 0000000..63535c9 --- /dev/null +++ b/spec/operations/sell/account/rate_table/index_spec.rb @@ -0,0 +1,32 @@ +RSpec.describe EbayAPI, ".sell.account.rate_table.index" do + let(:client) { described_class.new(**settings) } + let(:scope) { client.sell.account(version: version).rate_table } + let(:settings) { yaml_fixture_file("settings.valid.yml") } + let(:version) { "1.2.0" } + let(:url) do + "https://api.ebay.com/sell/account/v1/rate_table/" \ + "?marketplace_id=EBAY_US" + end + + before { stub_request(:get, url).to_return(response) } + subject { scope.index } + + context "success" do + let(:response) do + open_fixture_file "sell/account/rate_table/index/success" + end + + let(:rate_tables) do + yaml_fixture_file "sell/account/rate_table/index/success.yml" + end + + it "sends a request" do + subject + expect(a_request(:get, url)).to have_been_made + end + + it "returns the rate tables" do + expect(subject).to eq rate_tables + end + end +end