Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
56 commits
Select commit Hold shift + click to select a range
f6048f1
Added getSubscription endpoint for account_api
Halvanhelv Nov 7, 2022
de84291
Merge pull request #3 from ebaymag/feature/account_api_subscription
Halvanhelv Nov 9, 2022
1efc277
fix bug
May 17, 2023
ec6fb54
Merge pull request #5 from ebaymag/fix_program_get
YoungSpecial May 17, 2023
6691f1b
translation api
YoungSpecial Nov 14, 2023
ffbe0e0
findSellerStandardsProfiles api
YoungSpecial Nov 18, 2023
5abde26
findSellerStandardsProfiles api
YoungSpecial Nov 18, 2023
ca9630a
Merge pull request #7 from ebaymag/feature/seller_standards_profile
YoungSpecial Nov 21, 2023
7fb9f00
add log
YoungSpecial Dec 7, 2023
2f1769f
Merge pull request #8 from ebaymag/feature/add_request_log
YoungSpecial Dec 7, 2023
1de4338
add log
YoungSpecial Dec 12, 2023
bdf4550
Merge pull request #9 from ebaymag/feature/add_request_log
YoungSpecial Dec 12, 2023
48de866
Merge pull request #6 from ebaymag/feature/translation_api
YoungSpecial Jan 9, 2024
7487d41
add response parameters to Error
YoungSpecial Jan 25, 2024
33873bc
add response parameters to Error
YoungSpecial Jan 26, 2024
e6a6df7
add response parameters to Error
YoungSpecial Jan 26, 2024
e3d4ad4
add response parameters to Error
YoungSpecial Jan 26, 2024
7669e22
add response parameters to Error
YoungSpecial Jan 26, 2024
28158ed
add response parameters to Error
YoungSpecial Jan 26, 2024
fb7bf69
add response parameters to Error
YoungSpecial Jan 26, 2024
c0a9b40
add response parameters to Error
YoungSpecial Jan 26, 2024
8a7c3c9
add response parameters to Error
YoungSpecial Jan 26, 2024
99821cc
Merge pull request #10 from ebaymag/feature/add_response_parameter
YoungSpecial Jan 26, 2024
7bf9a6f
process ebaymag internal api.
YoungSpecial Mar 4, 2024
935198a
process ebaymag internal api.
YoungSpecial Mar 4, 2024
10ee0cd
process ebaymag internal api.
YoungSpecial Mar 4, 2024
fae610e
process ebaymag internal api.
YoungSpecial Mar 4, 2024
dd6083f
process ebaymag internal api.
YoungSpecial Mar 4, 2024
b7c7780
process ebaymag internal api.
YoungSpecial Mar 4, 2024
9fafb9d
process ebaymag internal api.
YoungSpecial Mar 4, 2024
cceb67f
change url
YoungSpecial Mar 4, 2024
288f690
change to real url
YoungSpecial Mar 21, 2024
9d0450f
add poll message
YoungSpecial Mar 21, 2024
e348934
Merge pull request #11 from ebaymag/feature/CBTEMAG-511_modify_to_pro…
YoungSpecial Mar 21, 2024
7ee8235
get compatibility properties
YoungSpecial Jul 8, 2024
0594c63
get compatibility properties
YoungSpecial Jul 8, 2024
9cbbefe
get compatibility properties
YoungSpecial Jul 8, 2024
6454e15
add log
YoungSpecial Jul 8, 2024
7702115
add log
YoungSpecial Jul 9, 2024
ce1448a
add response code
YoungSpecial Jul 9, 2024
bd70681
add response code
YoungSpecial Jul 9, 2024
d0b2444
catch some error
YoungSpecial Jul 10, 2024
ebb613c
catch some error
YoungSpecial Jul 10, 2024
d9e9b92
Merge pull request #14 from ebaymag/feature/CBTEMAG-749_get_compatibi…
YoungSpecial Jul 10, 2024
2804802
add get_compatibility_property_values
YoungSpecial Jul 11, 2024
887f57f
Merge pull request #15 from ebaymag/feature/CBTEMAG-749_get_compatibi…
YoungSpecial Jul 11, 2024
5d261e5
media document apis
YoungSpecial Oct 10, 2024
eafb915
media document apis
YoungSpecial Oct 10, 2024
8be660b
media document apis
YoungSpecial Oct 10, 2024
7a9d6ae
api log
YoungSpecial Oct 12, 2024
0549322
Merge pull request #17 from ebaymag/feature/test_for_qa
YoungSpecial Oct 22, 2024
f0fb10c
Merge pull request #18 from ebaymag/feature/optimize_api_log
YoungSpecial Oct 22, 2024
5d47e40
api log
YoungSpecial Nov 21, 2024
c2a3b6b
api log
YoungSpecial Nov 21, 2024
e294001
Merge pull request #20 from ebaymag/feature/roll_back
YoungSpecial Nov 21, 2024
61ac499
add the send_batch_message api
ganhan0821 Apr 29, 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
2 changes: 1 addition & 1 deletion lib/ebay_api.rb
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,6 @@ class << self
code = data.dig("errors", 0, "errorId")
message =
data.dig("errors", 0, "longMessage") || data.dig("errors", 0, "message")
raise InternalServerError.new(code: code), message
raise InternalServerError.new(code: code, data: data), message
end
end
27 changes: 27 additions & 0 deletions lib/ebay_api/middlewares/log_request.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,31 @@ def log_info(key, data = nil)
logger.info "[EbayAPI] | #{format('%9s', key)} | #{data}"
end

APIS = %w(PUT DELETE POST)
def log_api_request_log(env)
return unless APIS.include?(env["REQUEST_METHOD"])

Thread.current[:request_callname] = env["REQUEST_METHOD"]
Thread.current[:request_url] = env["PATH_INFO"]
Thread.current[:request_body] = env["rack.input"]
Thread.current[:request_restful] = true
rescue StandardError
nil
end

def log_api_response_log(output)
return unless Thread.current[:request_callname]

status, headers, body = output
Thread.current[:response_headers] = headers
Thread.current[:response_body] = body
Thread.current[:response_code] = status
rescue StandardError
nil
end

def log_request(env)
log_api_request_log(env)
return unless logger
log_info "REQUEST:"
log_info "Url", env["PATH_INFO"]
Expand All @@ -29,6 +53,7 @@ def log_request(env)
end

def log_response(output)
log_api_response_log(output)
return unless logger
status, headers, body = output
log_info "RESPONSE:"
Expand All @@ -37,4 +62,6 @@ def log_response(output)
log_info "Body", body
end
end


end
1 change: 1 addition & 0 deletions lib/ebay_api/operations.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
require_relative "operations/sell"
require_relative "operations/developer"
require_relative "operations/commerce"
require_relative "operations/ebaymagapi"
2 changes: 2 additions & 0 deletions lib/ebay_api/operations/commerce.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,7 @@ class EbayAPI

require_relative "commerce/notification"
require_relative "commerce/taxonomy"
require_relative "commerce/translation"
require_relative "commerce/media"
end
end
14 changes: 14 additions & 0 deletions lib/ebay_api/operations/commerce/media.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
class EbayAPI
scope :commerce do
#
# eBay Commerce Media API Overview
#
# @see https://developer.ebay.com/api-docs/commerce/media/overview.html
#
scope :media do
path { "media/v1_beta" }

require_relative "media/document"
end
end
end
16 changes: 16 additions & 0 deletions lib/ebay_api/operations/commerce/media/document.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
class EbayAPI
scope :commerce do
#
# eBay Commerce Media API about document
#
scope :media do
scope :document do
path { "document" }

require_relative "document/get"
require_relative "document/create"
require_relative "document/upload"
end
end
end
end
18 changes: 18 additions & 0 deletions lib/ebay_api/operations/commerce/media/document/create.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
class EbayAPI
scope :commerce do
scope :media do
scope :document do
#
# https://developer.ebay.com/api-docs/commerce/media/resources/document/methods/createDocument
#
operation :create do
option :data, proc(&:to_h)

path { "/" }
http_method :post
body { data }
end
end
end
end
end
17 changes: 17 additions & 0 deletions lib/ebay_api/operations/commerce/media/document/get.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
class EbayAPI
scope :commerce do
scope :media do
scope :document do
#
# https://developer.ebay.com/api-docs/commerce/media/resources/document/methods/getDocument
#
operation :get do
option :id, proc(&:to_s)

path { id }
http_method :get
end
end
end
end
end
19 changes: 19 additions & 0 deletions lib/ebay_api/operations/commerce/media/document/upload.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
class EbayAPI
scope :commerce do
scope :media do
scope :document do
#
# https://developer.ebay.com/api-docs/commerce/media/resources/document/methods/uploadDocument
#
operation :upload do
option :id
option :data

path { "#{id}/upload" }
http_method :post
body { data }
end
end
end
end
end
1 change: 1 addition & 0 deletions lib/ebay_api/operations/commerce/taxonomy/category_tree.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ class EbayAPI
require_relative "category_tree/get_category_suggestions"
require_relative "category_tree/get_item_aspects_for_category"
require_relative "category_tree/fetch_item_aspects"
require_relative "category_tree/get_compatibility_properties"
end
end
end
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
class EbayAPI
scope :commerce do
scope :taxonomy do
scope :category_tree do
# @see https://developer.ebay.com/api-docs/commerce/taxonomy/resources/category_tree/methods/getCompatibilityProperties
operation :get_compatibility_properties do
option :category_id, proc(&:to_s)

path { "get_compatibility_properties" }
query { { category_id: category_id } }
http_method :get
end
end
end
end
end
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
class EbayAPI
scope :commerce do
scope :taxonomy do
scope :category_tree do
# @see https://developer.ebay.com/api-docs/commerce/taxonomy/resources/category_tree/methods/getCompatibilityPropertyValues
operation :get_compatibility_property_values do
option :category_id, proc(&:to_s)

path { "get_compatibility_property_values" }
query { { category_id: category_id } }
http_method :get
end
end
end
end
end
14 changes: 14 additions & 0 deletions lib/ebay_api/operations/commerce/translation.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
class EbayAPI
scope :commerce do
#
# eBay Commerce Translation API
#
# @see https://developer.ebay.com/api-docs/commerce/translation/overview.html
#
scope :translation do
path { "translation/v1_beta" }

require_relative "translation/translate"
end
end
end
13 changes: 13 additions & 0 deletions lib/ebay_api/operations/commerce/translation/translate.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
class EbayAPI
scope :commerce do
scope :translation do
operation :translate do
option :data, proc(&:to_h) # TODO: add model to validate input

path { "/translate" }
http_method :post
body { data }
end
end
end
end
12 changes: 12 additions & 0 deletions lib/ebay_api/operations/ebaymagapi.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
class EbayAPI
#
# eBay Commerce APIs
#
# @see https://developer.ebay.com/api-docs/commerce/static/commerce-landing.html
#
scope :ebaymagapi do
path "ebaymagapi"

require_relative "ebaymagapi/v1"
end
end
13 changes: 13 additions & 0 deletions lib/ebay_api/operations/ebaymagapi/operations/poll_message.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
class EbayAPI
scope :ebaymagapi do
scope :v1 do
operation :poll_message do
option :data, proc(&:to_h)

path { "/poll_message" }
http_method :post
body { data }
end
end
end
end
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
class EbayAPI
scope :ebaymagapi do
scope :v1 do
operation :send_batch_message do
option :data do |value|
value.is_a?(Array) ? value : value.to_h
end

path { "/send_batch_message" }
http_method :post
body { data }
end
end
end
end


13 changes: 13 additions & 0 deletions lib/ebay_api/operations/ebaymagapi/operations/send_message.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
class EbayAPI
scope :ebaymagapi do
scope :v1 do
operation :send_message do
option :data, proc(&:to_h)

path { "/send_message" }
http_method :post
body { data }
end
end
end
end
16 changes: 16 additions & 0 deletions lib/ebay_api/operations/ebaymagapi/v1.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
class EbayAPI
scope :ebaymagapi do
#
# eBayMsa
#
# @see
#
scope :v1 do
path { "v1" }

require_relative "operations/send_message"
require_relative "operations/poll_message"
require_relative "operations/send_batch_message"
end
end
end
1 change: 1 addition & 0 deletions lib/ebay_api/operations/sell.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,6 @@ class EbayAPI
require_relative "sell/account"
require_relative "sell/inventory"
require_relative "sell/marketing"
require_relative "sell/analytics"
end
end
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/subscription"
end
end
end
1 change: 1 addition & 0 deletions lib/ebay_api/operations/sell/account/program.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
require_relative "program/opt_in"
require_relative "program/get"

class EbayAPI
scope :sell do
Expand Down
11 changes: 11 additions & 0 deletions lib/ebay_api/operations/sell/account/subscription.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
require_relative "subscription/get"

class EbayAPI
scope :sell do
scope :account do
scope :subscription do
path { "subscription" }
end
end
end
end
17 changes: 17 additions & 0 deletions lib/ebay_api/operations/sell/account/subscription/get.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
class EbayAPI
scope :sell do
scope :account do
scope :subscription do
# @see https://developer.ebay.com/api-docs/sell/account/resources/subscription/methods/getSubscription
operation :get do
option :limit, proc(&:to_s), optional: true
option :continuation_token, proc(&:to_s), optional: true

path { "/" }
query { { limit: limit, continuation_token: continuation_token }.compact }
http_method :get
end
end
end
end
end
13 changes: 13 additions & 0 deletions lib/ebay_api/operations/sell/analytics.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#
# findSellerStandardsProfiles
# https://developer.ebay.com/api-docs/sell/analytics/resources/seller_standards_profile/methods/findSellerStandardsProfiles
#
class EbayAPI
scope :sell do
scope :analytics do
path { "analytics/v#{EbayAPI::SELL_INVENTORY_VERSION[/^\d+/]}" }

require_relative "analytics/seller_standards_profile"
end
end
end
16 changes: 16 additions & 0 deletions lib/ebay_api/operations/sell/analytics/seller_standards_profile.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#
# findSellerStandardsProfiles
#
class EbayAPI
scope :sell do
scope :analytics do
scope :seller_standards_profile do
path "seller_standards_profile"

operation :get do
http_method :get
end
end
end
end
end
6 changes: 6 additions & 0 deletions spec/fixtures/sell/account/subscription/get/bad_request
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
HTTP/1.1 400 Bad Request
Content-Length: 182
Content-Type: text/html

{"errors":[{"errorId":1002,"domain":"OAuth","category":"REQUEST","message":"Missing access token","longMessage":"Access token is missing in the Authorization HTTP request header."}]}

5 changes: 5 additions & 0 deletions spec/fixtures/sell/account/subscription/get/server_error
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
HTTP/1.1 500 Server Error
Content-Length: 0
Content-Type: application/json


Loading