diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml new file mode 100644 index 0000000..d16117a --- /dev/null +++ b/.github/workflows/test.yml @@ -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 diff --git a/.gitignore b/.gitignore index a2807f6..ba5ea1d 100644 --- a/.gitignore +++ b/.gitignore @@ -9,4 +9,4 @@ /tmp/ *.gem .rspec_status -*.yml +.idea/ diff --git a/.rubocop.yml b/.rubocop.yml index d855f51..ca95559 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -3,7 +3,8 @@ AllCops: DisplayCopNames: true DisplayStyleGuide: true StyleGuideCopsOnly: true - TargetRubyVersion: 2.3 + TargetRubyVersion: 2.6 + NewCops: enable Metrics/LineLength: AllowHeredoc: true @@ -12,6 +13,9 @@ Metrics/LineLength: - http - https +Layout/SpaceInLambdaLiteral: + Enabled: false + Style/CaseEquality: Enabled: false @@ -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/**/* diff --git a/CHANGELOG.md b/CHANGELOG.md index db89610..c7632b2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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. diff --git a/README.md b/README.md index c0be67e..ce669d3 100644 --- a/README.md +++ b/README.md @@ -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 diff --git a/config/dictionary.yml b/config/dictionary.yml index 218e5a7..ae3ed3b 100644 --- a/config/dictionary.yml +++ b/config/dictionary.yml @@ -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 diff --git a/config/locales/en.yml b/config/locales/en.yml index 5234e5a..96d8f01 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -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' diff --git a/config/sites.yml b/config/sites.yml index 30ee8a6..4503f33 100644 --- a/config/sites.yml +++ b/config/sites.yml @@ -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 @@ -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 @@ -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 @@ -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 diff --git a/config/versions.yml b/config/versions.yml index 866d6bb..7ce488b 100644 --- a/config/versions.yml +++ b/config/versions.yml @@ -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" diff --git a/ebay_api.gemspec b/ebay_api.gemspec index d3c5f12..49a3a7e 100644 --- a/ebay_api.gemspec +++ b/ebay_api.gemspec @@ -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" @@ -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 diff --git a/lib/ebay_api.rb b/lib/ebay_api.rb index 0e8d15b..3628be7 100644 --- a/lib/ebay_api.rb +++ b/lib/ebay_api.rb @@ -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 @@ -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 @@ -61,21 +67,28 @@ 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"] @@ -83,6 +96,7 @@ class EbayAPI < Evil::Client 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") diff --git a/lib/ebay_api/exceptions.rb b/lib/ebay_api/exceptions.rb index 3a6997b..477d7e1 100644 --- a/lib/ebay_api/exceptions.rb +++ b/lib/ebay_api/exceptions.rb @@ -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 diff --git a/lib/ebay_api/middlewares.rb b/lib/ebay_api/middlewares.rb index 4ce44de..31fb13f 100644 --- a/lib/ebay_api/middlewares.rb +++ b/lib/ebay_api/middlewares.rb @@ -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" diff --git a/lib/ebay_api/middlewares/json_response.rb b/lib/ebay_api/middlewares/json_response.rb index 1640924..7dec4fd 100644 --- a/lib/ebay_api/middlewares/json_response.rb +++ b/lib/ebay_api/middlewares/json_response.rb @@ -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 diff --git a/lib/ebay_api/middlewares/log_request.rb b/lib/ebay_api/middlewares/log_request.rb new file mode 100644 index 0000000..8c7654c --- /dev/null +++ b/lib/ebay_api/middlewares/log_request.rb @@ -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 diff --git a/lib/ebay_api/middlewares/save_to_file_response.rb b/lib/ebay_api/middlewares/save_to_file_response.rb new file mode 100644 index 0000000..221f57a --- /dev/null +++ b/lib/ebay_api/middlewares/save_to_file_response.rb @@ -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 diff --git a/lib/ebay_api/models.rb b/lib/ebay_api/models.rb index 7549b12..fe471d9 100644 --- a/lib/ebay_api/models.rb +++ b/lib/ebay_api/models.rb @@ -10,3 +10,4 @@ require_relative "models/campaign" require_relative "models/create_campaign_request" require_relative "models/funding_strategy" +require_relative "models/program_type" diff --git a/lib/ebay_api/models/amount.rb b/lib/ebay_api/models/amount.rb index 09c04a1..2c5bb9d 100644 --- a/lib/ebay_api/models/amount.rb +++ b/lib/ebay_api/models/amount.rb @@ -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 } diff --git a/lib/ebay_api/models/bid_percentage.rb b/lib/ebay_api/models/bid_percentage.rb index 6b19af0..c4edecc 100644 --- a/lib/ebay_api/models/bid_percentage.rb +++ b/lib/ebay_api/models/bid_percentage.rb @@ -6,7 +6,7 @@ class BidPercentage < Evil::Client::Model unless /\A\d{1,2}(?:\.\d)?\z/ =~ value.to_s next errors.add :bid_wrong_format, value: value end - unless (1..20).cover?(BigDecimal(value)) + unless (1..100).cover?(BigDecimal(value)) errors.add :bid_out_of_range, value: value end end @@ -18,7 +18,5 @@ def self.call(raw) def to_s @value end - alias to_h to_s - alias to_hash to_s end end diff --git a/lib/ebay_api/models/program_type.rb b/lib/ebay_api/models/program_type.rb new file mode 100644 index 0000000..8f6d585 --- /dev/null +++ b/lib/ebay_api/models/program_type.rb @@ -0,0 +1,10 @@ +class EbayAPI + # Key for program types a seller can opt in + class ProgramType < String + extend Evil::Client::Dictionary["#{DICTIONARY_FILE}#program_type"] + + def self.call(value) + super value.to_s.upcase + end + end +end diff --git a/lib/ebay_api/models/site.rb b/lib/ebay_api/models/site.rb index 5f95ee8..a251b72 100644 --- a/lib/ebay_api/models/site.rb +++ b/lib/ebay_api/models/site.rb @@ -44,6 +44,15 @@ def merge(other) # Enumberable collection of the eBay marketplaces class << self + # Override new to handle hash argument from Evil::Client::Dictionary + def new(attributes = {}) + if attributes.is_a?(Hash) && !attributes.empty? + super(**attributes) + else + super + end + end + sites_file = File.join(GEM_ROOT, %w[config sites.yml]) include Evil::Client::Dictionary[sites_file] diff --git a/lib/ebay_api/operations.rb b/lib/ebay_api/operations.rb index 6fc01e1..ed2095a 100644 --- a/lib/ebay_api/operations.rb +++ b/lib/ebay_api/operations.rb @@ -1 +1,3 @@ require_relative "operations/sell" +require_relative "operations/developer" +require_relative "operations/commerce" diff --git a/lib/ebay_api/operations/commerce.rb b/lib/ebay_api/operations/commerce.rb new file mode 100644 index 0000000..4e0729a --- /dev/null +++ b/lib/ebay_api/operations/commerce.rb @@ -0,0 +1,14 @@ +class EbayAPI + # + # eBay Commerce APIs + # + # @see https://developer.ebay.com/api-docs/commerce/static/commerce-landing.html + # + scope :commerce do + path "commerce" + + require_relative "commerce/catalog" + require_relative "commerce/notification" + require_relative "commerce/taxonomy" + end +end diff --git a/lib/ebay_api/operations/commerce/catalog.rb b/lib/ebay_api/operations/commerce/catalog.rb new file mode 100644 index 0000000..db09390 --- /dev/null +++ b/lib/ebay_api/operations/commerce/catalog.rb @@ -0,0 +1,12 @@ +# +# Commerce Catalog API +# +class EbayAPI + scope :commerce do + scope :catalog do + path { "catalog/v#{EbayAPI::COMMERCE_CATALOG_VERSION.split(/\s|\./).first}" } + + require_relative "catalog/product_summary" + end + end +end diff --git a/lib/ebay_api/operations/commerce/catalog/product_summary.rb b/lib/ebay_api/operations/commerce/catalog/product_summary.rb new file mode 100644 index 0000000..0d11f09 --- /dev/null +++ b/lib/ebay_api/operations/commerce/catalog/product_summary.rb @@ -0,0 +1,22 @@ +require_relative "product_summary/search" + +class EbayAPI + scope :commerce do + scope :catalog do + scope :product_summary do + path "product_summary" + + response(400, 409) do |_, _, (data, *)| + code = data.dig("errors", 0, "errorId") + message = data.dig("errors", 0, "message") + case code + when 35_060 + raise EbayAPI::UserActionRequired.new(code: code), message + else + super! + end + end + end + end + end +end \ No newline at end of file diff --git a/lib/ebay_api/operations/commerce/catalog/product_summary/search.rb b/lib/ebay_api/operations/commerce/catalog/product_summary/search.rb new file mode 100644 index 0000000..f70fb4c --- /dev/null +++ b/lib/ebay_api/operations/commerce/catalog/product_summary/search.rb @@ -0,0 +1,35 @@ +class EbayAPI + scope :commerce do + scope :catalog do + scope :product_summary do + # @see https://developer.ebay.com/api-docs/commerce/catalog/resources/product_summary/methods/search + operation :search do + http_method :get + path { :search } + + query do + { + q: keywords, + gtin: gtin, + mpn: mpn, + category_ids: category_ids, + limit: limit, + offset: offset + }.compact + end + + option :keywords, optional: true + option :gtin, optional: true + option :mpn, optional: true + option :category_ids, optional: true + option :offset, optional: true + option :limit, default: proc { 20 }, optional: true + + response(200) { |_, _, (data, *)| data } + response(204) { {} } + response(404) { {} } + end + end + end + end +end diff --git a/lib/ebay_api/operations/commerce/notification.rb b/lib/ebay_api/operations/commerce/notification.rb new file mode 100644 index 0000000..6e31069 --- /dev/null +++ b/lib/ebay_api/operations/commerce/notification.rb @@ -0,0 +1,14 @@ +class EbayAPI + scope :commerce do + # + # eBay Commerce Notifications API + # + # @see https://developer.ebay.com/api-docs/commerce/notification/overview.html + # + scope :notifications do + path { "notification/v#{EbayAPI::COMMERCE_NOTIFICATIONS_VERSION[/^\d+/]}" } + + require_relative "notification/public_key" + end + end +end diff --git a/lib/ebay_api/operations/commerce/notification/public_key.rb b/lib/ebay_api/operations/commerce/notification/public_key.rb new file mode 100644 index 0000000..6113269 --- /dev/null +++ b/lib/ebay_api/operations/commerce/notification/public_key.rb @@ -0,0 +1,11 @@ +class EbayAPI + scope :commerce do + scope :notifications do + scope :public_key do + path "public_key" + + require_relative "public_key/get" + end + end + end +end diff --git a/lib/ebay_api/operations/commerce/notification/public_key/get.rb b/lib/ebay_api/operations/commerce/notification/public_key/get.rb new file mode 100644 index 0000000..caf9fae --- /dev/null +++ b/lib/ebay_api/operations/commerce/notification/public_key/get.rb @@ -0,0 +1,15 @@ +class EbayAPI + scope :commerce do + scope :notifications do + # @see https://developer.ebay.com/api-docs/commerce/notification/resources/public_key/methods/getPublicKey + scope :public_key do + operation :get do + option :key_id, proc(&:to_s) + + path { key_id } + http_method :get + end + end + end + end +end diff --git a/lib/ebay_api/operations/commerce/taxonomy.rb b/lib/ebay_api/operations/commerce/taxonomy.rb new file mode 100644 index 0000000..8ed0fd6 --- /dev/null +++ b/lib/ebay_api/operations/commerce/taxonomy.rb @@ -0,0 +1,15 @@ +class EbayAPI + scope :commerce do + # + # eBay Commerce Notifications API + # + # @see https://developer.ebay.com/api-docs/commerce/notification/overview.html + # + scope :taxonomy do + path { "taxonomy/v#{EbayAPI::COMMERCE_TAXONOMY_VERSION[/^\d+/]}" } + + require_relative "taxonomy/category_tree" + require_relative "taxonomy/get_default_category_tree_id" + end + end +end diff --git a/lib/ebay_api/operations/commerce/taxonomy/category_tree.rb b/lib/ebay_api/operations/commerce/taxonomy/category_tree.rb new file mode 100644 index 0000000..82afabc --- /dev/null +++ b/lib/ebay_api/operations/commerce/taxonomy/category_tree.rb @@ -0,0 +1,21 @@ +class EbayAPI + scope :commerce do + # + # eBay Commerce Notifications API + # + # @see https://developer.ebay.com/api-docs/commerce/taxonomy/overview.html + # + scope :taxonomy do + scope :category_tree do + path { "category_tree/#{category_tree_id}" } + option :category_tree_id + + require_relative "category_tree/get" + require_relative "category_tree/get_category_subtree" + require_relative "category_tree/get_category_suggestions" + require_relative "category_tree/get_item_aspects_for_category" + require_relative "category_tree/fetch_item_aspects" + end + end + end +end diff --git a/lib/ebay_api/operations/commerce/taxonomy/category_tree/fetch_item_aspects.rb b/lib/ebay_api/operations/commerce/taxonomy/category_tree/fetch_item_aspects.rb new file mode 100644 index 0000000..647511b --- /dev/null +++ b/lib/ebay_api/operations/commerce/taxonomy/category_tree/fetch_item_aspects.rb @@ -0,0 +1,15 @@ +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/fetchItemAspects + operation :fetch_item_aspects do + middleware { SaveToFileResponse } # returns { "filename": "..." } + + path { "fetch_item_aspects" } + http_method :get + end + end + end + end +end diff --git a/lib/ebay_api/operations/commerce/taxonomy/category_tree/get.rb b/lib/ebay_api/operations/commerce/taxonomy/category_tree/get.rb new file mode 100644 index 0000000..15bb351 --- /dev/null +++ b/lib/ebay_api/operations/commerce/taxonomy/category_tree/get.rb @@ -0,0 +1,13 @@ +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/getCategoryTree + operation :get do + path { "/" } + http_method :get + end + end + end + end +end diff --git a/lib/ebay_api/operations/commerce/taxonomy/category_tree/get_category_subtree.rb b/lib/ebay_api/operations/commerce/taxonomy/category_tree/get_category_subtree.rb new file mode 100644 index 0000000..ceca090 --- /dev/null +++ b/lib/ebay_api/operations/commerce/taxonomy/category_tree/get_category_subtree.rb @@ -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/getCategorySubtree + operation :get_category_subtree do + option :category_id, proc(&:to_s) + + path { "get_category_subtree" } + query { { category_id: category_id } } + http_method :get + end + end + end + end +end diff --git a/lib/ebay_api/operations/commerce/taxonomy/category_tree/get_category_suggestions.rb b/lib/ebay_api/operations/commerce/taxonomy/category_tree/get_category_suggestions.rb new file mode 100644 index 0000000..79c57f8 --- /dev/null +++ b/lib/ebay_api/operations/commerce/taxonomy/category_tree/get_category_suggestions.rb @@ -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/getCategorySuggestions + operation :get_category_suggestions do + option :query, proc(&:to_s) + + path { "get_category_suggestions" } + query { { q: query } } + http_method :get + end + end + end + end +end diff --git a/lib/ebay_api/operations/commerce/taxonomy/category_tree/get_item_aspects_for_category.rb b/lib/ebay_api/operations/commerce/taxonomy/category_tree/get_item_aspects_for_category.rb new file mode 100644 index 0000000..829ea8e --- /dev/null +++ b/lib/ebay_api/operations/commerce/taxonomy/category_tree/get_item_aspects_for_category.rb @@ -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/getItemAspectsForCategory + operation :get_item_aspects_for_category do + option :category_id, proc(&:to_s) + + path { "get_item_aspects_for_category" } + query { { category_id: category_id } } + http_method :get + end + end + end + end +end diff --git a/lib/ebay_api/operations/commerce/taxonomy/get_default_category_tree_id.rb b/lib/ebay_api/operations/commerce/taxonomy/get_default_category_tree_id.rb new file mode 100644 index 0000000..be83601 --- /dev/null +++ b/lib/ebay_api/operations/commerce/taxonomy/get_default_category_tree_id.rb @@ -0,0 +1,14 @@ +class EbayAPI + scope :commerce do + scope :taxonomy do + # @see https://developer.ebay.com/api-docs/commerce/taxonomy/resources/category_tree/methods/getDefaultCategoryTreeId + operation :get_default_category_tree_id do + option :site, Site + + path { "get_default_category_tree_id" } + query { { marketplace_id: site.key } } + http_method :get + end + end + end +end diff --git a/lib/ebay_api/operations/developer.rb b/lib/ebay_api/operations/developer.rb new file mode 100644 index 0000000..1b3628d --- /dev/null +++ b/lib/ebay_api/operations/developer.rb @@ -0,0 +1,12 @@ +class EbayAPI + # + # eBay Developer APIs + # + # @see https://developer.ebay.com/api-docs/developer/static/developer-landing.html + # + scope :developer do + path "developer" + + require_relative "developer/analytics" + end +end diff --git a/lib/ebay_api/operations/developer/analytics.rb b/lib/ebay_api/operations/developer/analytics.rb new file mode 100644 index 0000000..14f74de --- /dev/null +++ b/lib/ebay_api/operations/developer/analytics.rb @@ -0,0 +1,15 @@ +class EbayAPI + scope :developer do + # + # eBay Developer Analytics API + # + # @see https://developer.ebay.com/api-docs/developer/analytics/static/overview.html + # + scope :analytics do + path { "analytics/v#{EbayAPI::DEVELOPER_ANALYTICS_VERSION[/^\d[\w]+/]}" } + + require_relative "analytics/rate_limit" + require_relative "analytics/user_rate_limit" + end + end +end diff --git a/lib/ebay_api/operations/developer/analytics/rate_limit.rb b/lib/ebay_api/operations/developer/analytics/rate_limit.rb new file mode 100644 index 0000000..0b705c1 --- /dev/null +++ b/lib/ebay_api/operations/developer/analytics/rate_limit.rb @@ -0,0 +1,11 @@ +class EbayAPI + scope :developer do + scope :analytics do + scope :rate_limit do + path "rate_limit" + + require_relative "rate_limit/get" + end + end + end +end diff --git a/lib/ebay_api/operations/developer/analytics/rate_limit/get.rb b/lib/ebay_api/operations/developer/analytics/rate_limit/get.rb new file mode 100644 index 0000000..62de6ba --- /dev/null +++ b/lib/ebay_api/operations/developer/analytics/rate_limit/get.rb @@ -0,0 +1,22 @@ +class EbayAPI + scope :developer do + scope :analytics do + scope :rate_limit do + # @see https://developer.ebay.com/api-docs/developer/analytics/resources/rate_limit/methods/getRateLimits + operation :get do + option :api_context, optional: true + option :api_name, optional: true + + http_method :get + query do + { api_context: api_context, api_name: api_name }.compact + end + + response(200) do |_, _, (data, *)| + data["rateLimits"] + end + end + end + end + end +end diff --git a/lib/ebay_api/operations/developer/analytics/user_rate_limit.rb b/lib/ebay_api/operations/developer/analytics/user_rate_limit.rb new file mode 100644 index 0000000..1b97b65 --- /dev/null +++ b/lib/ebay_api/operations/developer/analytics/user_rate_limit.rb @@ -0,0 +1,11 @@ +class EbayAPI + scope :developer do + scope :analytics do + scope :user_rate_limit do + path "user_rate_limit" + + require_relative "user_rate_limit/get" + end + end + end +end diff --git a/lib/ebay_api/operations/developer/analytics/user_rate_limit/get.rb b/lib/ebay_api/operations/developer/analytics/user_rate_limit/get.rb new file mode 100644 index 0000000..bad4f86 --- /dev/null +++ b/lib/ebay_api/operations/developer/analytics/user_rate_limit/get.rb @@ -0,0 +1,17 @@ +class EbayAPI + scope :developer do + scope :analytics do + scope :user_rate_limit do + # @see https://developer.ebay.com/api-docs/developer/analytics/resources/user_rate_limit/methods/getUserRateLimits + operation :get do + http_method :get + path { "/" } + + response(200) do |_, _, (data, *)| + data["rateLimits"] + end + end + end + end + end +end diff --git a/lib/ebay_api/operations/sell.rb b/lib/ebay_api/operations/sell.rb index b4a68bf..ee8d1c7 100644 --- a/lib/ebay_api/operations/sell.rb +++ b/lib/ebay_api/operations/sell.rb @@ -8,5 +8,6 @@ class EbayAPI require_relative "sell/account" require_relative "sell/inventory" require_relative "sell/marketing" + require_relative "sell/metadata" end end diff --git a/lib/ebay_api/operations/sell/account.rb b/lib/ebay_api/operations/sell/account.rb index b4b3ea5..10e2596 100644 --- a/lib/ebay_api/operations/sell/account.rb +++ b/lib/ebay_api/operations/sell/account.rb @@ -7,6 +7,11 @@ class EbayAPI path { "account/v#{EbayAPI::SELL_ACCOUNT_VERSION[/^\d+/]}" } require_relative "account/privilege" + require_relative "account/program" + require_relative "account/fulfillment_policy" + require_relative "account/return_policy" + require_relative "account/payment_policy" + require_relative "account/payments_program" end end end diff --git a/lib/ebay_api/operations/sell/account/fulfillment_policy.rb b/lib/ebay_api/operations/sell/account/fulfillment_policy.rb new file mode 100644 index 0000000..558c769 --- /dev/null +++ b/lib/ebay_api/operations/sell/account/fulfillment_policy.rb @@ -0,0 +1,16 @@ +class EbayAPI + scope :sell do + scope :account do + scope :fulfillment_policy do + path { "fulfillment_policy" } + end + end + end +end + +require_relative "fulfillment_policy/delete" +require_relative "fulfillment_policy/get" +require_relative "fulfillment_policy/get_by_name" +require_relative "fulfillment_policy/index" +require_relative "fulfillment_policy/create" +require_relative "fulfillment_policy/update" diff --git a/lib/ebay_api/operations/sell/account/fulfillment_policy/create.rb b/lib/ebay_api/operations/sell/account/fulfillment_policy/create.rb new file mode 100644 index 0000000..c8556c1 --- /dev/null +++ b/lib/ebay_api/operations/sell/account/fulfillment_policy/create.rb @@ -0,0 +1,17 @@ +class EbayAPI + scope :sell do + scope :account do + scope :fulfillment_policy do + # @see https://developer.ebay.com/api-docs/sell/account/resources/fulfillment_policy/methods/createFulfillmentPolicy + operation :create do + option :site, Site + option :data, proc(&:to_h) # TODO: add model to validate input + + path { "/" } + http_method :post + body { data.merge("marketplaceId" => site.key) } + end + end + end + end +end diff --git a/lib/ebay_api/operations/sell/account/fulfillment_policy/delete.rb b/lib/ebay_api/operations/sell/account/fulfillment_policy/delete.rb new file mode 100644 index 0000000..0b2e1f9 --- /dev/null +++ b/lib/ebay_api/operations/sell/account/fulfillment_policy/delete.rb @@ -0,0 +1,15 @@ +class EbayAPI + scope :sell do + scope :account do + scope :fulfillment_policy do + # @see https://developer.ebay.com/api-docs/sell/account/resources/fulfillment_policy/methods/deleteFulfillmentPolicy + operation :delete do + option :id, proc(&:to_s) + + path { id } + http_method :delete + end + end + end + end +end diff --git a/lib/ebay_api/operations/sell/account/fulfillment_policy/get.rb b/lib/ebay_api/operations/sell/account/fulfillment_policy/get.rb new file mode 100644 index 0000000..8e62910 --- /dev/null +++ b/lib/ebay_api/operations/sell/account/fulfillment_policy/get.rb @@ -0,0 +1,15 @@ +class EbayAPI + scope :sell do + scope :account do + scope :fulfillment_policy do + # @see https://developer.ebay.com/api-docs/sell/account/resources/fulfillment_policy/methods/getFulfillmentPolicy + operation :get do + option :id, proc(&:to_s) + + path { id } + http_method :get + end + end + end + end +end diff --git a/lib/ebay_api/operations/sell/account/fulfillment_policy/get_by_name.rb b/lib/ebay_api/operations/sell/account/fulfillment_policy/get_by_name.rb new file mode 100644 index 0000000..3d485bf --- /dev/null +++ b/lib/ebay_api/operations/sell/account/fulfillment_policy/get_by_name.rb @@ -0,0 +1,17 @@ +class EbayAPI + scope :sell do + scope :account do + scope :fulfillment_policy do + # @see https://developer.ebay.com/api-docs/sell/account/resources/fulfillment_policy/methods/getFulfillmentPolicyByName + operation :get_by_name do + option :site, Site + option :name, proc(&:to_s) + + path { "/get_by_policy_name" } + query { { marketplace_id: site.key, name: name } } + http_method :get + end + end + end + end +end diff --git a/lib/ebay_api/operations/sell/account/fulfillment_policy/index.rb b/lib/ebay_api/operations/sell/account/fulfillment_policy/index.rb new file mode 100644 index 0000000..857a7d6 --- /dev/null +++ b/lib/ebay_api/operations/sell/account/fulfillment_policy/index.rb @@ -0,0 +1,16 @@ +class EbayAPI + scope :sell do + scope :account do + scope :fulfillment_policy do + # @see https://developer.ebay.com/api-docs/sell/account/resources/fulfillment_policy/methods/getFulfillmentPolicies + operation :index do + option :site, Site + + path { "/" } + query { { marketplace_id: site.key } } + http_method :get + end + end + end + end +end diff --git a/lib/ebay_api/operations/sell/account/fulfillment_policy/update.rb b/lib/ebay_api/operations/sell/account/fulfillment_policy/update.rb new file mode 100644 index 0000000..aea2cb4 --- /dev/null +++ b/lib/ebay_api/operations/sell/account/fulfillment_policy/update.rb @@ -0,0 +1,18 @@ +class EbayAPI + scope :sell do + scope :account do + scope :fulfillment_policy do + # @see https://developer.ebay.com/api-docs/sell/account/resources/fulfillment_policy/methods/updateFulfillmentPolicy + operation :update do + option :id, proc(&:to_s) + option :site, Site + option :data, proc(&:to_h) # TODO: add model to validate input + + path { id } + http_method :put + body { data.merge("marketplaceId" => site.key) } + end + end + end + end +end diff --git a/lib/ebay_api/operations/sell/account/payment_policy.rb b/lib/ebay_api/operations/sell/account/payment_policy.rb new file mode 100644 index 0000000..01fa0da --- /dev/null +++ b/lib/ebay_api/operations/sell/account/payment_policy.rb @@ -0,0 +1,16 @@ +class EbayAPI + scope :sell do + scope :account do + scope :payment_policy do + path { "payment_policy" } + end + end + end +end + +require_relative "payment_policy/delete" +require_relative "payment_policy/get" +require_relative "payment_policy/get_by_name" +require_relative "payment_policy/index" +require_relative "payment_policy/create" +require_relative "payment_policy/update" diff --git a/lib/ebay_api/operations/sell/account/payment_policy/create.rb b/lib/ebay_api/operations/sell/account/payment_policy/create.rb new file mode 100644 index 0000000..1924498 --- /dev/null +++ b/lib/ebay_api/operations/sell/account/payment_policy/create.rb @@ -0,0 +1,17 @@ +class EbayAPI + scope :sell do + scope :account do + scope :payment_policy do + # @see https://developer.ebay.com/api-docs/sell/account/resources/payment_policy/methods/createPaymentPolicy + operation :create do + option :site, Site + option :data, proc(&:to_h) # TODO: add model to validate input + + path { "/" } + http_method :post + body { data.merge("marketplaceId" => site.key) } + end + end + end + end +end diff --git a/lib/ebay_api/operations/sell/account/payment_policy/delete.rb b/lib/ebay_api/operations/sell/account/payment_policy/delete.rb new file mode 100644 index 0000000..25bb7ea --- /dev/null +++ b/lib/ebay_api/operations/sell/account/payment_policy/delete.rb @@ -0,0 +1,15 @@ +class EbayAPI + scope :sell do + scope :account do + scope :payment_policy do + # @see https://developer.ebay.com/api-docs/sell/account/resources/payment_policy/methods/deletePaymentPolicy + operation :delete do + option :id, proc(&:to_s) + + path { id } + http_method :delete + end + end + end + end +end diff --git a/lib/ebay_api/operations/sell/account/payment_policy/get.rb b/lib/ebay_api/operations/sell/account/payment_policy/get.rb new file mode 100644 index 0000000..cf35ac4 --- /dev/null +++ b/lib/ebay_api/operations/sell/account/payment_policy/get.rb @@ -0,0 +1,15 @@ +class EbayAPI + scope :sell do + scope :account do + scope :payment_policy do + # @see https://developer.ebay.com/api-docs/sell/account/resources/payment_policy/methods/getPaymentPolicy + operation :get do + option :id, proc(&:to_s) + + path { id } + http_method :get + end + end + end + end +end diff --git a/lib/ebay_api/operations/sell/account/payment_policy/get_by_name.rb b/lib/ebay_api/operations/sell/account/payment_policy/get_by_name.rb new file mode 100644 index 0000000..ce9edc9 --- /dev/null +++ b/lib/ebay_api/operations/sell/account/payment_policy/get_by_name.rb @@ -0,0 +1,17 @@ +class EbayAPI + scope :sell do + scope :account do + scope :payment_policy do + # @see https://developer.ebay.com/api-docs/sell/account/resources/payment_policy/methods/getPaymentPolicyByName + operation :get_by_name do + option :site, Site + option :name, proc(&:to_s) + + path { "/get_by_policy_name" } + query { { marketplace_id: site.key, name: name } } + http_method :get + end + end + end + end +end diff --git a/lib/ebay_api/operations/sell/account/payment_policy/index.rb b/lib/ebay_api/operations/sell/account/payment_policy/index.rb new file mode 100644 index 0000000..4aa6c93 --- /dev/null +++ b/lib/ebay_api/operations/sell/account/payment_policy/index.rb @@ -0,0 +1,16 @@ +class EbayAPI + scope :sell do + scope :account do + scope :payment_policy do + # @see https://developer.ebay.com/api-docs/sell/account/resources/payment_policy/methods/getPaymentPolicies + operation :index do + option :site, Site + + path { "/" } + query { { marketplace_id: site.key } } + http_method :get + end + end + end + end +end diff --git a/lib/ebay_api/operations/sell/account/payment_policy/update.rb b/lib/ebay_api/operations/sell/account/payment_policy/update.rb new file mode 100644 index 0000000..f30a08c --- /dev/null +++ b/lib/ebay_api/operations/sell/account/payment_policy/update.rb @@ -0,0 +1,18 @@ +class EbayAPI + scope :sell do + scope :account do + scope :payment_policy do + # @see https://developer.ebay.com/api-docs/sell/account/resources/payment_policy/methods/updatePaymentPolicy + operation :update do + option :id, proc(&:to_s) + option :site, Site + option :data, proc(&:to_h) # TODO: add model to validate input + + path { id } + http_method :put + body { data.merge("marketplaceId" => site.key) } + end + end + end + end +end diff --git a/lib/ebay_api/operations/sell/account/payments_program.rb b/lib/ebay_api/operations/sell/account/payments_program.rb new file mode 100644 index 0000000..07c7d62 --- /dev/null +++ b/lib/ebay_api/operations/sell/account/payments_program.rb @@ -0,0 +1,11 @@ +require_relative "payments_program/get" + +class EbayAPI + scope :sell do + scope :account do + scope :payments_program do + path { "payments_program" } + end + end + end +end diff --git a/lib/ebay_api/operations/sell/account/payments_program/get.rb b/lib/ebay_api/operations/sell/account/payments_program/get.rb new file mode 100644 index 0000000..3a8cd11 --- /dev/null +++ b/lib/ebay_api/operations/sell/account/payments_program/get.rb @@ -0,0 +1,16 @@ +class EbayAPI + scope :sell do + scope :account do + scope :payments_program do + # @see https://developer.ebay.com/api-docs/sell/account/resources/payments_program/methods/getPaymentsProgram + operation :get do + option :site, Site + option :type, proc(&:to_s), default: -> { "EBAY_PAYMENTS" } + + http_method :get + path { "/#{site.key}/#{type}" } + end + end + end + end +end diff --git a/lib/ebay_api/operations/sell/account/program.rb b/lib/ebay_api/operations/sell/account/program.rb new file mode 100644 index 0000000..0e523b2 --- /dev/null +++ b/lib/ebay_api/operations/sell/account/program.rb @@ -0,0 +1,11 @@ +require_relative "program/opt_in" + +class EbayAPI + scope :sell do + scope :account do + scope :program do + path { "program" } + end + end + end +end diff --git a/lib/ebay_api/operations/sell/account/program/get.rb b/lib/ebay_api/operations/sell/account/program/get.rb new file mode 100644 index 0000000..df873c3 --- /dev/null +++ b/lib/ebay_api/operations/sell/account/program/get.rb @@ -0,0 +1,13 @@ +class EbayAPI + scope :sell do + scope :account do + scope :program do + # @see https://developer.ebay.com/api-docs/sell/account/resources/program/methods/getOptedInPrograms + operation :get do + http_method :get + path { "get_opted_in_programs" } + end + end + end + end +end diff --git a/lib/ebay_api/operations/sell/account/program/opt_in.rb b/lib/ebay_api/operations/sell/account/program/opt_in.rb new file mode 100644 index 0000000..d93dc11 --- /dev/null +++ b/lib/ebay_api/operations/sell/account/program/opt_in.rb @@ -0,0 +1,16 @@ +class EbayAPI + scope :sell do + scope :account do + scope :program do + # @see https://developer.ebay.com/api-docs/sell/account/resources/program/methods/optInToProgram + operation :opt_in do + option :program, ProgramType + + http_method :post + path { "/opt_in" } + body { { programType: program } } + end + end + end + end +end diff --git a/lib/ebay_api/operations/sell/account/return_policy.rb b/lib/ebay_api/operations/sell/account/return_policy.rb new file mode 100644 index 0000000..781ff53 --- /dev/null +++ b/lib/ebay_api/operations/sell/account/return_policy.rb @@ -0,0 +1,16 @@ +class EbayAPI + scope :sell do + scope :account do + scope :return_policy do + path { "return_policy" } + end + end + end +end + +require_relative "return_policy/delete" +require_relative "return_policy/get" +require_relative "return_policy/get_by_name" +require_relative "return_policy/index" +require_relative "return_policy/create" +require_relative "return_policy/update" diff --git a/lib/ebay_api/operations/sell/account/return_policy/create.rb b/lib/ebay_api/operations/sell/account/return_policy/create.rb new file mode 100644 index 0000000..feae29e --- /dev/null +++ b/lib/ebay_api/operations/sell/account/return_policy/create.rb @@ -0,0 +1,17 @@ +class EbayAPI + scope :sell do + scope :account do + scope :return_policy do + # @see https://developer.ebay.com/api-docs/sell/account/resources/return_policy/methods/createReturnPolicy + operation :create do + option :site, Site + option :data, proc(&:to_h) # TODO: add model to validate input + + path { "/" } + http_method :post + body { data.merge "marketplaceId" => site.key } + end + end + end + end +end diff --git a/lib/ebay_api/operations/sell/account/return_policy/delete.rb b/lib/ebay_api/operations/sell/account/return_policy/delete.rb new file mode 100644 index 0000000..9f0c677 --- /dev/null +++ b/lib/ebay_api/operations/sell/account/return_policy/delete.rb @@ -0,0 +1,15 @@ +class EbayAPI + scope :sell do + scope :account do + scope :return_policy do + # @see https://developer.ebay.com/api-docs/sell/account/resources/return_policy/methods/deleteReturnPolicy + operation :delete do + option :id, proc(&:to_s) + + path { id } + http_method :delete + end + end + end + end +end diff --git a/lib/ebay_api/operations/sell/account/return_policy/get.rb b/lib/ebay_api/operations/sell/account/return_policy/get.rb new file mode 100644 index 0000000..329678c --- /dev/null +++ b/lib/ebay_api/operations/sell/account/return_policy/get.rb @@ -0,0 +1,15 @@ +class EbayAPI + scope :sell do + scope :account do + scope :return_policy do + # @see https://developer.ebay.com/api-docs/sell/account/resources/return_policy/methods/getReturnPolicy + operation :get do + option :id, proc(&:to_s) + + path { id } + http_method :get + end + end + end + end +end diff --git a/lib/ebay_api/operations/sell/account/return_policy/get_by_name.rb b/lib/ebay_api/operations/sell/account/return_policy/get_by_name.rb new file mode 100644 index 0000000..b7c9246 --- /dev/null +++ b/lib/ebay_api/operations/sell/account/return_policy/get_by_name.rb @@ -0,0 +1,17 @@ +class EbayAPI + scope :sell do + scope :account do + scope :return_policy do + # @see https://developer.ebay.com/api-docs/sell/account/resources/return_policy/methods/getReturnPolicyByName + operation :get_by_name do + option :site, Site + option :name, proc(&:to_s) + + path { "/get_by_policy_name" } + query { { marketplace_id: site.key, name: name } } + http_method :get + end + end + end + end +end diff --git a/lib/ebay_api/operations/sell/account/return_policy/index.rb b/lib/ebay_api/operations/sell/account/return_policy/index.rb new file mode 100644 index 0000000..07002e6 --- /dev/null +++ b/lib/ebay_api/operations/sell/account/return_policy/index.rb @@ -0,0 +1,16 @@ +class EbayAPI + scope :sell do + scope :account do + scope :return_policy do + # @see https://developer.ebay.com/api-docs/sell/account/resources/return_policy/methods/getReturnPolicies + operation :index do + option :site, Site + + path { "/" } + query { { marketplace_id: site.key } } + http_method :get + end + end + end + end +end diff --git a/lib/ebay_api/operations/sell/account/return_policy/update.rb b/lib/ebay_api/operations/sell/account/return_policy/update.rb new file mode 100644 index 0000000..2f82163 --- /dev/null +++ b/lib/ebay_api/operations/sell/account/return_policy/update.rb @@ -0,0 +1,18 @@ +class EbayAPI + scope :sell do + scope :account do + scope :return_policy do + # @see https://developer.ebay.com/api-docs/sell/account/resources/return_policy/methods/updateReturnPolicy + operation :update do + option :id, proc(&:to_s) + option :site, Site + option :data, proc(&:to_h) # TODO: add model to validate input + + path { id } + http_method :put + body { data.merge("marketplaceId" => site.key) } + end + end + end + end +end diff --git a/lib/ebay_api/operations/sell/marketing/ads.rb b/lib/ebay_api/operations/sell/marketing/ads.rb index ffce504..a40de57 100644 --- a/lib/ebay_api/operations/sell/marketing/ads.rb +++ b/lib/ebay_api/operations/sell/marketing/ads.rb @@ -21,7 +21,7 @@ class EbayAPI code = data.dig("errors", 0, "errorId") message = data.dig("errors", 0, "message") case code - when 35_060, 35_067 + when 35_060, 35_067, 35_077 raise EbayAPI::UserActionRequired.new(code: code), message else super! diff --git a/lib/ebay_api/operations/sell/marketing/campaigns.rb b/lib/ebay_api/operations/sell/marketing/campaigns.rb index b2b0683..05f7798 100644 --- a/lib/ebay_api/operations/sell/marketing/campaigns.rb +++ b/lib/ebay_api/operations/sell/marketing/campaigns.rb @@ -22,7 +22,7 @@ class EbayAPI code = data.dig("errors", 0, "errorId") message = data.dig("errors", 0, "message") case code - when 35_060 + when 35_060, 35_067, 35_077 raise EbayAPI::UserActionRequired.new(code: code), message else super! diff --git a/lib/ebay_api/operations/sell/metadata.rb b/lib/ebay_api/operations/sell/metadata.rb new file mode 100644 index 0000000..d5b7e86 --- /dev/null +++ b/lib/ebay_api/operations/sell/metadata.rb @@ -0,0 +1,13 @@ +# +# eBay Metadata API +# @see https://developer.ebay.com/api-docs/sell/metadata/overview.html +# +class EbayAPI + scope :sell do + scope :metadata do + path { "metadata/v#{EbayAPI::SELL_METADATA_VERSION.split(/\s|\./).first}" } + + require_relative "metadata/marketplace" + end + end +end diff --git a/lib/ebay_api/operations/sell/metadata/marketplace.rb b/lib/ebay_api/operations/sell/metadata/marketplace.rb new file mode 100644 index 0000000..93add5f --- /dev/null +++ b/lib/ebay_api/operations/sell/metadata/marketplace.rb @@ -0,0 +1,12 @@ +class EbayAPI + scope :sell 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 diff --git a/lib/ebay_api/operations/sell/metadata/marketplace/get_item_condition_policies.rb b/lib/ebay_api/operations/sell/metadata/marketplace/get_item_condition_policies.rb new file mode 100644 index 0000000..9d5c38c --- /dev/null +++ b/lib/ebay_api/operations/sell/metadata/marketplace/get_item_condition_policies.rb @@ -0,0 +1,14 @@ +# @see https://developer.ebay.com/api-docs/sell/metadata/resources/marketplace/methods/getItemConditionPolicies + +class EbayAPI + scope :sell 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 diff --git a/lib/ebay_api/paginated_collection.rb b/lib/ebay_api/paginated_collection.rb index b2cb3f7..6e0fefb 100644 --- a/lib/ebay_api/paginated_collection.rb +++ b/lib/ebay_api/paginated_collection.rb @@ -4,6 +4,10 @@ class EbayAPI class PaginatedCollection class Request < Evil::Client::Resolver::Request + def self.call(schema, settings, **options) + new(schema, settings, **options) + end + def initialize(schema, settings, uri:, limit: nil) super(schema, settings) @uri = URI(uri) @@ -38,12 +42,12 @@ def initialize(handler, response, key) @initial_next = @next end - def each - return to_enum unless block_given? + def each(&block) + return to_enum unless block @collection = @initial_collection @next = @initial_next loop do - @collection.each { |element| yield(element) } + @collection.each { |element| block.call(element) } raise StopIteration if all_records_loaded? load_next! end @@ -62,7 +66,7 @@ def load_next! middleware = Evil::Client::Resolver::Middleware.call(@schema, @settings) connection = @schema.client.connection stack = middleware.inject(connection) { |app, layer| layer.new app } - handle_response(*stack.call(request)) + handle_response(*stack.call(request.environment)) end def handle_response(status, _headers, (data, *)) diff --git a/lib/ebay_api/token_manager.rb b/lib/ebay_api/token_manager.rb index 35b173a..66a2c73 100644 --- a/lib/ebay_api/token_manager.rb +++ b/lib/ebay_api/token_manager.rb @@ -11,10 +11,10 @@ class EbayAPI::TokenManager class RefreshTokenExpired < EbayAPI::Error; end class RefreshTokenInvalid < EbayAPI::Error; end - option :access_token - option :access_token_expires_at - option :refresh_token - option :refresh_token_expires_at + option :access_token, optional: true + option :access_token_expires_at, optional: true + option :refresh_token, optional: true + option :refresh_token_expires_at, optional: true option :appid option :certid option :on_refresh, optional: true @@ -37,6 +37,20 @@ class RefreshTokenInvalid < EbayAPI::Error; end # Callback. Will be called after successful renewal with two arguments: # new access token and its expiration time + # Returns new application access token + # https://apitut.com/ebay/api/oauth-application-token.html + def application_token + request_application_token!["access_token"] + end + + # Requests new application access token and returns raw data + def request_application_token! + request_token!( + grant_type: "client_credentials", + scope: "https://api.ebay.com/oauth/api_scope" + ) + end + # Returns access token (retrieves and returns new one if it has expired) def access_token refresh! if access_token_expires_at&.<= Time.now + 60 # time drift margin @@ -59,25 +73,29 @@ def refresh! private def refresh_token_request! - response = - request! token_endpoint, - grant_type: "refresh_token", refresh_token: refresh_token + request_token!(grant_type: "refresh_token", refresh_token: refresh_token) + end + + def request_token!(options) + response = request!(token_endpoint, **options) body = JSON.parse(response.body) return body if response.is_a? Net::HTTPSuccess handle_errors!(body) rescue JSON::ParserError - raise EbayAPI::Error, "Can't refresh access token: #{response.body}" + message = "Response isn't JSON: #{response.code} - #{response.body}" + raise EbayAPI::Error, "Can't refresh access token: #{message}" end def handle_errors!(response) - message = response["error_description"] + cause = response.values_at("error", "error_description").compact.join(" - ") + cause = response if cause.length.zero? case response["error"] when "server_error" - raise EbayAPI::InternalServerError, message - when "invalid_grant" - raise RefreshTokenInvalid, message + raise EbayAPI::InternalServerError, cause + when "invalid_grant", "unauthorized_client" + raise RefreshTokenInvalid, cause else - raise EbayAPI::Error, "Can't refresh access token: #{message}" + raise EbayAPI::Error, "Can't refresh access token: #{cause}" end end diff --git a/spec/error_handling_spec.rb b/spec/error_handling_spec.rb index 4dd5566..732db8f 100644 --- a/spec/error_handling_spec.rb +++ b/spec/error_handling_spec.rb @@ -1,14 +1,16 @@ RSpec.describe EbayAPI, "error handling" do let!(:operation) do class EbayAPI - operation :test_error_handling do - http_method :get - path "sell/marketing/v1/ad_campaign" + scope :error_handling do + operation :test_error_handling do + http_method :get + path "sell/marketing/v1/ad_campaign" + end end end end - let(:client) { EbayAPI.new(yaml_fixture_file(settings_file)) } + let(:client) { EbayAPI.new(**yaml_fixture_file(settings_file)) } let(:settings_file) { "settings.valid.yml" } let!(:request) do @@ -16,7 +18,7 @@ class EbayAPI stub_request(:get, uri).to_return(response) end - subject { client.test_error_handling } + subject { client.error_handling.test_error_handling } context "on eBay's internal server error" do let(:response) do diff --git a/spec/fixtures/commerce/catalog/product_summary/search/matched-with-keywords b/spec/fixtures/commerce/catalog/product_summary/search/matched-with-keywords new file mode 100644 index 0000000..e842c1b --- /dev/null +++ b/spec/fixtures/commerce/catalog/product_summary/search/matched-with-keywords @@ -0,0 +1,4 @@ +HTTP/1.1 200 OK +Content-Type: application/json + +{"productSummaries":[{"epid":"241996593","gtin":["0888462068420"],"brand":"Apple","mpn":["MH1G2CL/A"],"image":{"imageUrl":"https://i.ebayimg.com/00/s/NjAwWDgwMA==/z/~V8AAOSwi4laZFiI/$_6.JPG?set_id=89040003C1"},"aspects":[{"localizedName":"Brand","localizedValues":["Apple"]},{"localizedName":"Hardware Connectivity","localizedValues":["Bluetooth","Wi-Fi"]},{"localizedName":"Type","localizedValues":["Tablet"]},{"localizedName":"Internet Connectivity","localizedValues":["Wi-Fi + Cellular"]},{"localizedName":"Carrier","localizedValues":["Rogers Wireless"]},{"localizedName":"Storage Capacity","localizedValues":["128GB"]},{"localizedName":"Resolution","localizedValues":["2048 x 1536"]},{"localizedName":"Screen Size","localizedValues":["9.7in."]},{"localizedName":"Processor","localizedValues":["Triple Core"]},{"localizedName":"Model","localizedValues":["Apple iPad Air 2"]},{"localizedName":"Processor Speed","localizedValues":["1.5GHz"]},{"localizedName":"RAM","localizedValues":["2GB"]},{"localizedName":"Color","localizedValues":["Gold"]},{"localizedName":"Product Information","localizedValues":["With an integrated memory of 128 GB the Apple iPad Air 2 Wi-Fi + Cellular makes storing user data and downloaded content easy. Running on iOS operating system, this Apple tablet offers a variety of handy features, as well as Wi-Fi + 4G connectivity. Additionally, this Apple iPad Air 2 weighs 0.44 kg (1 lb.) and comes in gold color with 9.7in (24.64 cm) display, ensuring convenient usage and menu navigation."]},{"localizedName":"Display Size","localizedValues":["9.7in (24.64cm)"]},{"localizedName":"Operating System","localizedValues":["iOS"]},{"localizedName":"Exterior Color","localizedValues":["Gold"]},{"localizedName":"Processor Manufacturer","localizedValues":["Apple"]},{"localizedName":"Processor Type","localizedValues":["Apple A8X"]},{"localizedName":"Display Tech","localizedValues":["Retina Display"]},{"localizedName":"Max. Video Resolution","localizedValues":["1920 x 1080"]},{"localizedName":"Touch Screen Technology","localizedValues":["Multi-Touch"]},{"localizedName":"Rear Camera Resolution","localizedValues":["8 Megapixel"]},{"localizedName":"Front Camera Resolution","localizedValues":["1.2 Channel Megapixel"]},{"localizedName":"RAM Technology","localizedValues":["LPDDR3 RAM"]},{"localizedName":"Installed RAM","localizedValues":["2 ChannelGB"]},{"localizedName":"Networking Type","localizedValues":["3G","4G","Bluetooth","Integrated Wireless LAN"]},{"localizedName":"Expansion Ports","localizedValues":["Lightning connector"]},{"localizedName":"PC Interface","localizedValues":["Bluetooth","Wi-Fi"]},{"localizedName":"Wireless capabilities","localizedValues":["Bluetooth","WLAN 802.11a","WLAN 802.11b","WLAN 802.11g","WLAN 802.11n"]},{"localizedName":"Audio Input","localizedValues":["Microphone"]},{"localizedName":"Audio Output","localizedValues":["Headphones","Speaker(s)"]},{"localizedName":"Height","localizedValues":["9.4in (24cm)"]},{"localizedName":"Width","localizedValues":["6.6in (16.95cm)"]},{"localizedName":"Depth","localizedValues":["0.24in (0.61cm)"]},{"localizedName":"Weight","localizedValues":["0.98lb. (0.44kg)"]},{"localizedName":"Battery Technology","localizedValues":["Rechargeable Lithium-Polymer"]},{"localizedName":"Battery Run Time","localizedValues":["UP to 9hr."]},{"localizedName":"Input Method","localizedValues":["Touch-Screen"]},{"localizedName":"Platform","localizedValues":["Mac","PC"]},{"localizedName":"Release Date","localizedValues":["10/16/2014"]},{"localizedName":"Security Features","localizedValues":["Finger Print Sensor","Quick Lock"]},{"localizedName":"Special Features","localizedValues":["Backlight","Bluetooth","Built-In Front Camera","Built-In Rear Camera","HD","Retina Display","Touch Screen","Web Browser"]}],"ean":["0888462068420"],"upc":["0888462068420"],"productHref":"https://api.sandbox.ebay.com/commerce/catalog/v1_beta/product/241996593","title":"Apple iPad Air 2 128GB, Wi-Fi + Cellular (Rogers Wireless), 9.7in - Gold (CA)","productWebUrl":"https://www.ebay.com/p/Apple-iPad-Air-2-128GB-Wi-Fi-Cellular-Rogers-Wireless-9-7in-Gold-CA/241996593?src=urllib"},{"epid":"241922865","gtin":["0888462535502"],"brand":"Apple","mpn":["ML2N2CL/A"],"image":{"imageUrl":"https://i.ebayimg.com/00/s/ODU0WDYxNg==/z/xsoAAOSwjytaZFi2/$_6.JPG?set_id=89040003C1"},"aspects":[{"localizedName":"Brand","localizedValues":["Apple"]},{"localizedName":"Hardware Connectivity","localizedValues":["Bluetooth","Wi-Fi"]},{"localizedName":"Type","localizedValues":["Tablet"]},{"localizedName":"Internet Connectivity","localizedValues":["Wi-Fi + Cellular"]},{"localizedName":"Carrier","localizedValues":["Telus"]},{"localizedName":"Storage Capacity","localizedValues":["256GB"]},{"localizedName":"Resolution","localizedValues":["2732 x 2048"]},{"localizedName":"Screen Size","localizedValues":["12.9in."]},{"localizedName":"Processor","localizedValues":["Dual Core"]},{"localizedName":"Model","localizedValues":["Apple iPad Pro (1st Generation)"]},{"localizedName":"Processor Speed","localizedValues":["2.26GHz"]},{"localizedName":"RAM","localizedValues":["4GB"]},{"localizedName":"Color","localizedValues":["Gold"]},{"localizedName":"Product Information","localizedValues":["Simple to use and highly portable, Apple’s iPad Pro is a powerful tablet, which impresses with the combination of efficient operation and stylish exterior. This gold tablet offers multiple connection options and its fast 2.16 GHz processor makes apps run smoothly. The large 12.9-inch Retina display with a resolution of 2732 x 2048 pixels makes images and video appear bright and crisp with fantastic contrast, while its responsiveness opens up a variety of creative possibilities. This Apple iPad Pro has 256GB of storage to effortlessly accommodate all your data. The device is available with the services of Telus and features Wi-Fi + Cellular connectivity for fast and simple Internet browsing."]},{"localizedName":"Display Size","localizedValues":["12.9in (32.77cm)"]},{"localizedName":"Operating System","localizedValues":["iOS"]},{"localizedName":"Exterior Color","localizedValues":["Gold"]},{"localizedName":"Processor Manufacturer","localizedValues":["Apple"]},{"localizedName":"Processor Type","localizedValues":["Apple A9X"]},{"localizedName":"Display Tech","localizedValues":["Retina Display"]},{"localizedName":"Max. Video Resolution","localizedValues":["1920 x 1080"]},{"localizedName":"Touch Screen Technology","localizedValues":["Multi-Touch"]},{"localizedName":"Rear Camera Resolution","localizedValues":["8 Megapixel"]},{"localizedName":"Front Camera Resolution","localizedValues":["1.2 Channel Megapixel"]},{"localizedName":"RAM Technology","localizedValues":["LPDDR4 SDRAM"]},{"localizedName":"Installed RAM","localizedValues":["4GB"]},{"localizedName":"Networking Type","localizedValues":["3G","4G","Bluetooth","Integrated Wireless LAN"]},{"localizedName":"Expansion Ports","localizedValues":["Lightning connector"]},{"localizedName":"PC Interface","localizedValues":["Bluetooth","Wi-Fi"]},{"localizedName":"Interface","localizedValues":["Camera","USB"]},{"localizedName":"Wireless capabilities","localizedValues":["Bluetooth","Built-in Wireless","WLAN 802.11a","WLAN 802.11ac","WLAN 802.11b","WLAN 802.11g","WLAN 802.11n","dual channel (2.4GHz and 5GHz) and MIMO"]},{"localizedName":"Audio Input","localizedValues":["Microphone"]},{"localizedName":"Audio Output","localizedValues":["Headphones","Speaker(s)"]},{"localizedName":"Height","localizedValues":["12in (30.57cm)"]},{"localizedName":"Width","localizedValues":["8.68in (22.06cm)"]},{"localizedName":"Depth","localizedValues":["0.27in (0.69cm)"]},{"localizedName":"Weight","localizedValues":["1.59lb. (0.72kg)"]},{"localizedName":"Battery Technology","localizedValues":["Rechargeable Lithium-Polymer"]},{"localizedName":"Battery Run Time","localizedValues":["UP to 10hr."]},{"localizedName":"Input Method","localizedValues":["Camera","Touch-Screen"]},{"localizedName":"Platform","localizedValues":["Mac","PC"]},{"localizedName":"Release Date","localizedValues":["9/9/2015"]},{"localizedName":"Security Features","localizedValues":["Quick Lock"]},{"localizedName":"Special Features","localizedValues":["Backlight","Bluetooth","Built-In Front Camera","Built-In Rear Camera","HD","Retina Display","Touch Screen","Web Browser"]}],"ean":["0888462535502"],"upc":["0888462535502"],"productHref":"https://api.sandbox.ebay.com/commerce/catalog/v1_beta/product/241922865","title":"Apple iPad Pro 256GB, Wi-Fi + Cellular (Telus), 12.9in - Gold (CA)","productWebUrl":"https://www.ebay.com/p/Apple-iPad-Pro-256GB-Wi-Fi-Cellular-Telus-12-9in-Gold-CA/241922865?src=urllib"}],"limit":10} \ No newline at end of file diff --git a/spec/fixtures/commerce/catalog/product_summary/search/no-matching b/spec/fixtures/commerce/catalog/product_summary/search/no-matching new file mode 100644 index 0000000..f6cb45b --- /dev/null +++ b/spec/fixtures/commerce/catalog/product_summary/search/no-matching @@ -0,0 +1,2 @@ +HTTP/1.1 204 OK +Content-Type: application/json diff --git a/spec/fixtures/commerce/catalog/product_summary/search/without-params b/spec/fixtures/commerce/catalog/product_summary/search/without-params new file mode 100644 index 0000000..9c43745 --- /dev/null +++ b/spec/fixtures/commerce/catalog/product_summary/search/without-params @@ -0,0 +1,4 @@ +HTTP/1.1 400 Bad Request +Content-Type: application/json + +{"errors":[{"errorId":75001,"domain":"API_CATALOG","category":"REQUEST","message":" The call must have a valid 'q', or 'category_ids' or 'gtin' or 'mpn' query parameter. "}]} diff --git a/spec/fixtures/commerce/notification/public_key/get/success b/spec/fixtures/commerce/notification/public_key/get/success new file mode 100644 index 0000000..1a8b801 --- /dev/null +++ b/spec/fixtures/commerce/notification/public_key/get/success @@ -0,0 +1,5 @@ +HTTP/1.1 200 OK +Content-Length: 220 +Content-Type: application/json + +{"algorithm":"ECDSA","digest":"SHA1","key":"-----BEGIN PUBLIC KEY-----MFkwEwYHKoZIzj0CAQYIKoZIzj0DAQcDQgAEZhhxXKtR+TOvtDbgTPCkSof02qgBB7IsYOyf76ilExJ/upAa/vKIKheOoCyOpcLmi4t0b4uepb7LLjmMr90FUg==-----END PUBLIC KEY-----"} \ No newline at end of file diff --git a/spec/fixtures/commerce/notification/public_key/get/success.yml b/spec/fixtures/commerce/notification/public_key/get/success.yml new file mode 100644 index 0000000..473a51f --- /dev/null +++ b/spec/fixtures/commerce/notification/public_key/get/success.yml @@ -0,0 +1,5 @@ +--- +algorithm: "ECDSA" +digest: "SHA1" +key: "-----BEGIN PUBLIC KEY-----MFkwEwYHKoZIzj0CAQYIKoZIzj0DAQcDQgAEZhhxXKtR+TOvtDbgTPCkSof02qgBB7IsYOyf76ilExJ/upAa/vKIKheOoCyOpcLmi4t0b4uepb7LLjmMr90FUg==-----END + PUBLIC KEY-----" diff --git a/spec/fixtures/commerce/taxonomy/category_tree/fetch_item_aspects/success.json b/spec/fixtures/commerce/taxonomy/category_tree/fetch_item_aspects/success.json new file mode 100644 index 0000000..31470c7 --- /dev/null +++ b/spec/fixtures/commerce/taxonomy/category_tree/fetch_item_aspects/success.json @@ -0,0 +1 @@ +{"categoryTreeId": "string", "categoryTreeVersion": "string", "categoryAspects": [{"category": {"categoryId": "string", "categoryName": "string"}, "aspects": [{"aspectConstraint": {"aspectApplicableTo": ["AspectApplicableToEnum"], "aspectDataType": "AspectDataTypeEnum : [DATE,NUMBER,STRING,STRING_ARRAY]", "aspectEnabledForVariations": "boolean", "aspectFormat": "string", "aspectMaxLength": "integer", "aspectMode": "AspectModeEnum : [FREE_TEXT,SELECTION_ONLY]", "aspectRequired": "boolean", "aspectUsage": "AspectUsageEnum : [RECOMMENDED,OPTIONAL]", "expectedRequiredByDate": "string", "itemToAspectCardinality": "ItemToAspectCardinalityEnum : [MULTI,SINGLE]"}, "aspectValues": [{"localizedValue": "string", "valueConstraints": [{"applicableForLocalizedAspectName": "string", "applicableForLocalizedAspectValues": ["string"]}]}], "localizedAspectName": "string", "relevanceIndicator": {"searchCount": "integer"}}]}]} \ No newline at end of file diff --git a/spec/fixtures/commerce/taxonomy/category_tree/get/success b/spec/fixtures/commerce/taxonomy/category_tree/get/success new file mode 100644 index 0000000..5aa3401 --- /dev/null +++ b/spec/fixtures/commerce/taxonomy/category_tree/get/success @@ -0,0 +1,5 @@ +HTTP/1.1 200 OK +Content-Length: 751 +Content-Type: application/json + +{"applicableMarketplaceIds": ["MarketplaceIdEnum"], "categoryTreeId": "string", "categoryTreeVersion": "string", "rootCategoryNode": {"category": {"categoryId": "string", "categoryName": "string"}, "categoryTreeNodeLevel": "integer", "childCategoryTreeNodes": [{"category": {"categoryId": "string", "categoryName": "string"}, "categoryTreeNodeLevel": "integer", "childCategoryTreeNodes": [{"category": {"categoryId": "string", "categoryName": "string"}, "categoryTreeNodeLevel": "integer", "childCategoryTreeNodes": [{}], "leafCategoryTreeNode": "boolean", "parentCategoryTreeNodeHref": "string"}], "leafCategoryTreeNode": "boolean", "parentCategoryTreeNodeHref": "string"}], "leafCategoryTreeNode": "boolean", "parentCategoryTreeNodeHref": "string"}} \ No newline at end of file diff --git a/spec/fixtures/commerce/taxonomy/category_tree/get_category_subtree/success b/spec/fixtures/commerce/taxonomy/category_tree/get_category_subtree/success new file mode 100644 index 0000000..751de64 --- /dev/null +++ b/spec/fixtures/commerce/taxonomy/category_tree/get_category_subtree/success @@ -0,0 +1,5 @@ +HTTP/1.1 200 OK +Content-Length: 703 +Content-Type: application/json + +{"categorySubtreeNode": {"category": {"categoryId": "string", "categoryName": "string"}, "categoryTreeNodeLevel": "integer", "childCategoryTreeNodes": [{"category": {"categoryId": "string", "categoryName": "string"}, "categoryTreeNodeLevel": "integer", "childCategoryTreeNodes": [{"category": {"categoryId": "string", "categoryName": "string"}, "categoryTreeNodeLevel": "integer", "childCategoryTreeNodes": [{}], "leafCategoryTreeNode": "boolean", "parentCategoryTreeNodeHref": "string"}], "leafCategoryTreeNode": "boolean", "parentCategoryTreeNodeHref": "string"}], "leafCategoryTreeNode": "boolean", "parentCategoryTreeNodeHref": "string"}, "categoryTreeId": "string", "categoryTreeVersion": "string"} \ No newline at end of file diff --git a/spec/fixtures/commerce/taxonomy/category_tree/get_category_suggestions/success b/spec/fixtures/commerce/taxonomy/category_tree/get_category_suggestions/success new file mode 100644 index 0000000..3e2b8db --- /dev/null +++ b/spec/fixtures/commerce/taxonomy/category_tree/get_category_suggestions/success @@ -0,0 +1,5 @@ +HTTP/1.1 200 OK +Content-Length: 367 +Content-Type: application/json + +{"categorySuggestions": [{"category": {"categoryId": "string", "categoryName": "string"}, "categoryTreeNodeAncestors": [{"categoryId": "string", "categoryName": "string", "categorySubtreeNodeHref": "string", "categoryTreeNodeLevel": "integer"}], "categoryTreeNodeLevel": "integer", "relevancy": "string"}], "categoryTreeId": "string", "categoryTreeVersion": "string"} \ No newline at end of file diff --git a/spec/fixtures/commerce/taxonomy/category_tree/get_item_aspects_for_category/success b/spec/fixtures/commerce/taxonomy/category_tree/get_item_aspects_for_category/success new file mode 100644 index 0000000..9b5fa80 --- /dev/null +++ b/spec/fixtures/commerce/taxonomy/category_tree/get_item_aspects_for_category/success @@ -0,0 +1,5 @@ +HTTP/1.1 200 OK +Content-Length: 771 +Content-Type: application/json + +{"aspects": [{"aspectConstraint": {"aspectApplicableTo": ["AspectApplicableToEnum"], "aspectDataType": "AspectDataTypeEnum : [DATE,NUMBER,STRING,STRING_ARRAY]", "aspectEnabledForVariations": "boolean", "aspectFormat": "string", "aspectMaxLength": "integer", "aspectMode": "AspectModeEnum : [FREE_TEXT,SELECTION_ONLY]", "aspectRequired": "boolean", "aspectUsage": "AspectUsageEnum : [RECOMMENDED,OPTIONAL]", "expectedRequiredByDate": "string", "itemToAspectCardinality": "ItemToAspectCardinalityEnum : [MULTI,SINGLE]"}, "aspectValues": [{"localizedValue": "string", "valueConstraints": [{"applicableForLocalizedAspectName": "string", "applicableForLocalizedAspectValues": ["string"]}]}], "localizedAspectName": "string", "relevanceIndicator": {"searchCount": "integer"}}]} \ No newline at end of file diff --git a/spec/fixtures/commerce/taxonomy/get_default_category_tree_id/success b/spec/fixtures/commerce/taxonomy/get_default_category_tree_id/success new file mode 100644 index 0000000..eaa275e --- /dev/null +++ b/spec/fixtures/commerce/taxonomy/get_default_category_tree_id/success @@ -0,0 +1,5 @@ +HTTP/1.1 200 OK +Content-Length: 220 +Content-Type: application/json + +{"categoryTreeId": "string", "categoryTreeVersion": "string"} \ No newline at end of file diff --git a/spec/fixtures/developer/analytics/rate_limit/get/api_context_and_name_response b/spec/fixtures/developer/analytics/rate_limit/get/api_context_and_name_response new file mode 100644 index 0000000..35827ce --- /dev/null +++ b/spec/fixtures/developer/analytics/rate_limit/get/api_context_and_name_response @@ -0,0 +1,4 @@ +HTTP/1.1 200 OK +Content-Type: application/json + +{"rateLimits":[{"apiContext":"sell","apiName":"Negotiation","apiVersion":"v1","resources":[{"name":"sell.negotiation"}]}]} diff --git a/spec/fixtures/developer/analytics/rate_limit/get/api_context_response b/spec/fixtures/developer/analytics/rate_limit/get/api_context_response new file mode 100644 index 0000000..31e8f33 --- /dev/null +++ b/spec/fixtures/developer/analytics/rate_limit/get/api_context_response @@ -0,0 +1,4 @@ +HTTP/1.1 200 OK +Content-Type: application/json + +{"rateLimits":[{"apiContext":"sell","apiName":"Negotiation","apiVersion":"v1","resources":[{"name":"sell.negotiation"}]},{"apiContext":"sell","apiName":"listingapi","apiVersion":"v1_beta","resources":[{"name":"createListingDraft"}]},{"apiContext":"sell","apiName":"logistics","apiVersion":"v1","resources":[{"name":"sell.logistics"}]},{"apiContext":"sell","apiName":"recommendation","apiVersion":"v1","resources":[{"name":"DELETE"}, {"name":"POST"}, {"name":"GET"}, {"name":"PUT"}]},{"apiContext":"sell","apiName":"research","apiVersion":"v1","resources":[{"name":"sell.research.product_insight"}]}]} diff --git a/spec/fixtures/developer/analytics/rate_limit/get/api_name_response b/spec/fixtures/developer/analytics/rate_limit/get/api_name_response new file mode 100644 index 0000000..35827ce --- /dev/null +++ b/spec/fixtures/developer/analytics/rate_limit/get/api_name_response @@ -0,0 +1,4 @@ +HTTP/1.1 200 OK +Content-Type: application/json + +{"rateLimits":[{"apiContext":"sell","apiName":"Negotiation","apiVersion":"v1","resources":[{"name":"sell.negotiation"}]}]} diff --git a/spec/fixtures/developer/analytics/rate_limit/get/no_data_response b/spec/fixtures/developer/analytics/rate_limit/get/no_data_response new file mode 100644 index 0000000..9670778 --- /dev/null +++ b/spec/fixtures/developer/analytics/rate_limit/get/no_data_response @@ -0,0 +1,4 @@ +HTTP/1.1 204 No Content +Content-Type: application/json + +{"rateLimits":[]} diff --git a/spec/fixtures/developer/analytics/rate_limit/get/no_params_response b/spec/fixtures/developer/analytics/rate_limit/get/no_params_response new file mode 100644 index 0000000..410f68c --- /dev/null +++ b/spec/fixtures/developer/analytics/rate_limit/get/no_params_response @@ -0,0 +1,4 @@ +HTTP/1.1 200 OK +Content-Type: application/json + +{"rateLimits":[{"apiContext":"buy","apiName":"Browse","apiVersion":"v1","resources":[{"name":"buy.browse"},{"name":"buy.browse.item.bulk"}]},{"apiContext":"commerce","apiName":"translation","apiVersion":"v1_beta","resources":[{"name":"commerce.translation.translate"}]},{"apiContext":"sell","apiName":"Negotiation","apiVersion":"v1","resources":[{"name":"sell.negotiation"}]},{"apiContext":"sell","apiName":"listingapi","apiVersion":"v1_beta","resources":[{"name":"createListingDraft"}]},{"apiContext":"sell","apiName":"logistics","apiVersion":"v1","resources":[{"name":"sell.logistics"}]},{"apiContext":"sell","apiName":"recommendation","apiVersion":"v1","resources":[{"name":"DELETE"},{"name":"POST"},{"name":"GET"},{"name":"PUT"}]},{"apiContext":"sell","apiName":"research","apiVersion":"v1","resources":[{"name":"sell.research.product_insight"}]}]} diff --git a/spec/fixtures/sell/account/fulfillment_policy/create/request.yml b/spec/fixtures/sell/account/fulfillment_policy/create/request.yml new file mode 100644 index 0000000..e1d1fbc --- /dev/null +++ b/spec/fixtures/sell/account/fulfillment_policy/create/request.yml @@ -0,0 +1,16 @@ +--- +name: Domestic free shipping +marketplaceId: EBAY_US +categoryTypes: + - name: ALL_EXCLUDING_MOTORS_VEHICLES +handlingTime: + unit: DAY + value: 1 +shippingOptions: + - costType: FLAT_RATE + optionType: DOMESTIC + shippingServices: + - buyerResponsibleForShipping: false + freeShipping: true + shippingCarrierCode: USPS + shippingServiceCode: USPSPriorityFlatRateBox diff --git a/spec/fixtures/sell/account/fulfillment_policy/create/success b/spec/fixtures/sell/account/fulfillment_policy/create/success new file mode 100644 index 0000000..4022949 --- /dev/null +++ b/spec/fixtures/sell/account/fulfillment_policy/create/success @@ -0,0 +1,6 @@ +HTTP/1.1 201 Created +Content-Length: 738 +Content-Type: application/json + +{"name":"Domestic free shipping","marketplaceId":"EBAY_US","categoryTypes":[{"name":"ALL_EXCLUDING_MOTORS_VEHICLES","default":false}],"handlingTime":{"value":1,"unit":"DAY"},"shippingOptions":[{"optionType":"DOMESTIC","costType":"FLAT_RATE","shippingServices":[{"sortOrder":1,"shippingCarrierCode":"USPS","shippingServiceCode":"USPSPriorityFlatRateBox","shippingCost":{"value":0.0,"currency":"USD"},"additionalShippingCost":{"value":0.0,"currency":"USD"},"freeShipping":true,"buyerResponsibleForShipping":false,"buyerResponsibleForPickup":false}],"insuranceOffered":false,"insuranceFee":{"value":0.0,"currency":"USD"}}],"globalShipping":false,"pickupDropOff":false,"freightShipping":false,"fulfillmentPolicyId":"5733588000","warnings":[]} + diff --git a/spec/fixtures/sell/account/fulfillment_policy/create/success.yml b/spec/fixtures/sell/account/fulfillment_policy/create/success.yml new file mode 100644 index 0000000..10377b1 --- /dev/null +++ b/spec/fixtures/sell/account/fulfillment_policy/create/success.yml @@ -0,0 +1,34 @@ +--- +name: Domestic free shipping +marketplaceId: EBAY_US +categoryTypes: + - name: ALL_EXCLUDING_MOTORS_VEHICLES + default: false +handlingTime: + value: 1 + unit: DAY +shippingOptions: + - optionType: DOMESTIC + costType: FLAT_RATE + shippingServices: + - sortOrder: 1 + shippingCarrierCode: USPS + shippingServiceCode: USPSPriorityFlatRateBox + shippingCost: + value: 0.0 + currency: USD + additionalShippingCost: + value: 0.0 + currency: USD + freeShipping: true + buyerResponsibleForShipping: false + buyerResponsibleForPickup: false + insuranceOffered: false + insuranceFee: + value: 0.0 + currency: USD +globalShipping: false +pickupDropOff: false +freightShipping: false +fulfillmentPolicyId: '5733588000' +warnings: [] diff --git a/spec/fixtures/sell/account/fulfillment_policy/get/success b/spec/fixtures/sell/account/fulfillment_policy/get/success new file mode 100644 index 0000000..9d7ad70 --- /dev/null +++ b/spec/fixtures/sell/account/fulfillment_policy/get/success @@ -0,0 +1,6 @@ +HTTP/1.1 200 OK +Content-Length: 724 +Content-Type: application/json + +{"name":"Domestic free shipping","marketplaceId":"EBAY_US","categoryTypes":[{"name":"ALL_EXCLUDING_MOTORS_VEHICLES","default":false}],"handlingTime":{"value":1,"unit":"DAY"},"shippingOptions":[{"optionType":"DOMESTIC","costType":"FLAT_RATE","shippingServices":[{"sortOrder":1,"shippingCarrierCode":"USPS","shippingServiceCode":"USPSPriorityFlatRateBox","shippingCost":{"value":0.0,"currency":"USD"},"additionalShippingCost":{"value":0.0,"currency":"USD"},"freeShipping":true,"buyerResponsibleForShipping":false,"buyerResponsibleForPickup":false}],"insuranceOffered":false,"insuranceFee":{"value":0.0,"currency":"USD"}}],"globalShipping":false,"pickupDropOff":false,"freightShipping":false,"fulfillmentPolicyId":"5733588000"} + diff --git a/spec/fixtures/sell/account/fulfillment_policy/get/success.yml b/spec/fixtures/sell/account/fulfillment_policy/get/success.yml new file mode 100644 index 0000000..1319be3 --- /dev/null +++ b/spec/fixtures/sell/account/fulfillment_policy/get/success.yml @@ -0,0 +1,33 @@ +--- +name: "Domestic free shipping" +marketplaceId: "EBAY_US" +categoryTypes: + - name: "ALL_EXCLUDING_MOTORS_VEHICLES" + default: false +handlingTime: + value: 1 + unit: "DAY" +shippingOptions: + - optionType: "DOMESTIC" + costType: "FLAT_RATE" + shippingServices: + - sortOrder: 1 + shippingCarrierCode: "USPS" + shippingServiceCode: "USPSPriorityFlatRateBox" + shippingCost: + value: 0.0 + currency: "USD" + additionalShippingCost: + value: 0.0 + currency: "USD" + freeShipping: true + buyerResponsibleForShipping: false + buyerResponsibleForPickup: false + insuranceOffered: false + insuranceFee: + value: 0.0 + currency: "USD" +globalShipping: false +pickupDropOff: false +freightShipping: false +fulfillmentPolicyId: "5733588000" diff --git a/spec/fixtures/sell/account/fulfillment_policy/get_by_name/success b/spec/fixtures/sell/account/fulfillment_policy/get_by_name/success new file mode 100644 index 0000000..1e6155f --- /dev/null +++ b/spec/fixtures/sell/account/fulfillment_policy/get_by_name/success @@ -0,0 +1,6 @@ +HTTP/1.1 200 OK +Content-Length: 1249 +Content-Type: application/json + +{"name":"Worldwide shipping options: Free domestic, CALCULATED int'l","marketplaceId":"EBAY_US","categoryTypes":[{"name":"ALL_EXCLUDING_MOTORS_VEHICLES","default":false}],"handlingTime":{"value":1,"unit":"DAY"},"shipToLocations":{"regionIncluded":[{"regionName":"Worldwide"}],"regionExcluded":[]},"shippingOptions":[{"optionType":"DOMESTIC","costType":"FLAT_RATE","shippingServices":[{"sortOrder":1,"shippingCarrierCode":"USPS","shippingServiceCode":"USPSPriorityFlatRateBox","shippingCost":{"value":0.0,"currency":"USD"},"additionalShippingCost":{"value":0.0,"currency":"USD"},"freeShipping":true,"buyerResponsibleForShipping":false,"buyerResponsibleForPickup":false}],"insuranceOffered":false,"insuranceFee":{"value":0.0,"currency":"USD"}},{"optionType":"INTERNATIONAL","costType":"CALCULATED","shippingServices":[{"sortOrder":1,"shippingCarrierCode":"USPS","shippingServiceCode":"USPSPriorityMailInternational","freeShipping":false,"shipToLocations":{"regionIncluded":[{"regionName":"Worldwide"}]},"buyerResponsibleForShipping":true,"buyerResponsibleForPickup":false}],"insuranceOffered":false,"insuranceFee":{"value":0.0,"currency":"USD"}}],"globalShipping":false,"pickupDropOff":false,"freightShipping":false,"fulfillmentPolicyId":"5733606000"} + diff --git a/spec/fixtures/sell/account/fulfillment_policy/get_by_name/success.yml b/spec/fixtures/sell/account/fulfillment_policy/get_by_name/success.yml new file mode 100644 index 0000000..5ceab01 --- /dev/null +++ b/spec/fixtures/sell/account/fulfillment_policy/get_by_name/success.yml @@ -0,0 +1,53 @@ +--- +name: "Worldwide shipping options: Free domestic, CALCULATED int'l" +marketplaceId: "EBAY_US" +categoryTypes: + - name: "ALL_EXCLUDING_MOTORS_VEHICLES" + default: false +handlingTime: + value: 1 + unit: "DAY" +shipToLocations: + regionIncluded: + - regionName: "Worldwide" + regionExcluded: [] +shippingOptions: + - optionType: "DOMESTIC" + costType: "FLAT_RATE" + shippingServices: + - sortOrder: 1 + shippingCarrierCode: "USPS" + shippingServiceCode: "USPSPriorityFlatRateBox" + shippingCost: + value: 0.0 + currency: "USD" + additionalShippingCost: + value: 0.0 + currency: "USD" + freeShipping: true + buyerResponsibleForShipping: false + buyerResponsibleForPickup: false + insuranceOffered: false + insuranceFee: + value: 0.0 + currency: "USD" + - optionType: "INTERNATIONAL" + costType: "CALCULATED" + shippingServices: + - sortOrder: 1 + shippingCarrierCode: "USPS" + shippingServiceCode: "USPSPriorityMailInternational" + freeShipping: false + shipToLocations: + regionIncluded: + - regionName: "Worldwide" + buyerResponsibleForShipping: true + buyerResponsibleForPickup: false + insuranceOffered: false + insuranceFee: + value: 0.0 + currency: "USD" +globalShipping: false +pickupDropOff: false +freightShipping: false +fulfillmentPolicyId: "5733606000" diff --git a/spec/fixtures/sell/account/fulfillment_policy/index/success b/spec/fixtures/sell/account/fulfillment_policy/index/success new file mode 100644 index 0000000..969b4a0 --- /dev/null +++ b/spec/fixtures/sell/account/fulfillment_policy/index/success @@ -0,0 +1,6 @@ +HTTP/1.1 200 OK +Content-Length: 2010 +Content-Type: application/json + +{"total":2,"fulfillmentPolicies":[{"name":"Domestic free shipping","marketplaceId":"EBAY_US","categoryTypes":[{"name":"ALL_EXCLUDING_MOTORS_VEHICLES","default":false}],"handlingTime":{"value":1,"unit":"DAY"},"shippingOptions":[{"optionType":"DOMESTIC","costType":"FLAT_RATE","shippingServices":[{"sortOrder":1,"shippingCarrierCode":"USPS","shippingServiceCode":"USPSPriorityFlatRateBox","shippingCost":{"value":0.0,"currency":"USD"},"additionalShippingCost":{"value":0.0,"currency":"USD"},"freeShipping":true,"buyerResponsibleForShipping":false,"buyerResponsibleForPickup":false}],"insuranceOffered":false,"insuranceFee":{"value":0.0,"currency":"USD"}}],"globalShipping":false,"pickupDropOff":false,"freightShipping":false,"fulfillmentPolicyId":"5733588000"},{"name":"Worldwide shipping options: Free domestic, CALCULATED int'l","marketplaceId":"EBAY_US","categoryTypes":[{"name":"ALL_EXCLUDING_MOTORS_VEHICLES","default":false}],"handlingTime":{"value":1,"unit":"DAY"},"shipToLocations":{"regionIncluded":[{"regionName":"Worldwide"}],"regionExcluded":[]},"shippingOptions":[{"optionType":"DOMESTIC","costType":"FLAT_RATE","shippingServices":[{"sortOrder":1,"shippingCarrierCode":"USPS","shippingServiceCode":"USPSPriorityFlatRateBox","shippingCost":{"value":0.0,"currency":"USD"},"additionalShippingCost":{"value":0.0,"currency":"USD"},"freeShipping":true,"buyerResponsibleForShipping":false,"buyerResponsibleForPickup":false}],"insuranceOffered":false,"insuranceFee":{"value":0.0,"currency":"USD"}},{"optionType":"INTERNATIONAL","costType":"CALCULATED","shippingServices":[{"sortOrder":1,"shippingCarrierCode":"USPS","shippingServiceCode":"USPSPriorityMailInternational","freeShipping":false,"shipToLocations":{"regionIncluded":[{"regionName":"Worldwide"}]},"buyerResponsibleForShipping":true,"buyerResponsibleForPickup":false}],"insuranceOffered":false,"insuranceFee":{"value":0.0,"currency":"USD"}}],"globalShipping":false,"pickupDropOff":false,"freightShipping":false,"fulfillmentPolicyId":"5733606000"}]} + diff --git a/spec/fixtures/sell/account/fulfillment_policy/index/success.yml b/spec/fixtures/sell/account/fulfillment_policy/index/success.yml new file mode 100644 index 0000000..977488e --- /dev/null +++ b/spec/fixtures/sell/account/fulfillment_policy/index/success.yml @@ -0,0 +1,87 @@ +--- +total: 2 +fulfillmentPolicies: +- name: Domestic free shipping + marketplaceId: EBAY_US + categoryTypes: + - name: ALL_EXCLUDING_MOTORS_VEHICLES + default: false + handlingTime: + value: 1 + unit: DAY + shippingOptions: + - optionType: DOMESTIC + costType: FLAT_RATE + shippingServices: + - sortOrder: 1 + shippingCarrierCode: USPS + shippingServiceCode: USPSPriorityFlatRateBox + shippingCost: + value: 0.0 + currency: USD + additionalShippingCost: + value: 0.0 + currency: USD + freeShipping: true + buyerResponsibleForShipping: false + buyerResponsibleForPickup: false + insuranceOffered: false + insuranceFee: + value: 0.0 + currency: USD + globalShipping: false + pickupDropOff: false + freightShipping: false + fulfillmentPolicyId: '5733588000' +- name: 'Worldwide shipping options: Free domestic, CALCULATED int''l' + marketplaceId: EBAY_US + categoryTypes: + - name: ALL_EXCLUDING_MOTORS_VEHICLES + default: false + handlingTime: + value: 1 + unit: DAY + shipToLocations: + regionIncluded: + - regionName: Worldwide + regionExcluded: [] + shippingOptions: + - optionType: DOMESTIC + costType: FLAT_RATE + shippingServices: + - sortOrder: 1 + shippingCarrierCode: USPS + shippingServiceCode: USPSPriorityFlatRateBox + shippingCost: + value: 0.0 + currency: USD + additionalShippingCost: + value: 0.0 + currency: USD + freeShipping: true + buyerResponsibleForShipping: false + buyerResponsibleForPickup: false + insuranceOffered: false + insuranceFee: + value: 0.0 + currency: USD + - optionType: INTERNATIONAL + costType: CALCULATED + shippingServices: + - sortOrder: 1 + shippingCarrierCode: USPS + shippingServiceCode: USPSPriorityMailInternational + freeShipping: false + shipToLocations: + regionIncluded: + - regionName: Worldwide + buyerResponsibleForShipping: true + buyerResponsibleForPickup: false + insuranceOffered: false + insuranceFee: + value: 0.0 + currency: USD + globalShipping: false + pickupDropOff: false + freightShipping: false + fulfillmentPolicyId: '5733606000' diff --git a/spec/fixtures/sell/account/fulfillment_policy/update/request.yml b/spec/fixtures/sell/account/fulfillment_policy/update/request.yml new file mode 100644 index 0000000..864f004 --- /dev/null +++ b/spec/fixtures/sell/account/fulfillment_policy/update/request.yml @@ -0,0 +1,34 @@ +--- +categoryTypes: + - name: ALL_EXCLUDING_MOTORS_VEHICLES +marketplaceId: EBAY_US +name: "Worldwide shipping options: Free domestic, CALCULATED int'l" +globalShipping: false +handlingTime: + unit: DAY + value: 1 +shippingOptions: + - costType: FLAT_RATE + optionType: DOMESTIC + shippingServices: + - buyerResponsibleForShipping: false + freeShipping: true + shippingCarrierCode: USPS + shippingServiceCode: USPSPriorityFlatRateBox + shippingCost: + currency: USD + value: 0.0 + - costType: CALCULATED + optionType: INTERNATIONAL + insuranceOffered: true + insuranceFee: + value: 10.0 + currency: USD + shippingServices: + - buyerResponsibleForShipping: true + freeShipping: false + shippingCarrierCode: USPS + shippingServiceCode: USPSPriorityMailInternational + shipToLocations: + regionIncluded: + - regionName: Worldwide diff --git a/spec/fixtures/sell/account/fulfillment_policy/update/success b/spec/fixtures/sell/account/fulfillment_policy/update/success new file mode 100644 index 0000000..7a5b5d0 --- /dev/null +++ b/spec/fixtures/sell/account/fulfillment_policy/update/success @@ -0,0 +1,6 @@ +HTTP/1.1 200 OK +Content-Length: 1263 +Content-Type: application/json + +{"name":"Worldwide shipping options: Free domestic, CALCULATED int'l","marketplaceId":"EBAY_US","categoryTypes":[{"name":"ALL_EXCLUDING_MOTORS_VEHICLES","default":false}],"handlingTime":{"value":1,"unit":"DAY"},"shipToLocations":{"regionIncluded":[{"regionName":"Worldwide"}],"regionExcluded":[]},"shippingOptions":[{"optionType":"DOMESTIC","costType":"FLAT_RATE","shippingServices":[{"sortOrder":1,"shippingCarrierCode":"USPS","shippingServiceCode":"USPSPriorityFlatRateBox","shippingCost":{"value":0.0,"currency":"USD"},"additionalShippingCost":{"value":0.0,"currency":"USD"},"freeShipping":true,"buyerResponsibleForShipping":false,"buyerResponsibleForPickup":false}],"insuranceOffered":false,"insuranceFee":{"value":0.0,"currency":"USD"}},{"optionType":"INTERNATIONAL","costType":"CALCULATED","shippingServices":[{"sortOrder":1,"shippingCarrierCode":"USPS","shippingServiceCode":"USPSPriorityMailInternational","freeShipping":false,"shipToLocations":{"regionIncluded":[{"regionName":"Worldwide"}]},"buyerResponsibleForShipping":true,"buyerResponsibleForPickup":false}],"insuranceOffered":true,"insuranceFee":{"value":10.0,"currency":"USD"}}],"globalShipping":false,"pickupDropOff":false,"freightShipping":false,"fulfillmentPolicyId":"5733606000","warnings":[]} + diff --git a/spec/fixtures/sell/account/fulfillment_policy/update/success.yml b/spec/fixtures/sell/account/fulfillment_policy/update/success.yml new file mode 100644 index 0000000..2823734 --- /dev/null +++ b/spec/fixtures/sell/account/fulfillment_policy/update/success.yml @@ -0,0 +1,54 @@ +--- +name: "Worldwide shipping options: Free domestic, CALCULATED int'l" +marketplaceId: EBAY_US +categoryTypes: + - name: ALL_EXCLUDING_MOTORS_VEHICLES + default: false +handlingTime: + value: 1 + unit: DAY +shipToLocations: + regionIncluded: + - regionName: Worldwide + regionExcluded: [] +shippingOptions: + - optionType: DOMESTIC + costType: FLAT_RATE + shippingServices: + - sortOrder: 1 + shippingCarrierCode: USPS + shippingServiceCode: USPSPriorityFlatRateBox + shippingCost: + value: 0.0 + currency: USD + additionalShippingCost: + value: 0.0 + currency: USD + freeShipping: true + buyerResponsibleForShipping: false + buyerResponsibleForPickup: false + insuranceOffered: false + insuranceFee: + value: 0.0 + currency: USD + - optionType: INTERNATIONAL + costType: CALCULATED + shippingServices: + - sortOrder: 1 + shippingCarrierCode: USPS + shippingServiceCode: USPSPriorityMailInternational + freeShipping: false + shipToLocations: + regionIncluded: + - regionName: Worldwide + buyerResponsibleForShipping: true + buyerResponsibleForPickup: false + insuranceOffered: true + insuranceFee: + value: 10.0 + currency: USD +globalShipping: false +pickupDropOff: false +freightShipping: false +fulfillmentPolicyId: '5733606000' +warnings: [] diff --git a/spec/fixtures/sell/account/payment_policy/create/request.yml b/spec/fixtures/sell/account/payment_policy/create/request.yml new file mode 100644 index 0000000..9d06788 --- /dev/null +++ b/spec/fixtures/sell/account/payment_policy/create/request.yml @@ -0,0 +1,7 @@ +--- +immediatePay: false +categoryTypes: +- name: ALL_EXCLUDING_MOTORS_VEHICLES +marketplaceId: EBAY_US +paymentMethods: [] +name: Managed Payments \ No newline at end of file diff --git a/spec/fixtures/sell/account/payment_policy/create/success b/spec/fixtures/sell/account/payment_policy/create/success new file mode 100644 index 0000000..923b6cc --- /dev/null +++ b/spec/fixtures/sell/account/payment_policy/create/success @@ -0,0 +1,5 @@ +HTTP/1.1 201 Created +Content-Length: 216 +Content-Type: application/json + +{"name":"Managed Payments","marketplaceId":"EBAY_US","categoryTypes":[{"name":"ALL_EXCLUDING_MOTORS_VEHICLES","default":false}],"paymentMethods":[],"immediatePay":false,"paymentPolicyId":"185091636024","warnings":[]} diff --git a/spec/fixtures/sell/account/payment_policy/create/success.yml b/spec/fixtures/sell/account/payment_policy/create/success.yml new file mode 100644 index 0000000..6ba2faa --- /dev/null +++ b/spec/fixtures/sell/account/payment_policy/create/success.yml @@ -0,0 +1,10 @@ +--- +name: Managed Payments +marketplaceId: EBAY_US +categoryTypes: +- name: ALL_EXCLUDING_MOTORS_VEHICLES + default: false +paymentMethods: [] +immediatePay: false +paymentPolicyId: "185091636024" +warnings: [] \ No newline at end of file diff --git a/spec/fixtures/sell/account/payment_policy/get/success b/spec/fixtures/sell/account/payment_policy/get/success new file mode 100644 index 0000000..24c62bb --- /dev/null +++ b/spec/fixtures/sell/account/payment_policy/get/success @@ -0,0 +1,5 @@ +HTTP/1.1 200 OK +Content-Length: 232 +Content-Type: application/json + +{"name":"Managed Payments","description":"eBay Payments","marketplaceId":"EBAY_US","categoryTypes":[{"name":"ALL_EXCLUDING_MOTORS_VEHICLES","default":false}],"paymentMethods":[],"immediatePay":false,"paymentPolicyId":"184528067024"} \ No newline at end of file diff --git a/spec/fixtures/sell/account/payment_policy/get/success.yml b/spec/fixtures/sell/account/payment_policy/get/success.yml new file mode 100644 index 0000000..84097eb --- /dev/null +++ b/spec/fixtures/sell/account/payment_policy/get/success.yml @@ -0,0 +1,10 @@ +--- +name: Managed Payments +description: eBay Payments +marketplaceId: EBAY_US +categoryTypes: +- name: ALL_EXCLUDING_MOTORS_VEHICLES + default: false +paymentMethods: [] +immediatePay: false +paymentPolicyId: "184528067024" \ No newline at end of file diff --git a/spec/fixtures/sell/account/payment_policy/get_by_name/success b/spec/fixtures/sell/account/payment_policy/get_by_name/success new file mode 100644 index 0000000..a0bcfcd --- /dev/null +++ b/spec/fixtures/sell/account/payment_policy/get_by_name/success @@ -0,0 +1,5 @@ +HTTP/1.1 200 OK +Content-Length: 202 +Content-Type: application/json + +{"name":"Managed Payments","marketplaceId":"EBAY_US","categoryTypes":[{"name":"ALL_EXCLUDING_MOTORS_VEHICLES","default":false}],"paymentMethods":[],"immediatePay":false,"paymentPolicyId":"185091636024"} diff --git a/spec/fixtures/sell/account/payment_policy/get_by_name/success.yml b/spec/fixtures/sell/account/payment_policy/get_by_name/success.yml new file mode 100644 index 0000000..b63dddb --- /dev/null +++ b/spec/fixtures/sell/account/payment_policy/get_by_name/success.yml @@ -0,0 +1,9 @@ +--- +name: Managed Payments +marketplaceId: EBAY_US +categoryTypes: +- name: ALL_EXCLUDING_MOTORS_VEHICLES + default: false +paymentMethods: [] +immediatePay: false +paymentPolicyId: "185091636024" \ No newline at end of file diff --git a/spec/fixtures/sell/account/payment_policy/index/success b/spec/fixtures/sell/account/payment_policy/index/success new file mode 100644 index 0000000..b346251 --- /dev/null +++ b/spec/fixtures/sell/account/payment_policy/index/success @@ -0,0 +1,5 @@ +HTTP/1.1 200 OK +Content-Length: 2010 +Content-Type: application/json + +{"total":3,"paymentPolicies":[{"name":"PayPal#1","description":"PayPal, userpaypal1@gmail.com","marketplaceId":"EBAY_US","categoryTypes":[{"name":"ALL_EXCLUDING_MOTORS_VEHICLES","default":true}],"paymentMethods":[{"paymentMethodType":"PAYPAL","recipientAccountReference":{"referenceType":"PAYPAL_EMAIL","referenceId":"userpaypal1@gmail.com"}}],"immediatePay":false,"paymentPolicyId":"103323093024"},{"name":"PayPal#2","description":"PayPal, userpaypal2@gmail.com","marketplaceId":"EBAY_US","categoryTypes":[{"name":"ALL_EXCLUDING_MOTORS_VEHICLES","default":false}],"paymentMethods":[{"paymentMethodType":"PAYPAL","recipientAccountReference":{"referenceType":"PAYPAL_EMAIL","referenceId":"userpaypal2@gmail.com"}}],"immediatePay":false,"paymentPolicyId":"117938331024"},{"name":"Managed Payments","marketplaceId":"EBAY_US","categoryTypes":[{"name":"ALL_EXCLUDING_MOTORS_VEHICLES","default":false}],"paymentMethods":[],"immediatePay":false,"paymentPolicyId":"185091636024"}]} diff --git a/spec/fixtures/sell/account/payment_policy/index/success.yml b/spec/fixtures/sell/account/payment_policy/index/success.yml new file mode 100644 index 0000000..d5160d4 --- /dev/null +++ b/spec/fixtures/sell/account/payment_policy/index/success.yml @@ -0,0 +1,36 @@ +total: 3 +paymentPolicies: +- name: PayPal#1 + description: PayPal, userpaypal1@gmail.com + marketplaceId: EBAY_US + categoryTypes: + - name: ALL_EXCLUDING_MOTORS_VEHICLES + default: true + paymentMethods: + - paymentMethodType: PAYPAL + recipientAccountReference: + referenceType: PAYPAL_EMAIL + referenceId: userpaypal1@gmail.com + immediatePay: false + paymentPolicyId: "103323093024" +- name: PayPal#2 + description: PayPal, userpaypal2@gmail.com + marketplaceId: EBAY_US + categoryTypes: + - name: ALL_EXCLUDING_MOTORS_VEHICLES + default: false + paymentMethods: + - paymentMethodType: PAYPAL + recipientAccountReference: + referenceType: PAYPAL_EMAIL + referenceId: userpaypal2@gmail.com + immediatePay: false + paymentPolicyId: "117938331024" +- name: Managed Payments + marketplaceId: EBAY_US + categoryTypes: + - name: ALL_EXCLUDING_MOTORS_VEHICLES + default: false + paymentMethods: [] + immediatePay: false + paymentPolicyId: "185091636024" \ No newline at end of file diff --git a/spec/fixtures/sell/account/payment_policy/update/request.yml b/spec/fixtures/sell/account/payment_policy/update/request.yml new file mode 100644 index 0000000..9d06788 --- /dev/null +++ b/spec/fixtures/sell/account/payment_policy/update/request.yml @@ -0,0 +1,7 @@ +--- +immediatePay: false +categoryTypes: +- name: ALL_EXCLUDING_MOTORS_VEHICLES +marketplaceId: EBAY_US +paymentMethods: [] +name: Managed Payments \ No newline at end of file diff --git a/spec/fixtures/sell/account/payment_policy/update/success b/spec/fixtures/sell/account/payment_policy/update/success new file mode 100644 index 0000000..db79fa0 --- /dev/null +++ b/spec/fixtures/sell/account/payment_policy/update/success @@ -0,0 +1,5 @@ +HTTP/1.1 200 OK +Content-Length: 216 +Content-Type: application/json + +{"name":"Managed Payments","marketplaceId":"EBAY_US","categoryTypes":[{"name":"ALL_EXCLUDING_MOTORS_VEHICLES","default":false}],"paymentMethods":[],"immediatePay":false,"paymentPolicyId":"184528067024","warnings":[]} \ No newline at end of file diff --git a/spec/fixtures/sell/account/payment_policy/update/success.yml b/spec/fixtures/sell/account/payment_policy/update/success.yml new file mode 100644 index 0000000..e07a7fe --- /dev/null +++ b/spec/fixtures/sell/account/payment_policy/update/success.yml @@ -0,0 +1,10 @@ +--- +name: Managed Payments +marketplaceId: EBAY_US +categoryTypes: +- name: ALL_EXCLUDING_MOTORS_VEHICLES + default: false +paymentMethods: [] +immediatePay: false +paymentPolicyId: "184528067024" +warnings: [] \ No newline at end of file diff --git a/spec/fixtures/sell/account/payments_program/get/bad_request b/spec/fixtures/sell/account/payments_program/get/bad_request new file mode 100644 index 0000000..79b9c09 --- /dev/null +++ b/spec/fixtures/sell/account/payments_program/get/bad_request @@ -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."}]} + diff --git a/spec/fixtures/sell/account/payments_program/get/server_error b/spec/fixtures/sell/account/payments_program/get/server_error new file mode 100644 index 0000000..9420ebf --- /dev/null +++ b/spec/fixtures/sell/account/payments_program/get/server_error @@ -0,0 +1,5 @@ +HTTP/1.1 500 Server Error +Content-Length: 0 +Content-Type: application/json + + diff --git a/spec/fixtures/sell/account/payments_program/get/success b/spec/fixtures/sell/account/payments_program/get/success new file mode 100644 index 0000000..9580b47 --- /dev/null +++ b/spec/fixtures/sell/account/payments_program/get/success @@ -0,0 +1,6 @@ +HTTP/1.1 200 OK +Content-Length: 113 +Content-Type: application/json + +{"marketplaceId":"EBAY_US","paymentProgramType":"EBAY_PAYMENTS","status":"OPTED_IN","wasPreviouslyOptedIn":false} + diff --git a/spec/fixtures/sell/account/privilege/get/bad_request b/spec/fixtures/sell/account/privilege/get/bad_request new file mode 100644 index 0000000..79b9c09 --- /dev/null +++ b/spec/fixtures/sell/account/privilege/get/bad_request @@ -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."}]} + diff --git a/spec/fixtures/sell/account/privilege/get/server_error b/spec/fixtures/sell/account/privilege/get/server_error new file mode 100644 index 0000000..9420ebf --- /dev/null +++ b/spec/fixtures/sell/account/privilege/get/server_error @@ -0,0 +1,5 @@ +HTTP/1.1 500 Server Error +Content-Length: 0 +Content-Type: application/json + + diff --git a/spec/fixtures/sell/account/return_policy/create/request.yml b/spec/fixtures/sell/account/return_policy/create/request.yml new file mode 100644 index 0000000..04d467a --- /dev/null +++ b/spec/fixtures/sell/account/return_policy/create/request.yml @@ -0,0 +1,17 @@ +--- +name: 30-day domestic and international return policy +marketplaceId: EBAY_US +description: Policy specifies an international return policy in addition to the domestic + return policy. +refundMethod: MONEY_BACK +returnsAccepted: true +returnPeriod: + value: 30 + unit: DAY +returnShippingCostPayer: SELLER +internationalOverride: + returnsAccepted: true + returnPeriod: + unit: DAY + value: 30 + returnShippingCostPayer: BUYER diff --git a/spec/fixtures/sell/account/return_policy/create/success b/spec/fixtures/sell/account/return_policy/create/success new file mode 100644 index 0000000..bae2be3 --- /dev/null +++ b/spec/fixtures/sell/account/return_policy/create/success @@ -0,0 +1,6 @@ +HTTP/1.1 201 Created +Content-Length: 561 +Content-Type: application/json + +{"name":"30-day domestic and international return policy","description":"Policy specifies an international return policy in addition to the domestic return policy.","marketplaceId":"EBAY_US","categoryTypes":[{"name":"ALL_EXCLUDING_MOTORS_VEHICLES","default":false}],"returnsAccepted":true,"returnPeriod":{"value":30,"unit":"DAY"},"refundMethod":"MONEY_BACK","returnShippingCostPayer":"SELLER","internationalOverride":{"returnsAccepted":true,"returnPeriod":{"value":30,"unit":"DAY"},"returnShippingCostPayer":"BUYER"},"returnPolicyId":"5790479000","warnings":[]} + diff --git a/spec/fixtures/sell/account/return_policy/create/success.yml b/spec/fixtures/sell/account/return_policy/create/success.yml new file mode 100644 index 0000000..334ee12 --- /dev/null +++ b/spec/fixtures/sell/account/return_policy/create/success.yml @@ -0,0 +1,22 @@ +--- +name: 30-day domestic and international return policy +description: Policy specifies an international return policy in addition to the domestic + return policy. +marketplaceId: EBAY_US +categoryTypes: +- name: ALL_EXCLUDING_MOTORS_VEHICLES + default: false +returnsAccepted: true +returnPeriod: + value: 30 + unit: DAY +refundMethod: MONEY_BACK +returnShippingCostPayer: SELLER +internationalOverride: + returnsAccepted: true + returnPeriod: + value: 30 + unit: DAY + returnShippingCostPayer: BUYER +returnPolicyId: '5790479000' +warnings: [] diff --git a/spec/fixtures/sell/account/return_policy/get/success b/spec/fixtures/sell/account/return_policy/get/success new file mode 100644 index 0000000..9ad6db5 --- /dev/null +++ b/spec/fixtures/sell/account/return_policy/get/success @@ -0,0 +1,6 @@ +HTTP/1.1 200 OK +Content-Length: 572 +Content-Type: application/json + +{"name":"30-day domestic and international return policy","description":"Policy specifies an international return policy in addition to the domestic return policy.","marketplaceId":"EBAY_US","categoryTypes":[{"name":"ALL_EXCLUDING_MOTORS_VEHICLES","default":true}],"returnsAccepted":true,"returnPeriod":{"value":30,"unit":"DAY"},"refundMethod":"MONEY_BACK","returnMethod":"EXCHANGE","returnShippingCostPayer":"SELLER","internationalOverride":{"returnsAccepted":true,"returnPeriod":{"value":60,"unit":"DAY"},"returnShippingCostPayer":"BUYER"},"returnPolicyId":"5790479000"} + diff --git a/spec/fixtures/sell/account/return_policy/get/success.yml b/spec/fixtures/sell/account/return_policy/get/success.yml new file mode 100644 index 0000000..0af1d8a --- /dev/null +++ b/spec/fixtures/sell/account/return_policy/get/success.yml @@ -0,0 +1,22 @@ +--- +name: 30-day domestic and international return policy +description: Policy specifies an international return policy in addition to the domestic + return policy. +marketplaceId: EBAY_US +categoryTypes: +- name: ALL_EXCLUDING_MOTORS_VEHICLES + default: true +returnsAccepted: true +returnPeriod: + value: 30 + unit: DAY +refundMethod: MONEY_BACK +returnMethod: EXCHANGE +returnShippingCostPayer: SELLER +internationalOverride: + returnsAccepted: true + returnPeriod: + value: 60 + unit: DAY + returnShippingCostPayer: BUYER +returnPolicyId: '5790479000' diff --git a/spec/fixtures/sell/account/return_policy/get_by_name/success b/spec/fixtures/sell/account/return_policy/get_by_name/success new file mode 100644 index 0000000..cb63ab2 --- /dev/null +++ b/spec/fixtures/sell/account/return_policy/get_by_name/success @@ -0,0 +1,6 @@ +HTTP/1.1 200 OK +Content-Length: 306 +Content-Type: application/json + +{"name":"minimal return policy, US marketplace","marketplaceId":"EBAY_US","categoryTypes":[{"name":"ALL_EXCLUDING_MOTORS_VEHICLES","default":false}],"returnsAccepted":true,"returnPeriod":{"value":30,"unit":"DAY"},"refundMethod":"MONEY_BACK","returnShippingCostPayer":"SELLER","returnPolicyId":"5792219000"} + diff --git a/spec/fixtures/sell/account/return_policy/get_by_name/success.yml b/spec/fixtures/sell/account/return_policy/get_by_name/success.yml new file mode 100644 index 0000000..e1a68b2 --- /dev/null +++ b/spec/fixtures/sell/account/return_policy/get_by_name/success.yml @@ -0,0 +1,13 @@ +--- +name: minimal return policy, US marketplace +marketplaceId: EBAY_US +categoryTypes: +- name: ALL_EXCLUDING_MOTORS_VEHICLES + default: false +returnsAccepted: true +returnPeriod: + value: 30 + unit: DAY +refundMethod: MONEY_BACK +returnShippingCostPayer: SELLER +returnPolicyId: '5792219000' diff --git a/spec/fixtures/sell/account/return_policy/index/success b/spec/fixtures/sell/account/return_policy/index/success new file mode 100644 index 0000000..dd96231 --- /dev/null +++ b/spec/fixtures/sell/account/return_policy/index/success @@ -0,0 +1,6 @@ +HTTP/1.1 200 OK +Content-Length: 1101 +Content-Type: application/json + +{"total":3,"returnPolicies":[{"name":"30-day domestic and international return policy","description":"Policy specifies an international return policy in addition to the domestic return policy.","marketplaceId":"EBAY_US","categoryTypes":[{"name":"ALL_EXCLUDING_MOTORS_VEHICLES","default":true}],"returnsAccepted":true,"returnPeriod":{"value":30,"unit":"DAY"},"refundMethod":"MONEY_BACK","returnMethod":"EXCHANGE","returnShippingCostPayer":"SELLER","internationalOverride":{"returnsAccepted":true,"returnPeriod":{"value":60,"unit":"DAY"},"returnShippingCostPayer":"BUYER"},"returnPolicyId":"5790479000"},{"name":"no returns return policy","marketplaceId":"EBAY_US","categoryTypes":[{"name":"ALL_EXCLUDING_MOTORS_VEHICLES","default":false}],"returnsAccepted":false,"returnPolicyId":"5790474000"},{"name":"minimal return policy, US marketplace","marketplaceId":"EBAY_US","categoryTypes":[{"name":"ALL_EXCLUDING_MOTORS_VEHICLES","default":false}],"returnsAccepted":true,"returnPeriod":{"value":30,"unit":"DAY"},"refundMethod":"MONEY_BACK","returnShippingCostPayer":"SELLER","returnPolicyId":"5792219000"}]} + diff --git a/spec/fixtures/sell/account/return_policy/index/success.yml b/spec/fixtures/sell/account/return_policy/index/success.yml new file mode 100644 index 0000000..315a576 --- /dev/null +++ b/spec/fixtures/sell/account/return_policy/index/success.yml @@ -0,0 +1,42 @@ +--- +total: 3 +returnPolicies: +- name: 30-day domestic and international return policy + description: Policy specifies an international return policy in addition to the domestic return policy. + marketplaceId: EBAY_US + categoryTypes: + - name: ALL_EXCLUDING_MOTORS_VEHICLES + default: true + returnsAccepted: true + returnPeriod: + value: 30 + unit: DAY + refundMethod: MONEY_BACK + returnMethod: EXCHANGE + returnShippingCostPayer: SELLER + internationalOverride: + returnsAccepted: true + returnPeriod: + value: 60 + unit: DAY + returnShippingCostPayer: BUYER + returnPolicyId: '5790479000' +- name: no returns return policy + marketplaceId: EBAY_US + categoryTypes: + - name: ALL_EXCLUDING_MOTORS_VEHICLES + default: false + returnsAccepted: false + returnPolicyId: '5790474000' +- name: minimal return policy, US marketplace + marketplaceId: EBAY_US + categoryTypes: + - name: ALL_EXCLUDING_MOTORS_VEHICLES + default: false + returnsAccepted: true + returnPeriod: + value: 30 + unit: DAY + refundMethod: MONEY_BACK + returnShippingCostPayer: SELLER + returnPolicyId: '5792219000' diff --git a/spec/fixtures/sell/account/return_policy/update/request.yml b/spec/fixtures/sell/account/return_policy/update/request.yml new file mode 100644 index 0000000..629adc2 --- /dev/null +++ b/spec/fixtures/sell/account/return_policy/update/request.yml @@ -0,0 +1,20 @@ +--- +name: 30-day domestic and international return policy +marketplaceId: EBAY_US +categoryTypes: +- name: ALL_EXCLUDING_MOTORS_VEHICLES + default: 'true' +description: Policy specifies an international return policy in addition to the domestic return policy. +refundMethod: MONEY_BACK +returnsAccepted: true +returnMethod: EXCHANGE +returnPeriod: + value: 30 + unit: DAY +returnShippingCostPayer: SELLER +internationalOverride: + returnsAccepted: true + returnPeriod: + unit: DAY + value: 60 + returnShippingCostPayer: BUYER diff --git a/spec/fixtures/sell/account/return_policy/update/success b/spec/fixtures/sell/account/return_policy/update/success new file mode 100644 index 0000000..7482352 --- /dev/null +++ b/spec/fixtures/sell/account/return_policy/update/success @@ -0,0 +1,6 @@ +HTTP/1.1 200 OK +Content-Length: 586 +Content-Type: application/json + +{"name":"30-day domestic and international return policy","description":"Policy specifies an international return policy in addition to the domestic return policy.","marketplaceId":"EBAY_US","categoryTypes":[{"name":"ALL_EXCLUDING_MOTORS_VEHICLES","default":true}],"returnsAccepted":true,"returnPeriod":{"value":30,"unit":"DAY"},"refundMethod":"MONEY_BACK","returnMethod":"EXCHANGE","returnShippingCostPayer":"SELLER","internationalOverride":{"returnsAccepted":true,"returnPeriod":{"value":60,"unit":"DAY"},"returnShippingCostPayer":"BUYER"},"returnPolicyId":"5790479000","warnings":[]} + diff --git a/spec/fixtures/sell/account/return_policy/update/success.yml b/spec/fixtures/sell/account/return_policy/update/success.yml new file mode 100644 index 0000000..dde66df --- /dev/null +++ b/spec/fixtures/sell/account/return_policy/update/success.yml @@ -0,0 +1,22 @@ +--- +name: 30-day domestic and international return policy +description: Policy specifies an international return policy in addition to the domestic return policy. +marketplaceId: EBAY_US +categoryTypes: +- name: ALL_EXCLUDING_MOTORS_VEHICLES + default: true +returnsAccepted: true +returnPeriod: + value: 30 + unit: DAY +refundMethod: MONEY_BACK +returnMethod: EXCHANGE +returnShippingCostPayer: SELLER +internationalOverride: + returnsAccepted: true + returnPeriod: + value: 60 + unit: DAY + returnShippingCostPayer: BUYER +returnPolicyId: '5790479000' +warnings: [] diff --git a/spec/fixtures/sell/marketing/ads/bulk_create_by_listing_id/invalid b/spec/fixtures/sell/marketing/ads/bulk_create_by_listing_id/invalid index 79e1d88..acb657e 100644 --- a/spec/fixtures/sell/marketing/ads/bulk_create_by_listing_id/invalid +++ b/spec/fixtures/sell/marketing/ads/bulk_create_by_listing_id/invalid @@ -1,6 +1,6 @@ HTTP/1.1 400 Bad Request -Content-Length: 487 +Content-Length: 489 Content-Type: application/json -{"errors":[{"errorId":35007,"domain":"API_MARKETING","category":"REQUEST","message":"The 'bidPercentage' null is not valid. The bid percentage should be a single precision value. Minimum value: 1.0 , Maximum value:20.0. Example of valid values: 4.1, 4.10, 5.5, 5.0, etc. Invalid values: 4.44, 8.11, etc.","inputRefIds":["$.requests[0].bidPercentage"],"parameters":[{"name":"bidPercentage","value":"null"},{"name":"minBidPercent","value":"1.0"},{"name":"maxBidPercent","value":"20.0"}]}]} +{"errors":[{"errorId":35007,"domain":"API_MARKETING","category":"REQUEST","message":"The 'bidPercentage' null is not valid. The bid percentage should be a single precision value. Minimum value: 1.0 , Maximum value:100.0. Example of valid values: 4.1, 4.10, 5.5, 5.0, etc. Invalid values: 4.44, 8.11, etc.","inputRefIds":["$.requests[0].bidPercentage"],"parameters":[{"name":"bidPercentage","value":"null"},{"name":"minBidPercent","value":"1.0"},{"name":"maxBidPercent","value":"100.0"}]}]} diff --git a/spec/fixtures/sell/metadata/marketplace/get_item_condition_policies/success b/spec/fixtures/sell/metadata/marketplace/get_item_condition_policies/success new file mode 100644 index 0000000..d2e8a4b --- /dev/null +++ b/spec/fixtures/sell/metadata/marketplace/get_item_condition_policies/success @@ -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" + } + ] + } + ] +} + diff --git a/spec/models/pricing_summary_spec.rb b/spec/models/pricing_summary_spec.rb index 2fbdb82..8e0f9eb 100644 --- a/spec/models/pricing_summary_spec.rb +++ b/spec/models/pricing_summary_spec.rb @@ -3,12 +3,12 @@ let(:source) do { - "currency" => "USD", - "price" => 49.99, - "pricingVisibility" => "PRE_CHECKOUT", - "minimumAdvertisedPrice" => 50.0, - "originallySoldForRetailPriceOn" => "ON_EBAY", - "originalRetailPrice" => 50.01 + currency: "USD", + price: 49.99, + pricingVisibility: "PRE_CHECKOUT", + minimumAdvertisedPrice: 50.0, + originallySoldForRetailPriceOn: "ON_EBAY", + originalRetailPrice: 50.01 } end @@ -30,9 +30,9 @@ context "with hash prices" do before do - source.update "price" => { "value" => "49.99", currency: "USD" }, - "originalRetailPrice" => { value: 50.01, currency: "USD" }, - "minimumAdvertisedPrice" => { value: "50", currency: "USD" } + source.update price: { value: "49.99", currency: "USD" }, + originalRetailPrice: { value: 50.01, currency: "USD" }, + minimumAdvertisedPrice: { value: "50", currency: "USD" } end it { is_expected.to eq target } @@ -40,8 +40,8 @@ context "without price" do before do - source.delete "price" target.delete :price + source.delete :price end it { is_expected.to eq target } @@ -49,8 +49,8 @@ context "without map params" do before do - source.delete "minimumAdvertisedPrice" - source.delete "pricingVisibility" + source.delete :minimumAdvertisedPrice + source.delete :pricingVisibility target.delete :minimumAdvertisedPrice target.delete :pricingVisibility end @@ -59,7 +59,7 @@ end context "with map price only" do - before { source.delete "pricingVisibility" } + before { source.delete :pricingVisibility } it "raises StandardError" do expect { subject }.to raise_error StandardError, /MAP/ @@ -67,7 +67,7 @@ end context "with map visibility only" do - before { source.delete "minimumAdvertisedPrice" } + before { source.delete :minimumAdvertisedPrice } it "raises StandardError" do expect { subject }.to raise_error StandardError, /MAP/ @@ -75,7 +75,7 @@ end context "with wrong visibility" do - before { source["pricingVisibility"] = "FOO" } + before { source[:pricingVisibility] = "FOO" } it "raises StandardError" do expect { subject }.to raise_error StandardError, /FOO/ @@ -84,8 +84,8 @@ context "without stp params" do before do - source.delete "originalRetailPrice" - source.delete "originallySoldForRetailPriceOn" + source.delete :originalRetailPrice + source.delete :originallySoldForRetailPriceOn target.delete :originallySoldForRetailPriceOn target.delete :originalRetailPrice end @@ -94,7 +94,7 @@ end context "with stp price only" do - before { source.delete "originallySoldForRetailPriceOn" } + before { source.delete :originallySoldForRetailPriceOn } it "raises StandardError" do expect { subject }.to raise_error StandardError, /STP/ @@ -102,7 +102,7 @@ end context "with stp type only" do - before { source.delete "originalRetailPrice" } + before { source.delete :originalRetailPrice } it "raises StandardError" do expect { subject }.to raise_error StandardError, /STP/ @@ -110,7 +110,7 @@ end context "with wrong stp_type" do - before { source["originallySoldForRetailPriceOn"] = "FOO" } + before { source[:originallySoldForRetailPriceOn] = "FOO" } it "raises StandardError" do expect { subject }.to raise_error StandardError, /FOO/ @@ -118,7 +118,7 @@ end context "without currency" do - before { source.delete "currency" } + before { source.delete :currency } it "raises StandardError" do expect { subject } @@ -127,7 +127,7 @@ end context "with wrong currency" do - before { source["currency"] = "FOO" } + before { source[:currency] = "FOO" } it "raises StandardError" do expect { subject }.to raise_error StandardError, /FOO/ diff --git a/spec/models/program_type_spec.rb b/spec/models/program_type_spec.rb new file mode 100644 index 0000000..ea7aadc --- /dev/null +++ b/spec/models/program_type_spec.rb @@ -0,0 +1,21 @@ +RSpec.describe EbayAPI::ProgramType do + describe "#call, #[]" do + subject(:program_type) { described_class[key] } + + context "by known key" do + let(:key) { :out_of_stock_control } + + it "finds the type" do + expect(subject).to eq "OUT_OF_STOCK_CONTROL" + end + end + + context "by unknown key" do + let(:key) { "AAA" } + + it "raises ArgumentError" do + expect { subject }.to raise_error(StandardError, /AAA/) + end + end + end +end diff --git a/spec/models/site_spec.rb b/spec/models/site_spec.rb index 547a3fa..f9dcbfb 100644 --- a/spec/models/site_spec.rb +++ b/spec/models/site_spec.rb @@ -25,7 +25,7 @@ let(:id) { "EBAY_CA" } it "return a proper site" do - expect(subject.options).to eq options.merge(id: 2, languages: %w[en-CA]) + expect(subject.options).to eq options.merge(languages: %w[en-CA fr-CA]) end end @@ -73,4 +73,47 @@ expect(subject).to eq "Canadian" end end + + describe ".new" do + context "when initialized with a hash argument" do + let(:hash_attrs) do + { + id: 0, + code: "EBAY-US", + country: "US", + host: "www.ebay.com", + key: "EBAY_US", + currencies: ["USD"], + languages: ["en-US"] + } + end + + it "properly initializes attributes from hash" do + site = described_class.new(hash_attrs) + expect(site.id).to eq(0) + expect(site.code).to eq("EBAY-US") + expect(site.country).to eq("US") + expect(site.host).to eq("www.ebay.com") + expect(site.key).to eq("EBAY_US") + expect(site.currencies.first.code).to eq("USD") + expect(site.languages.first).to eq("en-US") + end + end + + context "when initialized with keyword arguments" do + it "properly initializes attributes from keywords" do + site = described_class.new( + id: 0, + code: "EBAY-US", + country: "US", + host: "www.ebay.com", + key: "EBAY_US" + ) + expect(site.id).to eq(0) + expect(site.code).to eq("EBAY-US") + expect(site.country).to eq("US") + expect(site.host).to eq("www.ebay.com") + end + end + end end diff --git a/spec/operations/commerce/catalog/product_summary/search_spec.rb b/spec/operations/commerce/catalog/product_summary/search_spec.rb new file mode 100644 index 0000000..fe40d2d --- /dev/null +++ b/spec/operations/commerce/catalog/product_summary/search_spec.rb @@ -0,0 +1,57 @@ +RSpec.describe EbayAPI, ".commerce.catalog.product_summary.search" do + let(:url) do + Addressable::Template.new <<~URL.strip + https://api.ebay.com/commerce/catalog/v1_beta/product_summary/search{?params*} + URL + end + let(:client) { described_class.new(**settings) } + let(:scope) { client.commerce.catalog.product_summary } + let(:settings) { yaml_fixture_file(settings_file) } + let(:version) { "1_beta.1.0" } + let(:settings_file) { "settings.valid.yml" } + let(:params) { {} } + before do + stub_request(:get, url).to_return {|request| response} + end + + subject { scope.search(**params) } + + context "success" do + context "without params" do + let(:response) { open_fixture_file("commerce/catalog/product_summary/search/without-params") } + + it do + expect { subject }.to raise_error(EbayAPI::Error) do |ex| + expect(ex.code).to eq 75_001 + expect(ex.message).to match \ + /The call must have a valid 'q'/ + end + end + end + + context "with keywords" do + let(:response) { open_fixture_file("commerce/catalog/product_summary/search/matched-with-keywords") } + let(:params) { { keywords: "ipad" } } + + it "returns list of catalog products" do + expect(subject["productSummaries"].count).to eq(2) + end + + describe "#a catalog product" do + let(:catalog_product) { subject["productSummaries"].first } + + it "has proper attributes" do + expect(catalog_product["epid"]).to eq("241996593") + expect(catalog_product["brand"]).to eq("Apple") + end + end + end + end + + context "when not found any catalog products" do + let(:response) { open_fixture_file("commerce/catalog/product_summary/search/no-matching") } + let(:params) { { keywords: "blabla" } } + + it { is_expected.to be_empty } + end +end diff --git a/spec/operations/commerce/notification/public_key/get_spec.rb b/spec/operations/commerce/notification/public_key/get_spec.rb new file mode 100644 index 0000000..7413110 --- /dev/null +++ b/spec/operations/commerce/notification/public_key/get_spec.rb @@ -0,0 +1,30 @@ +RSpec.describe EbayAPI, ".commerce.notification.public_key.get" do + let(:client) { described_class.new(**settings) } + let(:scope) { client.commerce.notifications.public_key } + let(:settings) { yaml_fixture_file("settings.valid.yml") } + let(:url) do + "https://api.ebay.com/commerce/notification/v1/public_key/042" + end + + before { stub_request(:get, url).to_return(response) } + subject { scope.get key_id: "042" } + + context "success" do + let(:response) do + open_fixture_file "commerce/notification/public_key/get/success" + end + + let(:public_key) do + yaml_fixture_file "commerce/notification/public_key/get/success.yml" + end + + it "sends a request" do + subject + expect(a_request(:get, url)).to have_been_made + end + + it "returns the policy" do + expect(subject).to eq public_key + end + end +end diff --git a/spec/operations/commerce/taxonomy/category_tree/fetch_item_aspects_spec.rb b/spec/operations/commerce/taxonomy/category_tree/fetch_item_aspects_spec.rb new file mode 100644 index 0000000..e173eda --- /dev/null +++ b/spec/operations/commerce/taxonomy/category_tree/fetch_item_aspects_spec.rb @@ -0,0 +1,32 @@ +RSpec.describe EbayAPI, ".commerce.taxonomy.category_tree.fetch_item_aspects" do + let(:client) { described_class.new(**settings) } + let(:scope) { client.commerce.taxonomy.category_tree(category_tree_id: 41) } + let(:settings) { yaml_fixture_file("settings.valid.yml") } + let(:url) do + "https://api.ebay.com/commerce/taxonomy/v1/category_tree/41/fetch_item_aspects" + end + + before { stub_request(:get, url).to_return(response) } + subject do + scope.fetch_item_aspects + end + + context "success" do + let(:response) do + body = StringIO.new + gzipper = Zlib::GzipWriter.new(body) + gzipper.write(read_fixture_file("commerce/taxonomy/category_tree/fetch_item_aspects/success.json")) + gzipper.close + + { + status: 200, + body: body.string, + } + end + + it "sends a request" do + subject + expect(a_request(:get, url)).to have_been_made + end + end +end diff --git a/spec/operations/commerce/taxonomy/category_tree/get_category_subtree_spec.rb b/spec/operations/commerce/taxonomy/category_tree/get_category_subtree_spec.rb new file mode 100644 index 0000000..56b728c --- /dev/null +++ b/spec/operations/commerce/taxonomy/category_tree/get_category_subtree_spec.rb @@ -0,0 +1,24 @@ +RSpec.describe EbayAPI, ".commerce.taxonomy.category_tree.get_category_subtree" do + let(:client) { described_class.new(**settings) } + let(:scope) { client.commerce.taxonomy.category_tree(category_tree_id: 41) } + let(:settings) { yaml_fixture_file("settings.valid.yml") } + let(:url) do + "https://api.ebay.com/commerce/taxonomy/v1/category_tree/41/get_category_subtree?category_id=42" + end + + before { stub_request(:get, url).to_return(response) } + subject do + scope.get_category_subtree category_id: 42 + end + + context "success" do + let(:response) do + open_fixture_file "commerce/taxonomy/category_tree/get_category_subtree/success" + end + + it "sends a request" do + subject + expect(a_request(:get, url)).to have_been_made + end + end +end diff --git a/spec/operations/commerce/taxonomy/category_tree/get_category_suggestions_spec.rb b/spec/operations/commerce/taxonomy/category_tree/get_category_suggestions_spec.rb new file mode 100644 index 0000000..b018fbd --- /dev/null +++ b/spec/operations/commerce/taxonomy/category_tree/get_category_suggestions_spec.rb @@ -0,0 +1,24 @@ +RSpec.describe EbayAPI, ".commerce.taxonomy.category_tree.get_category_suggestions" do + let(:client) { described_class.new(**settings) } + let(:scope) { client.commerce.taxonomy.category_tree(category_tree_id: 41) } + let(:settings) { yaml_fixture_file("settings.valid.yml") } + let(:url) do + "https://api.ebay.com/commerce/taxonomy/v1/category_tree/41/get_category_suggestions?q=android" + end + + before { stub_request(:get, url).to_return(response) } + subject do + scope.get_category_suggestions query: "android" + end + + context "success" do + let(:response) do + open_fixture_file "commerce/taxonomy/category_tree/get_category_suggestions/success" + end + + it "sends a request" do + subject + expect(a_request(:get, url)).to have_been_made + end + end +end diff --git a/spec/operations/commerce/taxonomy/category_tree/get_item_aspects_for_category_spec.rb b/spec/operations/commerce/taxonomy/category_tree/get_item_aspects_for_category_spec.rb new file mode 100644 index 0000000..6a656e4 --- /dev/null +++ b/spec/operations/commerce/taxonomy/category_tree/get_item_aspects_for_category_spec.rb @@ -0,0 +1,24 @@ +RSpec.describe EbayAPI, ".commerce.taxonomy.category_tree.get_item_aspects_for_category" do + let(:client) { described_class.new(**settings) } + let(:scope) { client.commerce.taxonomy.category_tree(category_tree_id: 41) } + let(:settings) { yaml_fixture_file("settings.valid.yml") } + let(:url) do + "https://api.ebay.com/commerce/taxonomy/v1/category_tree/41/get_item_aspects_for_category?category_id=42" + end + + before { stub_request(:get, url).to_return(response) } + subject do + scope.get_item_aspects_for_category category_id: 42 + end + + context "success" do + let(:response) do + open_fixture_file "commerce/taxonomy/category_tree/get_item_aspects_for_category/success" + end + + it "sends a request" do + subject + expect(a_request(:get, url)).to have_been_made + end + end +end diff --git a/spec/operations/commerce/taxonomy/category_tree/get_spec.rb b/spec/operations/commerce/taxonomy/category_tree/get_spec.rb new file mode 100644 index 0000000..f813b41 --- /dev/null +++ b/spec/operations/commerce/taxonomy/category_tree/get_spec.rb @@ -0,0 +1,24 @@ +RSpec.describe EbayAPI, ".commerce.taxonomy.category_tree.get" do + let(:client) { described_class.new(**settings) } + let(:scope) { client.commerce.taxonomy.category_tree(category_tree_id: 41) } + let(:settings) { yaml_fixture_file("settings.valid.yml") } + let(:url) do + "https://api.ebay.com/commerce/taxonomy/v1/category_tree/41/" + end + + before { stub_request(:get, url).to_return(response) } + subject do + scope.get + end + + context "success" do + let(:response) do + open_fixture_file "commerce/taxonomy/category_tree/get/success" + end + + it "sends a request" do + subject + expect(a_request(:get, url)).to have_been_made + end + end +end diff --git a/spec/operations/commerce/taxonomy/get_default_category_tree_id_spec.rb b/spec/operations/commerce/taxonomy/get_default_category_tree_id_spec.rb new file mode 100644 index 0000000..18ccaab --- /dev/null +++ b/spec/operations/commerce/taxonomy/get_default_category_tree_id_spec.rb @@ -0,0 +1,24 @@ +RSpec.describe EbayAPI, ".commerce.taxonomy.get_default_category_tree_id" do + let(:client) { described_class.new(**settings) } + let(:scope) { client.commerce.taxonomy } + let(:settings) { yaml_fixture_file("settings.valid.yml") } + let(:url) do + "https://api.ebay.com/commerce/taxonomy/v1/get_default_category_tree_id?marketplace_id=EBAY_US" + end + + before { stub_request(:get, url).to_return(response) } + subject do + scope.get_default_category_tree_id site: 0 + end + + context "success" do + let(:response) do + open_fixture_file "commerce/taxonomy/get_default_category_tree_id/success" + end + + it "sends a request" do + subject + expect(a_request(:get, url)).to have_been_made + end + end +end diff --git a/spec/operations/developer/analytics/rate_limit/get_spec.rb b/spec/operations/developer/analytics/rate_limit/get_spec.rb new file mode 100644 index 0000000..e0f6eeb --- /dev/null +++ b/spec/operations/developer/analytics/rate_limit/get_spec.rb @@ -0,0 +1,110 @@ +# frozen_string_literal: true + +RSpec.describe EbayAPI, '.developer.analytics.rate_limit.get' do + let(:client) { described_class.new(**settings) } + let(:settings) { yaml_fixture_file('settings.valid.yml') } + + before { stub_request(:get, url).to_return(response) } + + shared_examples_for 'requesting corresponding data' do + it 'returns data for all APIs' do + expect(subject).to be_an(Array) + + subject.each do |api_usage_stats| + expect(api_usage_stats.keys) + .to match_array(%w[apiContext apiName apiVersion resources]) + end + + expect(subject.map { |api_usage_stats| api_usage_stats['apiContext'] }.uniq) + .to match_array(expected_api_contexts) + + expect(a_request(:get, expected_url)).to have_been_made + end + end + + context 'when api_context is passed' do + subject { client.developer.analytics.rate_limit.get(api_context: 'sell') } + + let(:url) do + 'https://api.ebay.com/developer/analytics/v1_beta/rate_limit?api_context=sell' + end + + let(:response) do + open_fixture_file 'developer/analytics/rate_limit/get/api_context_response' + end + + it_behaves_like 'requesting corresponding data' do + let(:expected_url) { url } + let(:expected_api_contexts) { %w[sell] } + end + end + + context 'when api_name is passed' do + subject { client.developer.analytics.rate_limit.get(api_name: 'Negotiation') } + + let(:url) do + 'https://api.ebay.com/developer/analytics/v1_beta/rate_limit?api_name=Negotiation' + end + + let(:response) do + open_fixture_file 'developer/analytics/rate_limit/get/api_name_response' + end + + it_behaves_like 'requesting corresponding data' do + let(:expected_url) { url } + let(:expected_api_contexts) { %w[sell] } + end + end + + context 'when both api_name and api_context are passed' do + subject { client.developer.analytics.rate_limit.get(api_context: 'sell', api_name: 'Negotiation') } + + let(:url) do + 'https://api.ebay.com/developer/analytics/v1_beta/rate_limit?api_context=sell&api_name=Negotiation' + end + + let(:response) do + open_fixture_file 'developer/analytics/rate_limit/get/api_context_and_name_response' + end + + it_behaves_like 'requesting corresponding data' do + let(:expected_url) { url } + let(:expected_api_contexts) { %w[sell] } + end + end + + context 'when no additional paras are passed' do + subject { client.developer.analytics.rate_limit.get } + + let(:url) do + 'https://api.ebay.com/developer/analytics/v1_beta/rate_limit' + end + + let(:response) do + open_fixture_file 'developer/analytics/rate_limit/get/no_params_response' + end + + it_behaves_like 'requesting corresponding data' do + let(:expected_url) { url } + let(:expected_api_contexts) { %w[buy commerce sell] } + end + end + + context 'when no data is found for the given params' do + subject { client.developer.analytics.rate_limit.get(api_context: 'random') } + + let(:url) do + 'https://api.ebay.com/developer/analytics/v1_beta/rate_limit?api_context=random' + end + + let(:response) do + open_fixture_file 'developer/analytics/rate_limit/get/no_data_response' + end + + it 'returns true' do + is_expected.to be_truthy + + expect(a_request(:get, url)).to have_been_made + end + end +end diff --git a/spec/operations/sell/account/fulfillment_policy/create_spec.rb b/spec/operations/sell/account/fulfillment_policy/create_spec.rb new file mode 100644 index 0000000..1817e3c --- /dev/null +++ b/spec/operations/sell/account/fulfillment_policy/create_spec.rb @@ -0,0 +1,40 @@ +RSpec.describe EbayAPI, ".sell.account.fulfillment_policy.create" do + let(:client) { described_class.new(**settings) } + let(:scope) { client.sell.account(version: version).fulfillment_policy } + let(:settings) { yaml_fixture_file("settings.valid.yml") } + let(:version) { "1.2.0" } + + let(:url) do + "https://api.ebay.com/sell/account/v1/fulfillment_policy/" + end + + let(:payload) do + yaml_fixture_file "sell/account/fulfillment_policy/create/request.yml" + end + + let(:data) do + payload.reject { |key| key == "marketplaceId" } + end + + before { stub_request(:post, url).with(body: payload).to_return(response) } + subject { scope.create site: 0, data: data } + + context "success" do + let(:response) do + open_fixture_file "sell/account/fulfillment_policy/create/success" + end + + let(:policy) do + yaml_fixture_file "sell/account/fulfillment_policy/create/success.yml" + end + + it "sends a request" do + subject + expect(a_request(:post, url)).to have_been_made + end + + it "returns the policy" do + expect(subject).to eq policy + end + end +end diff --git a/spec/operations/sell/account/fulfillment_policy/delete_spec.rb b/spec/operations/sell/account/fulfillment_policy/delete_spec.rb new file mode 100644 index 0000000..55a58a4 --- /dev/null +++ b/spec/operations/sell/account/fulfillment_policy/delete_spec.rb @@ -0,0 +1,21 @@ +RSpec.describe EbayAPI, ".sell.account.fulfillment_policy.delete" do + let(:url) { "https://api.ebay.com/sell/account/v1/fulfillment_policy/42" } + let(:client) { described_class.new(**settings) } + let(:scope) { client.sell.account(version: version).fulfillment_policy } + let(:settings) { yaml_fixture_file("settings.valid.yml") } + let(:version) { "1.2.0" } + + before { stub_request(:delete, url).to_return(status: 204) } + subject { scope.delete id: 42 } + + context "success" do + it "sends a request" do + subject + expect(a_request(:delete, url)).to have_been_made + end + + it "returns true" do + expect(subject).to eq true + end + end +end diff --git a/spec/operations/sell/account/fulfillment_policy/get_by_name_spec.rb b/spec/operations/sell/account/fulfillment_policy/get_by_name_spec.rb new file mode 100644 index 0000000..9f703ef --- /dev/null +++ b/spec/operations/sell/account/fulfillment_policy/get_by_name_spec.rb @@ -0,0 +1,33 @@ +RSpec.describe EbayAPI, ".sell.account.fulfillment_policy.get_by_name" do + let(:client) { described_class.new(**settings) } + let(:scope) { client.sell.account(version: version).fulfillment_policy } + let(:settings) { yaml_fixture_file("settings.valid.yml") } + let(:version) { "1.2.0" } + let(:url) do + "https://api.ebay.com/sell/account/v1/fulfillment_policy/get_by_policy_name" \ + "?marketplace_id=EBAY_US&name=postcards" + end + + before { stub_request(:get, url).to_return(response) } + subject { scope.get_by_name site: 0, name: "postcards" } + + context "success" do + let(:response) do + open_fixture_file "sell/account/fulfillment_policy/get_by_name/success" + end + + let(:policy) do + yaml_fixture_file \ + "sell/account/fulfillment_policy/get_by_name/success.yml" + end + + it "sends a request" do + subject + expect(a_request(:get, url)).to have_been_made + end + + it "returns the policy" do + expect(subject).to eq policy + end + end +end diff --git a/spec/operations/sell/account/fulfillment_policy/get_spec.rb b/spec/operations/sell/account/fulfillment_policy/get_spec.rb new file mode 100644 index 0000000..55c470d --- /dev/null +++ b/spec/operations/sell/account/fulfillment_policy/get_spec.rb @@ -0,0 +1,31 @@ +RSpec.describe EbayAPI, ".sell.account.fulfillment_policy.get" do + let(:client) { described_class.new(**settings) } + let(:scope) { client.sell.account(version: version).fulfillment_policy } + let(:settings) { yaml_fixture_file("settings.valid.yml") } + let(:version) { "1.2.0" } + let(:url) do + "https://api.ebay.com/sell/account/v1/fulfillment_policy/5733588000" + end + + before { stub_request(:get, url).to_return(response) } + subject { scope.get id: "5733588000" } + + context "success" do + let(:response) do + open_fixture_file "sell/account/fulfillment_policy/get/success" + end + + let(:policy) do + yaml_fixture_file "sell/account/fulfillment_policy/get/success.yml" + end + + it "sends a request" do + subject + expect(a_request(:get, url)).to have_been_made + end + + it "returns the policy" do + expect(subject).to eq policy + end + end +end diff --git a/spec/operations/sell/account/fulfillment_policy/index_spec.rb b/spec/operations/sell/account/fulfillment_policy/index_spec.rb new file mode 100644 index 0000000..6805b27 --- /dev/null +++ b/spec/operations/sell/account/fulfillment_policy/index_spec.rb @@ -0,0 +1,32 @@ +RSpec.describe EbayAPI, ".sell.account.fulfillment_policy.index" do + let(:client) { described_class.new(**settings) } + let(:scope) { client.sell.account(version: version).fulfillment_policy } + let(:settings) { yaml_fixture_file("settings.valid.yml") } + let(:version) { "1.2.0" } + let(:url) do + "https://api.ebay.com/sell/account/v1/fulfillment_policy/" \ + "?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/fulfillment_policy/get/success" + end + + let(:policy) do + yaml_fixture_file "sell/account/fulfillment_policy/get/success.yml" + end + + it "sends a request" do + subject + expect(a_request(:get, url)).to have_been_made + end + + it "returns the policy" do + expect(subject).to eq policy + end + end +end diff --git a/spec/operations/sell/account/fulfillment_policy/update_spec.rb b/spec/operations/sell/account/fulfillment_policy/update_spec.rb new file mode 100644 index 0000000..8b78db5 --- /dev/null +++ b/spec/operations/sell/account/fulfillment_policy/update_spec.rb @@ -0,0 +1,40 @@ +RSpec.describe EbayAPI, ".sell.account.fulfillment_policy.update" do + let(:client) { described_class.new(**settings) } + let(:scope) { client.sell.account(version: version).fulfillment_policy } + let(:settings) { yaml_fixture_file("settings.valid.yml") } + let(:version) { "1.2.0" } + + let(:url) do + "https://api.ebay.com/sell/account/v1/fulfillment_policy/5733606000" + end + + let(:payload) do + yaml_fixture_file "sell/account/fulfillment_policy/update/request.yml" + end + + let(:data) do + payload.reject { |key| key == "marketplaceId" } + end + + before { stub_request(:put, url).to_return(response) } + subject { scope.update id: "5733606000", site: 0, data: data } + + context "success" do + let(:response) do + open_fixture_file "sell/account/fulfillment_policy/update/success" + end + + let(:policy) do + yaml_fixture_file "sell/account/fulfillment_policy/update/success.yml" + end + + it "sends a request" do + subject + expect(a_request(:put, url)).to have_been_made + end + + it "returns the policy" do + expect(subject).to eq policy + end + end +end diff --git a/spec/operations/sell/account/payment_policy/create_spec.rb b/spec/operations/sell/account/payment_policy/create_spec.rb new file mode 100644 index 0000000..9bf44c0 --- /dev/null +++ b/spec/operations/sell/account/payment_policy/create_spec.rb @@ -0,0 +1,40 @@ +RSpec.describe EbayAPI, ".sell.account.payment_policy.create" do + let(:client) { described_class.new(**settings) } + let(:scope) { client.sell.account(version: version).payment_policy } + let(:settings) { yaml_fixture_file("settings.valid.yml") } + let(:version) { "1.2.0" } + + let(:url) do + "https://api.ebay.com/sell/account/v1/payment_policy/" + end + + let(:payload) do + yaml_fixture_file "sell/account/payment_policy/create/request.yml" + end + + let(:data) do + payload.reject { |key| key == "marketplaceId" } + end + + before { stub_request(:post, url).with(body: payload).to_return(response) } + subject { scope.create site: 0, data: data } + + context "success" do + let(:response) do + open_fixture_file "sell/account/payment_policy/create/success" + end + + let(:policy) do + yaml_fixture_file "sell/account/payment_policy/create/success.yml" + end + + it "sends a request" do + subject + expect(a_request(:post, url)).to have_been_made + end + + it "returns the policy" do + expect(subject).to eq policy + end + end +end diff --git a/spec/operations/sell/account/payment_policy/delete_spec.rb b/spec/operations/sell/account/payment_policy/delete_spec.rb new file mode 100644 index 0000000..72a8c0d --- /dev/null +++ b/spec/operations/sell/account/payment_policy/delete_spec.rb @@ -0,0 +1,21 @@ +RSpec.describe EbayAPI, ".sell.account.payment_policy.delete" do + let(:url) { "https://api.ebay.com/sell/account/v1/payment_policy/184528067024" } + let(:client) { described_class.new(**settings) } + let(:scope) { client.sell.account(version: version).payment_policy } + let(:settings) { yaml_fixture_file("settings.valid.yml") } + let(:version) { "1.2.0" } + + before { stub_request(:delete, url).to_return(status: 204) } + subject { scope.delete id: "184528067024" } + + context "success" do + it "sends a request" do + subject + expect(a_request(:delete, url)).to have_been_made + end + + it "returns true" do + expect(subject).to eq true + end + end +end diff --git a/spec/operations/sell/account/payment_policy/get_by_name_spec.rb b/spec/operations/sell/account/payment_policy/get_by_name_spec.rb new file mode 100644 index 0000000..46d29c3 --- /dev/null +++ b/spec/operations/sell/account/payment_policy/get_by_name_spec.rb @@ -0,0 +1,33 @@ +RSpec.describe EbayAPI, ".sell.account.payment_policy.get_by_name" do + let(:client) { described_class.new(**settings) } + let(:scope) { client.sell.account(version: version).payment_policy } + let(:settings) { yaml_fixture_file("settings.valid.yml") } + let(:version) { "1.2.0" } + let(:url) do + "https://api.ebay.com/sell/account/v1/payment_policy/get_by_policy_name" \ + "?marketplace_id=EBAY_US&name=Managed%20Payments" + end + + before { stub_request(:get, url).to_return(response) } + subject { scope.get_by_name site: 0, name: "Managed Payments" } + + context "success" do + let(:response) do + open_fixture_file "sell/account/payment_policy/get_by_name/success" + end + + let(:policy) do + yaml_fixture_file \ + "sell/account/payment_policy/get_by_name/success.yml" + end + + it "sends a request" do + subject + expect(a_request(:get, url)).to have_been_made + end + + it "returns the policy" do + expect(subject).to eq policy + end + end +end diff --git a/spec/operations/sell/account/payment_policy/get_spec.rb b/spec/operations/sell/account/payment_policy/get_spec.rb new file mode 100644 index 0000000..2d8487d --- /dev/null +++ b/spec/operations/sell/account/payment_policy/get_spec.rb @@ -0,0 +1,31 @@ +RSpec.describe EbayAPI, ".sell.account.payment_policy.get" do + let(:client) { described_class.new(**settings) } + let(:scope) { client.sell.account(version: version).payment_policy } + let(:settings) { yaml_fixture_file("settings.valid.yml") } + let(:version) { "1.2.0" } + let(:url) do + "https://api.ebay.com/sell/account/v1/payment_policy/184528067024" + end + + before { stub_request(:get, url).to_return(response) } + subject { scope.get id: "184528067024" } + + context "success" do + let(:response) do + open_fixture_file "sell/account/payment_policy/get/success" + end + + let(:policy) do + yaml_fixture_file "sell/account/payment_policy/get/success.yml" + end + + it "sends a request" do + subject + expect(a_request(:get, url)).to have_been_made + end + + it "returns the policy" do + expect(subject).to eq policy + end + end +end diff --git a/spec/operations/sell/account/payment_policy/index_spec.rb b/spec/operations/sell/account/payment_policy/index_spec.rb new file mode 100644 index 0000000..99d7c1f --- /dev/null +++ b/spec/operations/sell/account/payment_policy/index_spec.rb @@ -0,0 +1,32 @@ +RSpec.describe EbayAPI, ".sell.account.payment_policy.index" do + let(:client) { described_class.new(**settings) } + let(:scope) { client.sell.account(version: version).payment_policy } + let(:settings) { yaml_fixture_file("settings.valid.yml") } + let(:version) { "1.2.0" } + let(:url) do + "https://api.ebay.com/sell/account/v1/payment_policy/" \ + "?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/payment_policy/get/success" + end + + let(:policy) do + yaml_fixture_file "sell/account/payment_policy/get/success.yml" + end + + it "sends a request" do + subject + expect(a_request(:get, url)).to have_been_made + end + + it "returns the policy" do + expect(subject).to eq policy + end + end +end diff --git a/spec/operations/sell/account/payment_policy/update_spec.rb b/spec/operations/sell/account/payment_policy/update_spec.rb new file mode 100644 index 0000000..5c24134 --- /dev/null +++ b/spec/operations/sell/account/payment_policy/update_spec.rb @@ -0,0 +1,40 @@ +RSpec.describe EbayAPI, ".sell.account.payment_policy.update" do + let(:client) { described_class.new(**settings) } + let(:scope) { client.sell.account(version: version).payment_policy } + let(:settings) { yaml_fixture_file("settings.valid.yml") } + let(:version) { "1.2.0" } + + let(:url) do + "https://api.ebay.com/sell/account/v1/payment_policy/184528067024" + end + + let(:payload) do + yaml_fixture_file "sell/account/payment_policy/update/request.yml" + end + + let(:data) do + payload.reject { |key| key == "marketplaceId" } + end + + before { stub_request(:put, url).to_return(response) } + subject { scope.update id: "184528067024", site: 0, data: data } + + context "success" do + let(:response) do + open_fixture_file "sell/account/payment_policy/update/success" + end + + let(:policy) do + yaml_fixture_file "sell/account/payment_policy/update/success.yml" + end + + it "sends a request" do + subject + expect(a_request(:put, url)).to have_been_made + end + + it "returns the policy" do + expect(subject).to eq policy + end + end +end diff --git a/spec/operations/sell/account/payments_program/get_spec.rb b/spec/operations/sell/account/payments_program/get_spec.rb new file mode 100644 index 0000000..c974eee --- /dev/null +++ b/spec/operations/sell/account/payments_program/get_spec.rb @@ -0,0 +1,54 @@ +RSpec.describe EbayAPI, ".sell.account.payments_program.get" do + let(:url) { "https://api.ebay.com/sell/account/v1/payments_program/EBAY_US/EBAY_PAYMENTS" } + let(:client) { described_class.new(**settings) } + let(:scope) { client.sell.account(version: version).payments_program } + let(:settings) { yaml_fixture_file(settings_file) } + let(:version) { "1.2.0" } + let(:settings_file) { "settings.valid.yml" } + + before { stub_request(:get, url).to_return(response) } + subject { scope.get(site: 0) } + + context "success" do + let(:response) do + open_fixture_file "sell/account/payments_program/get/success" + end + + it "returns just parsed JSON with data about payments program" do + expect(subject).to \ + eq( + "marketplaceId" => "EBAY_US", + "paymentProgramType" => "EBAY_PAYMENTS", + "status" => "OPTED_IN", + "wasPreviouslyOptedIn" => false + ) + end + end + + context "bad request" do + let(:response) do + open_fixture_file "sell/account/payments_program/get/bad_request" + end + + it "raises an exception" do + expect { subject }.to raise_error EbayAPI::Error + end + + it "carries error message" do + subject + rescue => err + expect(err.code).to eq 1002 + expect(err.data).not_to be_empty + end + end + + context "server error" do + let(:response) do + open_fixture_file "sell/account/payments_program/get/server_error" + end + + it "raises an exception" do + expect { subject }.to raise_error EbayAPI::Error + end + end +end diff --git a/spec/operations/sell/account/privilege/get_spec.rb b/spec/operations/sell/account/privilege/get_spec.rb index a1d0f56..0062e1a 100644 --- a/spec/operations/sell/account/privilege/get_spec.rb +++ b/spec/operations/sell/account/privilege/get_spec.rb @@ -1,6 +1,6 @@ RSpec.describe EbayAPI, ".sell.account.privilege.get" do let(:url) { "https://api.ebay.com/sell/account/v1/privilege/" } - let(:client) { described_class.new(settings) } + let(:client) { described_class.new(**settings) } let(:scope) { client.sell.account(version: version).privilege } let(:settings) { yaml_fixture_file(settings_file) } let(:version) { "1.2.0" } @@ -25,4 +25,31 @@ ) end end + + context "bad request" do + let(:response) do + open_fixture_file "sell/account/privilege/get/bad_request" + end + + it "raises an exception" do + expect { subject }.to raise_error EbayAPI::Error + end + + it "carries error message" do + subject + rescue => err + expect(err.code).to eq 1002 + expect(err.data).not_to be_empty + end + end + + context "server error" do + let(:response) do + open_fixture_file "sell/account/privilege/get/server_error" + end + + it "raises an exception" do + expect { subject }.to raise_error EbayAPI::Error + end + end end diff --git a/spec/operations/sell/account/program/opt_in_spec.rb b/spec/operations/sell/account/program/opt_in_spec.rb new file mode 100644 index 0000000..e4609ec --- /dev/null +++ b/spec/operations/sell/account/program/opt_in_spec.rb @@ -0,0 +1,22 @@ +RSpec.describe EbayAPI, ".sell.account.program.opt_in" do + let(:url) { "https://api.ebay.com/sell/account/v1/program/opt_in" } + let(:client) { described_class.new(**settings) } + let(:scope) { client.sell.account(version: version).program } + let(:settings) { yaml_fixture_file("settings.valid.yml") } + let(:version) { "1.2.0" } + let(:request) { { "programType" => "SELLING_POLICY_MANAGEMENT" }.to_json } + + before { stub_request(:post, url) } + subject { scope.opt_in program: :selling_policy_management } + + context "success" do + let(:response) do + open_fixture_file "sell/account/program/opt_in/success" + end + + it "sends a request" do + subject + expect(a_request(:post, url).with(body: request)).to have_been_made + end + end +end diff --git a/spec/operations/sell/account/return_policy/create_spec.rb b/spec/operations/sell/account/return_policy/create_spec.rb new file mode 100644 index 0000000..ef59424 --- /dev/null +++ b/spec/operations/sell/account/return_policy/create_spec.rb @@ -0,0 +1,40 @@ +RSpec.describe EbayAPI, ".sell.account.return_policy.create" do + let(:client) { described_class.new(**settings) } + let(:scope) { client.sell.account(version: version).return_policy } + let(:settings) { yaml_fixture_file("settings.valid.yml") } + let(:version) { "1.2.0" } + + let(:url) do + "https://api.ebay.com/sell/account/v1/return_policy/" + end + + let(:payload) do + yaml_fixture_file "sell/account/return_policy/create/request.yml" + end + + let(:data) do + payload.reject { |key| key == "marketplaceId" } + end + + before { stub_request(:post, url).with(body: payload).to_return(response) } + subject { scope.create site: 0, data: data } + + context "success" do + let(:response) do + open_fixture_file "sell/account/return_policy/create/success" + end + + let(:policy) do + yaml_fixture_file "sell/account/return_policy/create/success.yml" + end + + it "sends a request" do + subject + expect(a_request(:post, url)).to have_been_made + end + + it "returns the policy" do + expect(subject).to eq policy + end + end +end diff --git a/spec/operations/sell/account/return_policy/delete_spec.rb b/spec/operations/sell/account/return_policy/delete_spec.rb new file mode 100644 index 0000000..f05e54e --- /dev/null +++ b/spec/operations/sell/account/return_policy/delete_spec.rb @@ -0,0 +1,21 @@ +RSpec.describe EbayAPI, ".sell.account.return_policy.delete" do + let(:url) { "https://api.ebay.com/sell/account/v1/return_policy/42" } + let(:client) { described_class.new(**settings) } + let(:scope) { client.sell.account(version: version).return_policy } + let(:settings) { yaml_fixture_file("settings.valid.yml") } + let(:version) { "1.2.0" } + + before { stub_request(:delete, url).to_return(status: 204) } + subject { scope.delete id: 42 } + + context "success" do + it "sends a request" do + subject + expect(a_request(:delete, url)).to have_been_made + end + + it "returns true" do + expect(subject).to eq true + end + end +end diff --git a/spec/operations/sell/account/return_policy/get_by_name_spec.rb b/spec/operations/sell/account/return_policy/get_by_name_spec.rb new file mode 100644 index 0000000..44438ca --- /dev/null +++ b/spec/operations/sell/account/return_policy/get_by_name_spec.rb @@ -0,0 +1,33 @@ +RSpec.describe EbayAPI, ".sell.account.return_policy.get_by_name" do + let(:client) { described_class.new(**settings) } + let(:scope) { client.sell.account(version: version).return_policy } + let(:settings) { yaml_fixture_file("settings.valid.yml") } + let(:version) { "1.2.0" } + let(:url) do + "https://api.ebay.com/sell/account/v1/return_policy/get_by_policy_name" \ + "?marketplace_id=EBAY_US&name=postcards" + end + + before { stub_request(:get, url).to_return(response) } + subject { scope.get_by_name site: 0, name: "postcards" } + + context "success" do + let(:response) do + open_fixture_file "sell/account/return_policy/get_by_name/success" + end + + let(:policy) do + yaml_fixture_file \ + "sell/account/return_policy/get_by_name/success.yml" + end + + it "sends a request" do + subject + expect(a_request(:get, url)).to have_been_made + end + + it "returns the policy" do + expect(subject).to eq policy + end + end +end diff --git a/spec/operations/sell/account/return_policy/get_spec.rb b/spec/operations/sell/account/return_policy/get_spec.rb new file mode 100644 index 0000000..7ab54d8 --- /dev/null +++ b/spec/operations/sell/account/return_policy/get_spec.rb @@ -0,0 +1,31 @@ +RSpec.describe EbayAPI, ".sell.account.return_policy.get" do + let(:client) { described_class.new(**settings) } + let(:scope) { client.sell.account(version: version).return_policy } + let(:settings) { yaml_fixture_file("settings.valid.yml") } + let(:version) { "1.2.0" } + let(:url) do + "https://api.ebay.com/sell/account/v1/return_policy/5733588000" + end + + before { stub_request(:get, url).to_return(response) } + subject { scope.get id: "5733588000" } + + context "success" do + let(:response) do + open_fixture_file "sell/account/return_policy/get/success" + end + + let(:policy) do + yaml_fixture_file "sell/account/return_policy/get/success.yml" + end + + it "sends a request" do + subject + expect(a_request(:get, url)).to have_been_made + end + + it "returns the policy" do + expect(subject).to eq policy + end + end +end diff --git a/spec/operations/sell/account/return_policy/index_spec.rb b/spec/operations/sell/account/return_policy/index_spec.rb new file mode 100644 index 0000000..8b2f745 --- /dev/null +++ b/spec/operations/sell/account/return_policy/index_spec.rb @@ -0,0 +1,32 @@ +RSpec.describe EbayAPI, ".sell.account.return_policy.index" do + let(:client) { described_class.new(**settings) } + let(:scope) { client.sell.account(version: version).return_policy } + let(:settings) { yaml_fixture_file("settings.valid.yml") } + let(:version) { "1.2.0" } + let(:url) do + "https://api.ebay.com/sell/account/v1/return_policy/" \ + "?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/return_policy/get/success" + end + + let(:policy) do + yaml_fixture_file "sell/account/return_policy/get/success.yml" + end + + it "sends a request" do + subject + expect(a_request(:get, url)).to have_been_made + end + + it "returns the policy" do + expect(subject).to eq policy + end + end +end diff --git a/spec/operations/sell/account/return_policy/update_spec.rb b/spec/operations/sell/account/return_policy/update_spec.rb new file mode 100644 index 0000000..00f99dd --- /dev/null +++ b/spec/operations/sell/account/return_policy/update_spec.rb @@ -0,0 +1,38 @@ +RSpec.describe EbayAPI, ".sell.account.return_policy.update" do + let(:client) { described_class.new(**settings) } + let(:scope) { client.sell.account(version: version).return_policy } + let(:settings) { yaml_fixture_file("settings.valid.yml") } + let(:version) { "1.2.0" } + + let(:url) do + "https://api.ebay.com/sell/account/v1/return_policy/5733606000" + end + + let(:payload) do + yaml_fixture_file "sell/account/return_policy/update/request.yml" + end + + let(:data) { payload.reject { |k| k == "marketplaceId" } } + + before { stub_request(:put, url).to_return(response) } + subject { scope.update id: "5733606000", data: data, site: 0 } + + context "success" do + let(:response) do + open_fixture_file "sell/account/return_policy/update/success" + end + + let(:policy) do + yaml_fixture_file "sell/account/return_policy/update/success.yml" + end + + it "sends a request" do + subject + expect(a_request(:put, url).with(body: payload)).to have_been_made + end + + it "returns the policy" do + expect(subject).to eq policy + end + end +end diff --git a/spec/operations/sell/inventory/offers/get_listing_fees_spec.rb b/spec/operations/sell/inventory/offers/get_listing_fees_spec.rb index 38eb87f..453a663 100644 --- a/spec/operations/sell/inventory/offers/get_listing_fees_spec.rb +++ b/spec/operations/sell/inventory/offers/get_listing_fees_spec.rb @@ -1,5 +1,5 @@ RSpec.describe EbayAPI, ".sell.inventory.offer.get_listing_fees" do - let(:client) { described_class.new(settings) } + let(:client) { described_class.new(**settings) } let(:scope) { client.sell.inventory(version: version).offers } let(:response) { yaml_fixture_file(response_file).to_json } let(:request) { yaml_fixture_file(request_file).to_json } diff --git a/spec/operations/sell/marketing/ads/bulk_create_by_listing_id_spec.rb b/spec/operations/sell/marketing/ads/bulk_create_by_listing_id_spec.rb index 01b97b0..db16cc5 100644 --- a/spec/operations/sell/marketing/ads/bulk_create_by_listing_id_spec.rb +++ b/spec/operations/sell/marketing/ads/bulk_create_by_listing_id_spec.rb @@ -4,7 +4,7 @@ https://api.ebay.com/sell/marketing/v1/ad_campaign/1/bulk_create_ads_by_listing_id URL end - let(:client) { described_class.new(settings) } + let(:client) { described_class.new(**settings) } let(:scope) { client.sell.marketing(version: version).ads(campaign_id: 1) } let(:settings) { yaml_fixture_file(settings_file) } let(:version) { "1.1.0" } diff --git a/spec/operations/sell/marketing/ads/bulk_delete_by_listing_id_spec.rb b/spec/operations/sell/marketing/ads/bulk_delete_by_listing_id_spec.rb index 378fbc5..757ec9b 100644 --- a/spec/operations/sell/marketing/ads/bulk_delete_by_listing_id_spec.rb +++ b/spec/operations/sell/marketing/ads/bulk_delete_by_listing_id_spec.rb @@ -4,7 +4,7 @@ https://api.ebay.com/sell/marketing/v1/ad_campaign/1/bulk_delete_ads_by_listing_id URL end - let(:client) { described_class.new(settings) } + let(:client) { described_class.new(**settings) } let(:scope) { client.sell.marketing(version: version).ads(campaign_id: 1) } let(:settings) { yaml_fixture_file(settings_file) } let(:version) { "1.1.0" } diff --git a/spec/operations/sell/marketing/ads/create_by_listing_id_spec.rb b/spec/operations/sell/marketing/ads/create_by_listing_id_spec.rb index acd0fbe..ab4b7b3 100644 --- a/spec/operations/sell/marketing/ads/create_by_listing_id_spec.rb +++ b/spec/operations/sell/marketing/ads/create_by_listing_id_spec.rb @@ -1,6 +1,6 @@ RSpec.describe EbayAPI, ".sell.marketing.ads.create_by_listing_id" do let(:url) { "https://api.ebay.com/sell/marketing/v1/ad_campaign/1/ad" } - let(:client) { described_class.new(settings) } + let(:client) { described_class.new(**settings) } let(:scope) { client.sell.marketing(version: version).ads(campaign_id: 1) } let(:settings) { yaml_fixture_file(settings_file) } let(:version) { "1.1.0" } diff --git a/spec/operations/sell/marketing/ads/list_spec.rb b/spec/operations/sell/marketing/ads/list_spec.rb index 11d6be1..84a28ed 100644 --- a/spec/operations/sell/marketing/ads/list_spec.rb +++ b/spec/operations/sell/marketing/ads/list_spec.rb @@ -4,7 +4,7 @@ https://api.ebay.com/sell/marketing/v1/ad_campaign/1/ad{?params*} URL end - let(:client) { described_class.new(settings) } + let(:client) { described_class.new(**settings) } let(:scope) { client.sell.marketing(version: version).ads(campaign_id: 1) } let(:settings) { yaml_fixture_file(settings_file) } let(:version) { "1.1.0" } diff --git a/spec/operations/sell/marketing/campaigns/create_spec.rb b/spec/operations/sell/marketing/campaigns/create_spec.rb index 374d305..d3a7405 100644 --- a/spec/operations/sell/marketing/campaigns/create_spec.rb +++ b/spec/operations/sell/marketing/campaigns/create_spec.rb @@ -1,18 +1,18 @@ RSpec.describe EbayAPI, ".sell.marketing.campaign.create" do let(:url) { "https://api.ebay.com/sell/marketing/v1/ad_campaign" } - let(:client) { described_class.new(settings) } + let(:client) { described_class.new(**settings) } let(:scope) { client.sell.marketing(version: version).campaigns } let(:settings) { yaml_fixture_file(settings_file) } let(:version) { "1.1.0" } let(:settings_file) { "settings.valid.yml" } let(:params) do { - "campaignName" => "eBay Mag GB", + campaignName: "eBay Mag GB", fundingStrategy: { - "bidPercentage" => "5.0", - "fundingModel" => "COST_PER_SALE" + bidPercentage: "5.0", + fundingModel: "COST_PER_SALE" }, - "marketplaceId": "EBAY_GB", + marketplaceId: "EBAY_GB", startDate: Time.now.iso8601 } end diff --git a/spec/operations/sell/metadata/marketplace/get_item_condition_policies_spec.rb b/spec/operations/sell/metadata/marketplace/get_item_condition_policies_spec.rb new file mode 100644 index 0000000..7f125cc --- /dev/null +++ b/spec/operations/sell/metadata/marketplace/get_item_condition_policies_spec.rb @@ -0,0 +1,45 @@ +RSpec.describe EbayAPI, ".sell.metadata.marketplace.get_item_condition_policies" do + let(:client) { described_class.new(**settings) } + let(:scope) { client.sell.metadata.marketplace(marketplace_id: "EBAY_US") } + let(:settings) { yaml_fixture_file("settings.valid.yml") } + let(:url) do + "https://api.ebay.com/sell/metadata/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 "sell/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 + diff --git a/spec/paginated_collection_spec.rb b/spec/paginated_collection_spec.rb index 8059535..5a1a5ba 100644 --- a/spec/paginated_collection_spec.rb +++ b/spec/paginated_collection_spec.rb @@ -4,27 +4,28 @@ require "ebay_api/paginated_collection" RSpec.describe EbayAPI::PaginatedCollection do - let!(:operation) do + let!(:new_operation) do class EbayAPI - operation :test_paginated_operation do - http_method :get - path "sell/marketing/v1/ad_campaign" + scope :paginated do + operation :test_paginated_operation do + http_method :get + path { "sell/marketing/v1/ad_campaign" } - option :limit, optional: true - option :offset, optional: true + option :limit, optional: true + option :offset, optional: true - query { { limit: limit, offset: offset }.compact } + query { { limit: limit, offset: offset }.compact } + middleware { PaginatedCollection::MiddlewareBuilder.call(max_limit: 2) } - middleware { PaginatedCollection::MiddlewareBuilder.call(max_limit: 2) } - - response(200) do |*response| - EbayAPI::PaginatedCollection.new(self, response, "campaigns") + response(200) do |*response| + EbayAPI::PaginatedCollection.new(self, response, "campaigns") + end end end end end - let(:client) { EbayAPI.new(settings) } + let(:client) { EbayAPI.new(**settings) } let(:settings) { yaml_fixture_file(settings_file) } let(:settings_file) { "settings.valid.yml" } @@ -58,7 +59,7 @@ class EbayAPI let(:params) { {} } - subject { client.test_paginated_operation(**params) } + subject { client.paginated.test_paginated_operation(**params) } it "retrieves all pages" do expect(subject.to_a).to eq(Array.new(5) { |i| { "id" => i } }) diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index 44c0fcb..24d7bd9 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -16,7 +16,3 @@ config.filter_run focus: true config.run_all_when_everything_filtered = true end - -I18n.available_locales = %i[en] -I18n.locale = :en -I18n.load_path += ["config/locales/en.yml"] diff --git a/spec/token_manager_spec.rb b/spec/token_manager_spec.rb index 0c919ae..13431dd 100644 --- a/spec/token_manager_spec.rb +++ b/spec/token_manager_spec.rb @@ -4,18 +4,6 @@ require "ebay_api/token_manager" describe EbayAPI::TokenManager do - let(:refresh_response) do - { status: 200, body: '{"access_token":"new_token","expires_in":7200}' } - end - let!(:api) do - stub_request(:post, "https://api.sandbox.ebay.com/identity/v1/oauth2/token") - .with( - body: { grant_type: "refresh_token", refresh_token: "refreshing" }, - basic_auth: %w[1 2] - ) - .to_return(refresh_response) - end - let(:access_token) { "old_token" } let(:refresh_token) { "refreshing" } let(:access_expire) { Time.now + 120 } @@ -31,6 +19,18 @@ ) end + let(:refresh_response) do + { status: 200, body: '{"access_token":"new_token","expires_in":7200}' } + end + let!(:api) do + stub_request(:post, "https://api.sandbox.ebay.com/identity/v1/oauth2/token") + .with( + body: { grant_type: "refresh_token", refresh_token: "refreshing" }, + basic_auth: %w[1 2] + ) + .to_return(refresh_response) + end + before do Timecop.freeze allow(callback).to receive(:call).with("new_token", Time.now + 7200) @@ -38,6 +38,44 @@ after { Timecop.return } + describe "#application_token" do + let!(:api) do + stub_request(:post, "https://api.sandbox.ebay.com/identity/v1/oauth2/token") + .with( + body: { + grant_type: "client_credentials", + scope: "https://api.ebay.com/oauth/api_scope" + }, + basic_auth: %w[1 2] + ) + .to_return(refresh_response) + end + + it "returns application token" do + expect(subject.application_token).to eq("new_token") + expect(api).to have_been_requested + end + end + + describe "#request_application_token!" do + let!(:api) do + stub_request(:post, "https://api.sandbox.ebay.com/identity/v1/oauth2/token") + .with( + body: { + grant_type: "client_credentials", + scope: "https://api.ebay.com/oauth/api_scope" + }, + basic_auth: %w[1 2] + ) + .to_return(refresh_response) + end + + it "returns application token" do + expect(subject.request_application_token!).to eq(JSON.parse(refresh_response[:body])) + expect(api).to have_been_requested + end + end + describe "#access_token" do context "with valid access_token" do it "returns access_token" do @@ -105,13 +143,29 @@ let(:refresh_response) do { status: 400, - body: '{"error":"invalid_grant","error_description":"fiasco"}', + body: '{"error":"invalid_grant","error_description":"fiasco"}' + } + end + + it "raises exception" do + expect { subject.refresh! }.to raise_error( + EbayAPI::TokenManager::RefreshTokenInvalid, "invalid_grant - fiasco" + ) + end + end + + context "with client not authorized" do + let(:refresh_response) do + { + status: 400, + body: '{"error":"unauthorized_client","error_description":"fiasco"}' } end it "raises exception" do expect { subject.refresh! }.to raise_error( - EbayAPI::TokenManager::RefreshTokenInvalid, "fiasco" + EbayAPI::TokenManager::RefreshTokenInvalid, + "unauthorized_client - fiasco" ) end end @@ -120,13 +174,24 @@ let(:refresh_response) do { status: 500, - body: '{"error":"server_error","error_description":"this is fiasco"}', + body: '{"error":"server_error","error_description":"this is fiasco"}' } end it "raises exception" do expect { subject.refresh! }.to raise_error \ - EbayAPI::InternalServerError, /this is fiasco/ + EbayAPI::InternalServerError, /server_error - this is fiasco/ + end + end + + context "when server returns nonparseable result" do + let(:refresh_response) do + { status: 502, body: "

Gateway timeout

" } + end + + it "raises exception" do + expect { subject.refresh! }.to raise_error \ + EbayAPI::Error, /isn't JSON: 502 .*Gateway timeout/ end end end