Git Product home page Git Product logo

ebay_request's Introduction

EbayRequest

eBay XML API request interface.

Installation

Add this line to your application's Gemfile:

gem 'ebay_request'

And then execute:

$ bundle

Or install it yourself as:

$ gem install ebay_request

Usage

# config/initializers/ebay_request.rb

secrets = Rails.application.secrets.ebay
raise "Set eBay credentials in secrets.yml" if secrets.blank?

EbayRequest.configure do |config|
  config.appid = secrets["appid"]
  config.certid = secrets["certid"]
  config.devid = secrets["devid"]
  config.runame = secrets["runame"]
  config.sandbox = secrets["sandbox"]
end

EbayRequest.logger = Logger.new("ebay-request.log")
EbayRequest.warn_logger = Logger.new("ebay-request-warn.log") # Not logged otherwise
EbayRequest.json_logger = GraylogProxy.new # Should receive #notify
EbayRequest::Finding.new.response("findItemsByKeywords", keywords: "abc")
EbayRequest::Shopping.new.response("GetSingleItem", ItemID: "252261544055")
EbayRequest::Shopping.new(token: "...").response("AddItem", ...some data...)

Using multiple key sets

EbayRequest.configure do |config|
  config.appid = secrets["appid"]
  # And so on
  # ...
end

EbayRequest.configure(:sandbox) do |config|
  config.appid = secrets["appid"]
  # ...
  config.sandbox = true  
end

EbayRequest::Finding.new(env: :sandbox).response("findItemsByKeywords", keywords: "abc")

OmniAuth strategy

If gem is configured somewhere at initializer (shown above):

Rails.application.config.middleware.use OmniAuth::Builder do
  provider :ebay
end

If you want to use just strategy you can pass all the required options as #provider args (see source).

This strategy is for Auth'n'auth method only. For OAuth method see the omniauth-ebay-oauth gem.

Working with old XML and new REST API simultaneously

If you're planning to work with new eBay REST APIs, you will find that another kind of access tokens are required for working with these APIs.

Tokens obtained with Auth'n'auth only usable with eBay XML API, while tokens obtained with OAuth only usable with eBay REST API.

However, you can use new OAuth tokens to access old APIs by providing an access token in (not yet) documented HTTP header X-EBAY-API-IAF-TOKEN. This gem has builtin support for this.

To use it:

  1. Replace OmniAuth strategy from this gem to the strategy from the omniauth-ebay-oauth gem.

    Most probably you will need to store and use both Auth'n'auth and OAuth tokens for a while to provide a smooth transition.

  2. For working with REST API and their tokens add the ebay_api gem to your application.

  3. Construct an EbayAPI::TokenManager instance with all OAuth tokens.

    See https://github.com/nepalez/ebay_api/#working-with-access-tokens

    Any object that responds to refresh! method and returns actual token from the access_token method will be fine too.

  4. Pass this token manager object in :iaf_token_manager option into the XML API constructor:

    EbayRequest::Trading.new(
      token: auth_n_auth_token,
      iaf_token_manager: iaf_token_manager,
      siteid: 0,
    )

    You can pass both old token in :token option and new token manager in :iaf_token_manager option. Old tokens will be used if the token manager is nil.

Development

After checking out the repo, run bin/setup to install dependencies. Then, run rake spec to run the tests. You can also run bin/console for an interactive prompt that will allow you to experiment.

To install this gem onto your local machine, run bundle exec rake install. To release a new version, update the version number in version.rb, and then run bundle exec rake release, which will create a git tag for the version, push git commits and tags, and push the .gem file to rubygems.org.

Contributing

Bug reports and pull requests are welcome on GitHub at https://github.com/gzigzigzeo/ebay_request.

ebay_request's People

Contributors

aderyabin avatar alno avatar darthsim avatar envek avatar gzigzigzeo avatar nepalez avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.