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
39 changes: 39 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
name: CI

on:
push:
branches:
- '**'
pull_request:
branches:
- '**'

jobs:
test:
name: Ruby ${{ matrix.ruby }} Tests
runs-on: ubuntu-latest

strategy:
fail-fast: false
matrix:
ruby:
- '3.0'
- '3.1'
- '3.2'
- '3.3'

steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Set up Ruby
uses: ruby/setup-ruby@v1
with:
ruby-version: ${{ matrix.ruby }}
bundler-cache: true

- name: Install dependencies
run: bundle install --jobs 4 --retry 3

- name: Run tests
run: bundle exec rake spec
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# [WIP] EbayAPI
[![Build Status](https://github.com/main24/ebay_api/actions/workflows/test.yml/badge.svg?branch=support-catalog-product-search)](https://github.com/main24/ebay_api/actions/workflows/test.yml)

Ruby client to eBay RESTful JSON API

Expand Down
1 change: 1 addition & 0 deletions config/versions.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ commerce:
taxonomy: "1.0.0"
notifications: "1.0.0"
catalog: "1_beta.1.0"
metadata: "1.0.0"
sell:
account: "1.1.0"
analytics: "1.0.0"
Expand Down
4 changes: 2 additions & 2 deletions ebay_api.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@ Gem::Specification.new do |gem|
gem.test_files = gem.files.grep(/^spec/)
gem.extra_rdoc_files = Dir["README.md", "LICENSE", "CHANGELOG.md"]

gem.required_ruby_version = ">= 2.2"
gem.required_ruby_version = ">= 3.0"

gem.add_runtime_dependency "evil-client", "~> 3.0", ">= 3.0.1"
gem.add_runtime_dependency "evil-client", "~> 3.2", ">= 3.2.0"
gem.add_runtime_dependency "dry-equalizer"

gem.add_development_dependency "rake", ">= 10"
Expand Down
1 change: 1 addition & 0 deletions lib/ebay_api/operations/commerce.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,6 @@ class EbayAPI
require_relative "commerce/catalog"
require_relative "commerce/notification"
require_relative "commerce/taxonomy"
require_relative "commerce/metadata"
end
end
13 changes: 13 additions & 0 deletions lib/ebay_api/operations/commerce/metadata.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#
# eBay Metadata API
# @see https://developer.ebay.com/api-docs/sell/metadata/overview.html
#
class EbayAPI
scope :commerce do
scope :metadata do
path { "catalog/v#{EbayAPI::COMMERCE_METADATA_VERSION.split(/\s|\./).first}" }

require_relative "metadata/marketplace"
end
end
end
12 changes: 12 additions & 0 deletions lib/ebay_api/operations/commerce/metadata/marketplace.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
class EbayAPI
scope :commerce do
scope :metadata do
scope :marketplace do
path { "marketplace/#{marketplace_id}" }
option :marketplace_id

require_relative "marketplace/get_item_condition_policies"
end
end
end
end
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
class EbayAPI
scope :commerce do
scope :metadata do
scope :marketplace do
operation :get_item_condition_policies do
path { "get_item_condition_policies" }
http_method :get
end
end
end
end
end
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
HTTP/1.1 200 OK
Content-Length: 500
Content-Type: application/json

{
"itemConditionPolicies": [
{
"categoryId": "625",
"categoryTreeId": "0",
"itemConditionRequired": true,
"itemConditions": [
{
"conditionDescription": "Brand new, unused, and unworn",
"conditionId": "1000"
},
{
"conditionDescription": "Pre-owned but in excellent condition",
"conditionId": "3000"
}
]
}
]
}

Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@

RSpec.describe EbayAPI, ".commerce.metadata.marketplace.get_item_condition_policies" do
let(:client) { described_class.new(**settings) }
let(:scope) { client.commerce.metadata.marketplace(marketplace_id: "EBAY_US") }
let(:settings) { yaml_fixture_file("settings.valid.yml") }
let(:url) do
"https://api.ebay.com/commerce/catalog/v1/marketplace/EBAY_US/get_item_condition_policies"
end

before { stub_request(:get, url).to_return(response) }
subject { scope.get_item_condition_policies }

context "success" do
let(:response) do
open_fixture_file "commerce/metadata/marketplace/get_item_condition_policies/success"
end

it "sends a request" do
subject
expect(a_request(:get, url)).to have_been_made
end

it "returns item condition policies" do
expect(subject["itemConditionPolicies"]).to be_an(Array)
expect(subject["itemConditionPolicies"].count).to eq(1)
end

describe "item condition policy" do
let(:policy) { subject["itemConditionPolicies"].first }

it "has proper attributes" do
expect(policy["categoryId"]).to eq("625")
expect(policy["categoryTreeId"]).to eq("0")
expect(policy["itemConditionRequired"]).to eq(true)
expect(policy["itemConditions"]).to be_an(Array)
end

it "has item conditions with proper attributes" do
condition = policy["itemConditions"].first
expect(condition["conditionId"]).to eq("1000")
expect(condition["conditionDescription"]).to eq("Brand new, unused, and unworn")
end
end
end
end