Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
61 commits
Select commit Hold shift + click to select a range
49f73cf
Add model for eBay program types
nepalez Aug 7, 2018
d5e3312
Add operation account/program/opt_in
nepalez Aug 7, 2018
68fb65b
Fix security issue in the gemspec
nepalez Aug 7, 2018
26ae8d9
Merge pull request #7 from nepalez/sell/account/program/opt_in
nepalez Aug 7, 2018
994da34
Add fulfillment_policy.delete method call
nepalez Aug 9, 2018
606bbae
Add fulfillment_policy.get method call
nepalez Aug 9, 2018
cb2527b
Add fulfillment_policy.get_by_name method call
nepalez Aug 9, 2018
9eaab94
Add fulfillment_policy.index method call
nepalez Aug 9, 2018
de6dd90
Add fulfillment_policy.create method call
nepalez Aug 9, 2018
5f47149
Add fulfillment_policy.update method call
nepalez Aug 9, 2018
856adf8
Merge pull request #8 from nepalez/sell/account/fulfillment_policy
nepalez Aug 9, 2018
ff1f3fb
Add all operations for account.return_policy
nepalez Aug 9, 2018
2932e92
Merge pull request #9 from nepalez/sell/account/return_policy
nepalez Aug 9, 2018
0bb993c
Send the site and data separated to policies create/update methods
nepalez Aug 10, 2018
c68b830
Fix rubocop
nepalez Aug 21, 2018
4cb90aa
Fix keys of multilanguage sites
nepalez Aug 21, 2018
caec776
Add logger
nepalez Aug 21, 2018
523fbfa
Fix update policy methods from POST to PUT
nepalez Sep 3, 2018
574f0e9
Increase maximum allowed PL ad bid value to 100%
Envek Sep 18, 2018
2a467a2
Fix the case when eBay responds with empty body
nepalez Oct 8, 2018
4f17e95
Add optional #data information to EbayAPI::Error exception
nepalez Oct 8, 2018
af53508
More verbose exception messages on access token refresh failures
Envek Nov 7, 2018
5341855
Add support for eBay Developer APIs
Envek Nov 8, 2018
df3ba9e
Add RubyMine .idea folder to .gitignore
nepalez Jun 18, 2019
db277d7
Update processing of business error 35077
nepalez Jun 18, 2019
8fe2510
Handle errors in responses to marketing campaings
nepalez Jun 18, 2019
b2719b8
Handle unauthorized_client error with RefreshTokenInvalid exception
nepalez Sep 23, 2019
d6725d3
Implement payments_program
nepalez Feb 16, 2021
29b1770
Fix rubocop issues
nepalez Feb 16, 2021
f2d2c82
Bump v0.0.2
nepalez Feb 16, 2021
e0e86ab
Add application token retrieving
mrexox Apr 28, 2021
496cfe3
Add commerce/notifications/public_key operation
mrexox Apr 29, 2021
4f8e848
Fix typo with notification url
mrexox May 11, 2021
8e7b011
Update CHANGELOG
mrexox May 11, 2021
ab4b8c0
Merge pull request #11 from mrexox/feature/add-application-token-retr…
nepalez May 12, 2021
ceb2da8
Add taxonomy API (#12)
mrexox Dec 1, 2021
d6dce11
Save heavy responses to a file for fetch_item_aspects (#13)
mrexox Dec 13, 2021
52d18f6
Add payment policy operations
SSDany Dec 9, 2021
9e544a2
Add payment policy operations specs
SSDany Dec 10, 2021
aa76249
Fix 'get_by_name' policy operation paths, fix broken specs
SSDany Dec 10, 2021
cbac0d2
Try use longMessage on some 4xx errors
SSDany Dec 10, 2021
ab2b3e1
Remove strange to_h to to_s aliases from BidPercentage model
SSDany Dec 10, 2021
5b06c6b
Bump webmock to 3.14
SSDany Dec 10, 2021
0abdd43
Bump gem version to 0.0.6
SSDany Dec 22, 2021
81ad857
Merge pull request #14 from nepalez/payment-policy-operations
SSDany Jan 14, 2022
d1330c9
Add ability to request to product searching of CatalogAPI
ulandj Apr 25, 2018
e694fac
Fix failing specs
main24 Oct 10, 2022
e03784f
Add a method that returns full response of application access token r…
main24 Nov 15, 2023
483738c
Allow sending params api_context and api_name to getRateLimits endpoi…
main24 Nov 20, 2023
50747d1
Fix Site initialization to handle hash arguments from Evil::Client::D…
ulandj Nov 20, 2025
9b724d1
Configure I18n load path for eBay API locale files
ulandj Nov 20, 2025
104c23b
Merge pull request #1 from main24/fix-ebay-api-initialization-with-si…
ulandj Nov 21, 2025
6b61381
Fix site code type for Russia
Dec 4, 2025
765e927
Fix Ruby 3.0+ keyword argument issues and fix tests
Dec 4, 2025
7485daa
Add Metadata `item_condition_policies` API
Dec 4, 2025
94a4ad3
Add a GitHub action for running tests and update the minimum supporte…
Dec 5, 2025
5d89b85
Merge pull request #5 from main24/github-action-to-run-tests
ulandj Dec 5, 2025
73e2214
Merge pull request #3 from main24/fix-tests-and-some-changes-to-suppo…
ulandj Dec 5, 2025
e61b61e
Merge pull request #4 from main24/add-item-conditions-policy-metadata…
ulandj Dec 5, 2025
7983c67
Fix get_item_condition_policies Metadata endpoint location
Dec 10, 2025
825a04d
Merge pull request #6 from main24/fix-get-item-condition-metadata-end…
ulandj Dec 10, 2025
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
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,4 @@
/tmp/
*.gem
.rspec_status
*.yml
.idea/
16 changes: 12 additions & 4 deletions .rubocop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@ AllCops:
DisplayCopNames: true
DisplayStyleGuide: true
StyleGuideCopsOnly: true
TargetRubyVersion: 2.3
TargetRubyVersion: 2.6
NewCops: enable

Metrics/LineLength:
AllowHeredoc: true
Expand All @@ -12,6 +13,9 @@ Metrics/LineLength:
- http
- https

Layout/SpaceInLambdaLiteral:
Enabled: false

Style/CaseEquality:
Enabled: false

Expand All @@ -36,8 +40,12 @@ Style/PercentLiteralDelimiters:
Style/RaiseArgs:
Enabled: false

Style/SpaceInLambdaLiteral:
Enabled: false

Style/StringLiterals:
EnforcedStyle: double_quotes

Style/IfUnlessModifier:
Enabled: false

Lint/ConstantDefinitionInBlock:
Exclude:
- spec/**/*
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,13 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](http://keepachangelog.com/)
and this project adheres to [Semantic Versioning](http://semver.org/).

## [0.0.3]

### Added

- Method to retrieve Application token
- [getPublicKey](https://developer.ebay.com/api-docs/commerce/notification/resources/public_key/methods/getPublicKey) request.

## [0.0.1] - To be released

This is a first public release.
Expand Down
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
3 changes: 3 additions & 0 deletions config/dictionary.yml
Original file line number Diff line number Diff line change
Expand Up @@ -1016,6 +1016,9 @@
- NONE
- PRE_CHECKOUT
- DURING_CHECKOUT
:program_type: # https://developer.ebay.com/api-docs/sell/account/types/api:ProgramTypeEnum
- OUT_OF_STOCK_CONTROL
- SELLING_POLICY_MANAGEMENT
:refund_status: # https://developer.ebay.com/api-docs/sell/fulfillment/types/sel:RefundStatusEnum
- code: FAILED
requested: true
Expand Down
2 changes: 1 addition & 1 deletion config/locales/en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ en:
unsupported_marketplace: You can't use Promoted Listings at %{site}
ebay_api/funding_strategy:
bid_wrong_format: Promoted listing ad fee can only contain 1 fractional digit, you provided %(value)
bid_out_of_range: Promoted listing ad fee must be from 1% to 20%, you provided %(value)
bid_out_of_range: Promoted listing ad fee must be from 1% to 100%, you provided %(value)
unsupported_funding_model: You can't use %(model) funding model, only COST_PER_SALE is allowed
sites:
'EBAY-AT': 'Austrian'
Expand Down
8 changes: 4 additions & 4 deletions config/sites.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
:country: BE
:currencies: [EUR]
:host: www.ebay.be
:key: EBAY_BE_FR
:key: EBAY_BE
:languages: [fr-BE]
- :id: 71
:code: EBAY-FR
Expand Down Expand Up @@ -78,7 +78,7 @@
:country: BE
:currencies: [EUR]
:host: www.ebay.be
:key: EBAY_BE_NL
:key: EBAY_BE
:languages: [nl-BE]
- :id: 146
:code: EBAY-NL
Expand Down Expand Up @@ -148,7 +148,7 @@
:country: CA
:currencies: [USD, CAD]
:host: www.cafr.ebay.ca
:key: EBAY_CA_FR
:key: EBAY_CA
:languages: [fr-CA]
- :id: 211
:code: EBAY-PH
Expand All @@ -165,7 +165,7 @@
:key: EBAY_PL
:languages: [pl-PL]
- :id: 215
:code: EBAY-US
:code: EBAY-RU
:country: RU
:currencies: [RUB]
:host: ebay.com/sch/Russia
Expand Down
8 changes: 6 additions & 2 deletions config/versions.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,15 @@ buy:
marketing: "1_beta.0.0"
order: "1_beta.7.0"
commerce:
taxonomy: "1_beta.0.0"
taxonomy: "1.0.0"
notifications: "1.0.0"
catalog: "1_beta.1.0"
sell:
account: "1.1.0"
analytics: "1.0.0"
fullfillemt: "1.2.0"
inventory: "1.1.0"
marketing: "1.3.0"
marketing: "1.4.0"
metadata: "1.1.0"
developer:
analytics: "1_beta.0.0"
10 changes: 5 additions & 5 deletions ebay_api.gemspec
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Gem::Specification.new do |gem|
gem.name = "ebay_api"
gem.version = "0.0.1"
gem.version = "0.0.6"
gem.author = "Andrew Kozin (nepalez)"
gem.email = "andrew.kozin@gmail.com"
gem.homepage = "https://github.com/nepalez/sms_aero"
Expand All @@ -11,16 +11,16 @@ 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"
gem.add_development_dependency "rspec", "~> 3.0"
gem.add_development_dependency "rspec-its", "~> 1.2"
gem.add_development_dependency "rubocop", "~> 0.42"
gem.add_development_dependency "rubocop", "~> 0.49"
gem.add_development_dependency "timecop", "~> 0.9"
gem.add_development_dependency "webmock", "~> 2.1"
gem.add_development_dependency "webmock", "~> 3.14"
gem.add_development_dependency "httplog"
end
28 changes: 21 additions & 7 deletions lib/ebay_api.rb
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,12 @@ class EbayAPI < Evil::Client
require_relative "ebay_api/middlewares"
require_relative "ebay_api/exceptions"

I18n.load_path += Dir[File.join(GEM_ROOT, *%w[config locales ** *.{yml,yaml}])]

class << self
attr_accessor :logger
end

option :token
option :site, Site, optional: true
option :language, Language, optional: true
Expand All @@ -41,10 +47,10 @@ class EbayAPI < Evil::Client
errors.add :wrong_language, language: language, site: site
end

format "json"
path { "https://api#{".sandbox" if sandbox}.ebay.com/" }
format "json"
path { "https://api#{".sandbox" if sandbox}.ebay.com/" }

middleware JSONResponse
middleware { [LogRequest, JSONResponse] }

security do
token_value = token.respond_to?(:call) ? token.call : token
Expand All @@ -61,28 +67,36 @@ class EbayAPI < Evil::Client
}.compact
end

response(200) { |_, _, (data, *)| data }
response(200, 201) { |_, _, (data, *)| data }

response(204) { true }

# https://developer.ebay.com/api-docs/static/handling-error-messages.html
response(400, 401, 409) do |_, _, (data, *)|
case (code = data.dig("errors", 0, "errorId"))
data = data.to_h
error = data.dig("errors", 0) || {}
code = error["errorId"]
message = error["longMessage"] || error["message"]

case code
when 1001
message = data.dig("errors", 0, "longMessage")
raise InvalidAccessToken.new(code: code), message
else
raise Error.new(code: code), data.dig("errors", 0, "message")
raise Error.new(code: code, data: data), message
end
end

# https://go.developer.ebay.com/api-call-limits
response(429) do |_, _, (data, *)|
data = data.to_h
error = data.dig("errors", 0) || {}
code = error["errorId"]
message = error["longMessage"] || error["message"]
raise RequestLimitExceeded.new(code: code), message
end

response(500) do |_, _, (data, *)|
data = data.to_h
code = data.dig("errors", 0, "errorId")
message =
data.dig("errors", 0, "longMessage") || data.dig("errors", 0, "message")
Expand Down
5 changes: 3 additions & 2 deletions lib/ebay_api/exceptions.rb
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
class EbayAPI
class Error < RuntimeError
attr_reader :code
attr_reader :code, :data

def initialize(*args, code: nil, **)
def initialize(*args, code: nil, data: nil, **)
super(*args)
@code = code
@data = data
end
end

Expand Down
2 changes: 2 additions & 0 deletions lib/ebay_api/middlewares.rb
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
require_relative "middlewares/json_response"
require_relative "middlewares/save_to_file_response"
require_relative "middlewares/paginated_collection"
require_relative "middlewares/log_request"
12 changes: 11 additions & 1 deletion lib/ebay_api/middlewares/json_response.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,17 @@ def initialize(app)

def call(env)
status, headers, body = @app.call(env)
[status, headers, body.map { |b| JSON.parse(b) unless b&.empty? }]

[status, headers, body.map { |b| parse(b) }]
end

private

def parse(body)
return unless body
return if body.empty?

JSON.parse(body)
end
end
end
40 changes: 40 additions & 0 deletions lib/ebay_api/middlewares/log_request.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
class EbayAPI
class LogRequest
def initialize(app)
@app = app
end

def call(env)
log_request(env)
@app.call(env).tap { |output| log_response(output) }
end

private

def logger
@logger ||= EbayAPI.logger
end

def log_info(key, data = nil)
logger.info "[EbayAPI] | #{format('%9s', key)} | #{data}"
end

def log_request(env)
return unless logger
log_info "REQUEST:"
log_info "Url", env["PATH_INFO"]
log_info "Method", env["REQUEST_METHOD"]
log_info "Headers", env["HTTP_Variables"]
log_info "Body", env["rack.input"]
end

def log_response(output)
return unless logger
status, headers, body = output
log_info "RESPONSE:"
log_info "Status", status
log_info "Headers", headers
log_info "Body", body
end
end
end
29 changes: 29 additions & 0 deletions lib/ebay_api/middlewares/save_to_file_response.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
require "securerandom"

# Parses gzipped response
class EbayAPI
class SaveToFileResponse
def initialize(app)
@app = app
end

def call(env)
status, headers, body = @app.call(env)

[status, headers, body.map { |b| save(b) }]
end

private

def save(body)
return unless body
return if body.empty?

file = File.new("/tmp/ebay-api-response-#{SecureRandom.hex}", "w+b")
file.write(body)
file.flush
file.close
{ "filename" => file.path }.to_json
end
end
end
1 change: 1 addition & 0 deletions lib/ebay_api/models.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,4 @@
require_relative "models/campaign"
require_relative "models/create_campaign_request"
require_relative "models/funding_strategy"
require_relative "models/program_type"
2 changes: 1 addition & 1 deletion lib/ebay_api/models/amount.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ class Amount < Evil::Client::Model
option :value, ->(v) { v.to_f.round(2) }
option :currency, Currency

validate { errors.add :negative_value, to_h if value.negative? }
validate { errors.add :negative_value, **to_h if value.negative? }

def to_h
{ value: value.to_s, currency: currency.code }
Expand Down
Loading