Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions lib/ebay_api/operations/sell/account.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
11 changes: 11 additions & 0 deletions lib/ebay_api/operations/sell/account/rate_table.rb
Original file line number Diff line number Diff line change
@@ -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"
16 changes: 16 additions & 0 deletions lib/ebay_api/operations/sell/account/rate_table/index.rb
Original file line number Diff line number Diff line change
@@ -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
6 changes: 6 additions & 0 deletions spec/fixtures/sell/account/rate_table/index/success
Original file line number Diff line number Diff line change
@@ -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"}]}

6 changes: 6 additions & 0 deletions spec/fixtures/sell/account/rate_table/index/success.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
rateTables:
- rateTableId: "5048772018"
countryCode: "GB"
name: "Domestic_Default"
locality: "DOMESTIC"
32 changes: 32 additions & 0 deletions spec/operations/sell/account/rate_table/index_spec.rb
Original file line number Diff line number Diff line change
@@ -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
Loading