ebay_client 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +15 -0
- data/.gitignore +2 -0
- data/.ruby-version +1 -0
- data/Gemfile +2 -0
- data/Gemfile.lock +51 -0
- data/LICENSE +23 -0
- data/README.md +63 -0
- data/Rakefile +6 -0
- data/config/defaults.yml +25 -0
- data/ebay_client.gemspec +29 -0
- data/lib/ebay_client.rb +11 -0
- data/lib/ebay_client/api.rb +68 -0
- data/lib/ebay_client/configuration.rb +79 -0
- data/lib/ebay_client/endpoint.rb +22 -0
- data/lib/ebay_client/engine.rb +20 -0
- data/lib/ebay_client/header.rb +26 -0
- data/lib/ebay_client/request.rb +40 -0
- data/lib/ebay_client/response.rb +109 -0
- data/lib/ebay_client/version.rb +3 -0
- data/vendor/ebay/767.wsdl +133660 -0
- data/vendor/ebay/809.wsdl +137391 -0
- metadata +106 -0
    
        checksums.yaml
    ADDED
    
    | @@ -0,0 +1,15 @@ | |
| 1 | 
            +
            ---
         | 
| 2 | 
            +
            !binary "U0hBMQ==":
         | 
| 3 | 
            +
              metadata.gz: !binary |-
         | 
| 4 | 
            +
                OTQzYjA2ZmUwYzllYmJiNmNlOWQxMWRlZTVmYzk3M2MzODVlMmRkNg==
         | 
| 5 | 
            +
              data.tar.gz: !binary |-
         | 
| 6 | 
            +
                MWFjZWIyZWQwMmM1ZTE0MGZjYjY2N2UxYTI1OTM1YjRmODNkM2Q1Mg==
         | 
| 7 | 
            +
            SHA512:
         | 
| 8 | 
            +
              metadata.gz: !binary |-
         | 
| 9 | 
            +
                NmY3NGI2MjllOWNmY2U0MDk5NzZmNTQzMDgxNTI3NjI5ZDc4N2NjYTAwYTg3
         | 
| 10 | 
            +
                ODMyMjk4MWVjYzA2MDA4MjA3NGQ3NTI3ZmY1NTVkNzFlNjkwMjZjZTA0ZjAy
         | 
| 11 | 
            +
                Y2Y2ODFiM2M0MzY4MTExNTJmOGExZDdlNTg0MGU0Yzc2MjFiZDA=
         | 
| 12 | 
            +
              data.tar.gz: !binary |-
         | 
| 13 | 
            +
                MTg2NjZmMGY2YjVmZmUzMWI4OTM4ZWJhNWUxYzQ3ZTFhYzY4MjJlMTBjYTQx
         | 
| 14 | 
            +
                NTQ1NDQ3NmNiNWM3NDJkMGQ5ZDMwZTU3YjJiYTZjMTA5YTliZmM4NDQ0OTUz
         | 
| 15 | 
            +
                N2I0YjQ3ZGY4ZWZjNjZkZTZhMDM0YWVkZmY5Zjg2YmNhNDM3N2E=
         | 
    
        data/.gitignore
    ADDED
    
    
    
        data/.ruby-version
    ADDED
    
    | @@ -0,0 +1 @@ | |
| 1 | 
            +
            1.9.3
         | 
    
        data/Gemfile
    ADDED
    
    
    
        data/Gemfile.lock
    ADDED
    
    | @@ -0,0 +1,51 @@ | |
| 1 | 
            +
            PATH
         | 
| 2 | 
            +
              remote: .
         | 
| 3 | 
            +
              specs:
         | 
| 4 | 
            +
                ebay_client (0.0.1)
         | 
| 5 | 
            +
                  activesupport (>= 3.1.0)
         | 
| 6 | 
            +
                  savon (~> 0.9.9)
         | 
| 7 | 
            +
             | 
| 8 | 
            +
            GEM
         | 
| 9 | 
            +
              remote: http://rubygems.org/
         | 
| 10 | 
            +
              specs:
         | 
| 11 | 
            +
                activesupport (3.2.3)
         | 
| 12 | 
            +
                  i18n (~> 0.6)
         | 
| 13 | 
            +
                  multi_json (~> 1.0)
         | 
| 14 | 
            +
                akami (1.0.0)
         | 
| 15 | 
            +
                  gyoku (>= 0.4.0)
         | 
| 16 | 
            +
                builder (3.0.0)
         | 
| 17 | 
            +
                columnize (0.3.6)
         | 
| 18 | 
            +
                debugger (1.1.1)
         | 
| 19 | 
            +
                  columnize (>= 0.3.1)
         | 
| 20 | 
            +
                  debugger-linecache (~> 1.1)
         | 
| 21 | 
            +
                  debugger-ruby_core_source (~> 1.1)
         | 
| 22 | 
            +
                debugger-linecache (1.1.1)
         | 
| 23 | 
            +
                  debugger-ruby_core_source (>= 1.1.1)
         | 
| 24 | 
            +
                debugger-ruby_core_source (1.1.2)
         | 
| 25 | 
            +
                gyoku (0.4.4)
         | 
| 26 | 
            +
                  builder (>= 2.1.2)
         | 
| 27 | 
            +
                httpi (0.9.6)
         | 
| 28 | 
            +
                  rack
         | 
| 29 | 
            +
                i18n (0.6.0)
         | 
| 30 | 
            +
                multi_json (1.3.2)
         | 
| 31 | 
            +
                nokogiri (1.5.2)
         | 
| 32 | 
            +
                nori (1.1.0)
         | 
| 33 | 
            +
                rack (1.4.1)
         | 
| 34 | 
            +
                savon (0.9.9)
         | 
| 35 | 
            +
                  akami (~> 1.0)
         | 
| 36 | 
            +
                  builder (>= 2.1.2)
         | 
| 37 | 
            +
                  gyoku (>= 0.4.0)
         | 
| 38 | 
            +
                  httpi (~> 0.9)
         | 
| 39 | 
            +
                  nokogiri (>= 1.4.0)
         | 
| 40 | 
            +
                  nori (~> 1.1)
         | 
| 41 | 
            +
                  wasabi (~> 2.1)
         | 
| 42 | 
            +
                wasabi (2.1.0)
         | 
| 43 | 
            +
                  nokogiri (>= 1.4.0)
         | 
| 44 | 
            +
             | 
| 45 | 
            +
            PLATFORMS
         | 
| 46 | 
            +
              ruby
         | 
| 47 | 
            +
             | 
| 48 | 
            +
            DEPENDENCIES
         | 
| 49 | 
            +
              bundler
         | 
| 50 | 
            +
              debugger
         | 
| 51 | 
            +
              ebay_client!
         | 
    
        data/LICENSE
    ADDED
    
    | @@ -0,0 +1,23 @@ | |
| 1 | 
            +
            Copyright (c) 2012 ['Kayoom GmbH Düren, Germany', 'Marian Theisen'],
         | 
| 2 | 
            +
            except 'vendor/ebay/*.wsdl', Copyright (c) eBay
         | 
| 3 | 
            +
             | 
| 4 | 
            +
            Permission is hereby granted, free of charge, to any person
         | 
| 5 | 
            +
            obtaining a copy of this software and associated documentation
         | 
| 6 | 
            +
            files (the "Software"), to deal in the Software without
         | 
| 7 | 
            +
            restriction, including without limitation the rights to use,
         | 
| 8 | 
            +
            copy, modify, merge, publish, distribute, sublicense, and/or sell
         | 
| 9 | 
            +
            copies of the Software, and to permit persons to whom the
         | 
| 10 | 
            +
            Software is furnished to do so, subject to the following
         | 
| 11 | 
            +
            conditions:
         | 
| 12 | 
            +
             | 
| 13 | 
            +
            The above copyright notice and this permission notice shall be
         | 
| 14 | 
            +
            included in all copies or substantial portions of the Software.
         | 
| 15 | 
            +
             | 
| 16 | 
            +
            THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
         | 
| 17 | 
            +
            EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
         | 
| 18 | 
            +
            OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
         | 
| 19 | 
            +
            NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
         | 
| 20 | 
            +
            HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
         | 
| 21 | 
            +
            WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
         | 
| 22 | 
            +
            FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
         | 
| 23 | 
            +
            OTHER DEALINGS IN THE SOFTWARE.
         | 
    
        data/README.md
    ADDED
    
    | @@ -0,0 +1,63 @@ | |
| 1 | 
            +
            EbayClient
         | 
| 2 | 
            +
            ==========
         | 
| 3 | 
            +
             | 
| 4 | 
            +
            Simple, lightweight eBay Trading API Client.
         | 
| 5 | 
            +
             | 
| 6 | 
            +
            Installation
         | 
| 7 | 
            +
            ------------
         | 
| 8 | 
            +
             | 
| 9 | 
            +
            ### Rails
         | 
| 10 | 
            +
             | 
| 11 | 
            +
            `Gemfile`:
         | 
| 12 | 
            +
             | 
| 13 | 
            +
                gem 'ebay_client', '~> 0.1.0'
         | 
| 14 | 
            +
             | 
| 15 | 
            +
            `config/ebay_client.yml`:
         | 
| 16 | 
            +
             | 
| 17 | 
            +
                development: &sandbox
         | 
| 18 | 
            +
                  api_keys:
         | 
| 19 | 
            +
                    - token: '<YOUR SANDBOX AUTHENTICATION TOKEN>'
         | 
| 20 | 
            +
                      devid: '<YOUR SANDBOX DEV ID>'
         | 
| 21 | 
            +
                      appid: '<YOUR SANDBOX APP ID>'
         | 
| 22 | 
            +
                      certid: '<YOUR SANDBOX CERT ID>'
         | 
| 23 | 
            +
             | 
| 24 | 
            +
                test:
         | 
| 25 | 
            +
                  <<: *sandbox
         | 
| 26 | 
            +
             | 
| 27 | 
            +
                production:
         | 
| 28 | 
            +
                  api_keys:
         | 
| 29 | 
            +
                    - token: '<YOUR LIVE AUTHENTICATION TOKEN>'
         | 
| 30 | 
            +
                      devid: '<YOUR LIVE DEV ID>'
         | 
| 31 | 
            +
                      appid: '<YOUR LIVE APP ID>'
         | 
| 32 | 
            +
                      certid: '<YOUR LIVE CERT ID>'
         | 
| 33 | 
            +
             | 
| 34 | 
            +
            Fire up your console!
         | 
| 35 | 
            +
             | 
| 36 | 
            +
            Usage
         | 
| 37 | 
            +
            -----
         | 
| 38 | 
            +
             | 
| 39 | 
            +
            ### Rails
         | 
| 40 | 
            +
             | 
| 41 | 
            +
            e.g. `rails console`:
         | 
| 42 | 
            +
             | 
| 43 | 
            +
                EbayClient.api.get_ebay_official_time!
         | 
| 44 | 
            +
                # => {:timestamp=>Fri, 22 Nov 2013 12:31:02 +0000}
         | 
| 45 | 
            +
             | 
| 46 | 
            +
            Notes
         | 
| 47 | 
            +
            -----
         | 
| 48 | 
            +
            * An overview of possible API calls can be found at the
         | 
| 49 | 
            +
              [eBay Trading API docs](http://developer.ebay.com/DevZone/XML/docs/Reference/eBay/)
         | 
| 50 | 
            +
            * Names (Methods, Types, Members) are mapped from `CamelCase` \<=\> `snake_case`
         | 
| 51 | 
            +
            * `eBay` is mapped to `ebay`, i.e. `GeteBayOfficialTime` \<=\>
         | 
| 52 | 
            +
              `get_ebay_official_time`
         | 
| 53 | 
            +
            * For each call, there are 2 methods, with and without a bang (`!`), i.e.  
         | 
| 54 | 
            +
                * `get_ebay_official_time` returns an `EbayClient::Response`
         | 
| 55 | 
            +
                  instance, which contains the `ack` value, the `payload` and possibly
         | 
| 56 | 
            +
                  `errors`
         | 
| 57 | 
            +
                * `get_ebay_official_time!` returns the payload as a `Hash` and raises
         | 
| 58 | 
            +
                  an `EbayClient::Response::Exception` if the API returned an error.
         | 
| 59 | 
            +
            * You can specify an arbitrary amount of API key/tokens in your
         | 
| 60 | 
            +
              `ebay_client.yml`. On initialization, the EbayClient will randomly
         | 
| 61 | 
            +
              choose one of them. If you run out of API calls, it will automatically
         | 
| 62 | 
            +
              switch to another key.
         | 
| 63 | 
            +
            * Pull requests and bug reports are welcome!
         | 
    
        data/Rakefile
    ADDED
    
    
    
        data/config/defaults.yml
    ADDED
    
    | @@ -0,0 +1,25 @@ | |
| 1 | 
            +
            defaults: &defaults
         | 
| 2 | 
            +
              version: 809
         | 
| 3 | 
            +
              # use local file as default
         | 
| 4 | 
            +
              #wsdl_file: 'http://developer.ebay.com/webservices/809/eBaySvc.wsdl'
         | 
| 5 | 
            +
              routing: default
         | 
| 6 | 
            +
              siteid: 0
         | 
| 7 | 
            +
              preload: false
         | 
| 8 | 
            +
              warning_level: Low
         | 
| 9 | 
            +
              error_language: en_US
         | 
| 10 | 
            +
              api_keys: []
         | 
| 11 | 
            +
              savon_log_level: debug
         | 
| 12 | 
            +
             | 
| 13 | 
            +
            development: &development
         | 
| 14 | 
            +
              <<: *defaults
         | 
| 15 | 
            +
              url: 'https://api.sandbox.ebay.com/wsapi'
         | 
| 16 | 
            +
              warning_level: High
         | 
| 17 | 
            +
              savon_log_level: info
         | 
| 18 | 
            +
             | 
| 19 | 
            +
            test:
         | 
| 20 | 
            +
              <<: *development
         | 
| 21 | 
            +
             | 
| 22 | 
            +
            production:
         | 
| 23 | 
            +
              <<: *defaults
         | 
| 24 | 
            +
              url: 'https://api.ebay.com/wsapi'
         | 
| 25 | 
            +
              preload: true
         | 
    
        data/ebay_client.gemspec
    ADDED
    
    | @@ -0,0 +1,29 @@ | |
| 1 | 
            +
            # -*- encoding: utf-8 -*-
         | 
| 2 | 
            +
            $:.push File.expand_path("../lib", __FILE__)
         | 
| 3 | 
            +
            require "ebay_client/version"
         | 
| 4 | 
            +
             | 
| 5 | 
            +
            Gem::Specification.new do |s|
         | 
| 6 | 
            +
              s.name        = "ebay_client"
         | 
| 7 | 
            +
              s.version     = EbayClient::VERSION
         | 
| 8 | 
            +
              s.platform    = Gem::Platform::RUBY
         | 
| 9 | 
            +
              s.date        = Time.now.strftime("%Y-%m-%d")
         | 
| 10 | 
            +
              s.authors     = ["Marian Theisen"]
         | 
| 11 | 
            +
              s.email       = 'marian.theisen@kayoom.com'
         | 
| 12 | 
            +
              s.summary     = "Ebay Trading API Client"
         | 
| 13 | 
            +
              s.homepage    = "http://github.com/kayoom/ebay_client"
         | 
| 14 | 
            +
              s.description = "Simple, lightweight eBay Trading API Client"
         | 
| 15 | 
            +
              s.license     = "MIT"
         | 
| 16 | 
            +
              s.metadata    = {
         | 
| 17 | 
            +
                'issue_tracker' => 'https://github.com/kayoom/ebay_client/issues'
         | 
| 18 | 
            +
              }
         | 
| 19 | 
            +
             | 
| 20 | 
            +
              s.files         = `git ls-files`.split("\n")
         | 
| 21 | 
            +
              s.test_files    = `git ls-files -- {test,spec,features}/*`.split("\n")
         | 
| 22 | 
            +
              s.executables   = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
         | 
| 23 | 
            +
              s.require_paths = ["lib"]
         | 
| 24 | 
            +
             | 
| 25 | 
            +
              s.add_dependency "activesupport", ">= 3.1.0"
         | 
| 26 | 
            +
              s.add_dependency "savon", "< 2.0.0"
         | 
| 27 | 
            +
             | 
| 28 | 
            +
              s.add_development_dependency "bundler"
         | 
| 29 | 
            +
            end
         | 
    
        data/lib/ebay_client.rb
    ADDED
    
    | @@ -0,0 +1,11 @@ | |
| 1 | 
            +
            require 'ebay_client/version'
         | 
| 2 | 
            +
            require 'ebay_client/engine' if defined?(::Rails)
         | 
| 3 | 
            +
             | 
| 4 | 
            +
            module EbayClient
         | 
| 5 | 
            +
              autoload :Configuration, 'ebay_client/configuration'
         | 
| 6 | 
            +
              autoload :Api, 'ebay_client/api'
         | 
| 7 | 
            +
              autoload :Endpoint, 'ebay_client/endpoint'
         | 
| 8 | 
            +
              autoload :Header, 'ebay_client/header'
         | 
| 9 | 
            +
              autoload :Request, 'ebay_client/request'
         | 
| 10 | 
            +
              autoload :Response, 'ebay_client/response'
         | 
| 11 | 
            +
            end
         | 
| @@ -0,0 +1,68 @@ | |
| 1 | 
            +
            require 'savon'
         | 
| 2 | 
            +
            require 'gyoku'
         | 
| 3 | 
            +
            require 'ebay_client/response'
         | 
| 4 | 
            +
             | 
| 5 | 
            +
            class EbayClient::Api < ActiveSupport::BasicObject
         | 
| 6 | 
            +
              attr_reader :configuration, :endpoint, :namespace, :header, :client, :calls
         | 
| 7 | 
            +
             | 
| 8 | 
            +
              def initialize configuration
         | 
| 9 | 
            +
                @configuration = configuration
         | 
| 10 | 
            +
                @endpoint = ::EbayClient::Endpoint.new configuration
         | 
| 11 | 
            +
                @namespace = :urn
         | 
| 12 | 
            +
                @header = ::EbayClient::Header.new configuration, namespace
         | 
| 13 | 
            +
                @client = ::Savon::Client.new configuration.wsdl_file
         | 
| 14 | 
            +
                @client.http.read_timeout = 600
         | 
| 15 | 
            +
                @calls = 0
         | 
| 16 | 
            +
             | 
| 17 | 
            +
                ::Gyoku.convert_symbols_to :camelcase
         | 
| 18 | 
            +
                create_methods if configuration.preload?
         | 
| 19 | 
            +
              end
         | 
| 20 | 
            +
             | 
| 21 | 
            +
              def dispatch name, body
         | 
| 22 | 
            +
                request = ::EbayClient::Request.new self, name, body
         | 
| 23 | 
            +
             | 
| 24 | 
            +
                @calls += 1
         | 
| 25 | 
            +
                begin
         | 
| 26 | 
            +
                  request.execute
         | 
| 27 | 
            +
                rescue ::EbayClient::Response::Error.for_code('218050') => e
         | 
| 28 | 
            +
                  @configuration.next_key!
         | 
| 29 | 
            +
                  request.execute
         | 
| 30 | 
            +
                end
         | 
| 31 | 
            +
              end
         | 
| 32 | 
            +
             | 
| 33 | 
            +
              def dispatch! name, body
         | 
| 34 | 
            +
                dispatch(name, body).payload!
         | 
| 35 | 
            +
              end
         | 
| 36 | 
            +
             | 
| 37 | 
            +
              def inspect
         | 
| 38 | 
            +
                "<EbayClient::Api>"
         | 
| 39 | 
            +
              end
         | 
| 40 | 
            +
              alias_method :to_s, :inspect
         | 
| 41 | 
            +
             | 
| 42 | 
            +
              protected
         | 
| 43 | 
            +
              def create_methods
         | 
| 44 | 
            +
                api_methods = ::Module.new
         | 
| 45 | 
            +
             | 
| 46 | 
            +
                client.wsdl.soap_actions.each do |action|
         | 
| 47 | 
            +
                  name = action.to_s.gsub(/e_bay_/, '_ebay_')
         | 
| 48 | 
            +
             | 
| 49 | 
            +
                  api_methods.send :define_method, name do |*args|
         | 
| 50 | 
            +
                    dispatch name, args.first
         | 
| 51 | 
            +
                  end
         | 
| 52 | 
            +
             | 
| 53 | 
            +
                  api_methods.send :define_method, name + '!' do |*args|
         | 
| 54 | 
            +
                    dispatch! name, args.first
         | 
| 55 | 
            +
                  end
         | 
| 56 | 
            +
                end
         | 
| 57 | 
            +
             | 
| 58 | 
            +
                api_methods.send :extend_object, self
         | 
| 59 | 
            +
              end
         | 
| 60 | 
            +
             | 
| 61 | 
            +
              def method_missing name, *args, &block
         | 
| 62 | 
            +
                if name.to_s[-1,1] == '!'
         | 
| 63 | 
            +
                  dispatch! name, args.first
         | 
| 64 | 
            +
                else
         | 
| 65 | 
            +
                  dispatch name, args.first
         | 
| 66 | 
            +
                end
         | 
| 67 | 
            +
              end
         | 
| 68 | 
            +
            end
         | 
| @@ -0,0 +1,79 @@ | |
| 1 | 
            +
            class EbayClient::Configuration
         | 
| 2 | 
            +
              class ApiKey
         | 
| 3 | 
            +
                attr_accessor :appid, :devid, :certid, :token
         | 
| 4 | 
            +
             | 
| 5 | 
            +
                def initialize key_values
         | 
| 6 | 
            +
                  key_values.each do |key, val|
         | 
| 7 | 
            +
                    instance_variable_set "@#{key}", val
         | 
| 8 | 
            +
                  end
         | 
| 9 | 
            +
                end
         | 
| 10 | 
            +
              end
         | 
| 11 | 
            +
             | 
| 12 | 
            +
              attr_accessor :version, :siteid, :routing, :url, :api_keys, :warning_level, :error_language, :current_key, :savon_log_level
         | 
| 13 | 
            +
             | 
| 14 | 
            +
              def initialize presets
         | 
| 15 | 
            +
                presets.each do |key, val|
         | 
| 16 | 
            +
                  instance_variable_set "@#{key}", val
         | 
| 17 | 
            +
                end
         | 
| 18 | 
            +
             | 
| 19 | 
            +
                @api_keys = @api_keys.map do |key_values|
         | 
| 20 | 
            +
                  ApiKey.new key_values
         | 
| 21 | 
            +
                end.shuffle
         | 
| 22 | 
            +
                @current_key = @api_keys.first
         | 
| 23 | 
            +
              end
         | 
| 24 | 
            +
             | 
| 25 | 
            +
              def next_key!
         | 
| 26 | 
            +
                i = @api_keys.index(@current_key) + 1
         | 
| 27 | 
            +
                i = 0 if i >= @api_keys.count
         | 
| 28 | 
            +
                @current_key = @api_keys[i]
         | 
| 29 | 
            +
              end
         | 
| 30 | 
            +
             | 
| 31 | 
            +
              def appid
         | 
| 32 | 
            +
                @current_key.appid
         | 
| 33 | 
            +
              end
         | 
| 34 | 
            +
             | 
| 35 | 
            +
              def devid
         | 
| 36 | 
            +
                @current_key.devid
         | 
| 37 | 
            +
              end
         | 
| 38 | 
            +
             | 
| 39 | 
            +
              def certid
         | 
| 40 | 
            +
                @current_key.certid
         | 
| 41 | 
            +
              end
         | 
| 42 | 
            +
             | 
| 43 | 
            +
              def token
         | 
| 44 | 
            +
                @current_key.token
         | 
| 45 | 
            +
              end
         | 
| 46 | 
            +
             | 
| 47 | 
            +
              def wsdl_file
         | 
| 48 | 
            +
                @wsdl_file ||= File.expand_path "../../../vendor/ebay/#{version}.wsdl", __FILE__
         | 
| 49 | 
            +
              end
         | 
| 50 | 
            +
             | 
| 51 | 
            +
              def preload?
         | 
| 52 | 
            +
                !!@preload
         | 
| 53 | 
            +
              end
         | 
| 54 | 
            +
             | 
| 55 | 
            +
              class << self
         | 
| 56 | 
            +
                def load file
         | 
| 57 | 
            +
                  defaults = load_defaults
         | 
| 58 | 
            +
                  configs = YAML.load_file file
         | 
| 59 | 
            +
             | 
| 60 | 
            +
                  configs.each_pair do |env, presets|
         | 
| 61 | 
            +
                    env_defaults = defaults[env] || {}
         | 
| 62 | 
            +
                    presets = presets || {}
         | 
| 63 | 
            +
             | 
| 64 | 
            +
                    configs[env] = new env_defaults.merge(presets)
         | 
| 65 | 
            +
                  end
         | 
| 66 | 
            +
             | 
| 67 | 
            +
                  configs
         | 
| 68 | 
            +
                end
         | 
| 69 | 
            +
             | 
| 70 | 
            +
                protected
         | 
| 71 | 
            +
                def load_defaults
         | 
| 72 | 
            +
                  YAML.load_file defaults_file
         | 
| 73 | 
            +
                end
         | 
| 74 | 
            +
             | 
| 75 | 
            +
                def defaults_file
         | 
| 76 | 
            +
                  File.expand_path '../../../config/defaults.yml', __FILE__
         | 
| 77 | 
            +
                end
         | 
| 78 | 
            +
              end
         | 
| 79 | 
            +
            end
         | 
| @@ -0,0 +1,22 @@ | |
| 1 | 
            +
            class EbayClient::Endpoint
         | 
| 2 | 
            +
              attr_reader :configuration
         | 
| 3 | 
            +
             | 
| 4 | 
            +
              def initialize configuration
         | 
| 5 | 
            +
                @configuration = configuration
         | 
| 6 | 
            +
              end
         | 
| 7 | 
            +
             | 
| 8 | 
            +
              def url_for action
         | 
| 9 | 
            +
                url_base + action.to_s
         | 
| 10 | 
            +
              end
         | 
| 11 | 
            +
             | 
| 12 | 
            +
              def url_base
         | 
| 13 | 
            +
                @url_base ||= [
         | 
| 14 | 
            +
                  configuration.url,
         | 
| 15 | 
            +
                  params_base
         | 
| 16 | 
            +
                ].join
         | 
| 17 | 
            +
              end
         | 
| 18 | 
            +
             | 
| 19 | 
            +
              def params_base
         | 
| 20 | 
            +
                @params_base ||= "?appid=#{configuration.appid}&siteid=#{configuration.siteid}&version=#{configuration.version}&routing=#{configuration.routing}&callname="
         | 
| 21 | 
            +
              end
         | 
| 22 | 
            +
            end
         | 
| @@ -0,0 +1,20 @@ | |
| 1 | 
            +
            module EbayClient
         | 
| 2 | 
            +
              mattr_accessor :api
         | 
| 3 | 
            +
             | 
| 4 | 
            +
              class Engine < ::Rails::Engine
         | 
| 5 | 
            +
                CONFIG_FILE_PATH = %w(config ebay_client.yml)
         | 
| 6 | 
            +
             | 
| 7 | 
            +
                initializer 'ebay_client.load_configuration' do
         | 
| 8 | 
            +
                  configurations = EbayClient::Configuration.load Rails.root.join(*CONFIG_FILE_PATH)
         | 
| 9 | 
            +
                  configuration = configurations[Rails.env]
         | 
| 10 | 
            +
             | 
| 11 | 
            +
                  EbayClient.api = EbayClient::Api.new configuration
         | 
| 12 | 
            +
             | 
| 13 | 
            +
                  ::Savon.configure do |config|
         | 
| 14 | 
            +
                    config.log = true
         | 
| 15 | 
            +
                    config.logger = Rails.logger
         | 
| 16 | 
            +
                    config.log_level = configuration.savon_log_level
         | 
| 17 | 
            +
                  end
         | 
| 18 | 
            +
                end
         | 
| 19 | 
            +
              end
         | 
| 20 | 
            +
            end
         | 
| @@ -0,0 +1,26 @@ | |
| 1 | 
            +
            class EbayClient::Header
         | 
| 2 | 
            +
              attr_reader :configuration, :namespace
         | 
| 3 | 
            +
             | 
| 4 | 
            +
              def initialize configuration, namespace
         | 
| 5 | 
            +
                @configuration = configuration
         | 
| 6 | 
            +
                @namespace = namespace
         | 
| 7 | 
            +
              end
         | 
| 8 | 
            +
             | 
| 9 | 
            +
              def to_hash
         | 
| 10 | 
            +
                {
         | 
| 11 | 
            +
                  ns_key(:RequesterCredentials) => {
         | 
| 12 | 
            +
                    ns_key(:eBayAuthToken) => configuration.token,
         | 
| 13 | 
            +
                    ns_key(:Credentials) => {
         | 
| 14 | 
            +
                      ns_key(:AppId) => configuration.appid,
         | 
| 15 | 
            +
                      ns_key(:DevId) => configuration.devid,
         | 
| 16 | 
            +
                      ns_key(:AuthCert) => configuration.certid
         | 
| 17 | 
            +
                    }
         | 
| 18 | 
            +
                  }
         | 
| 19 | 
            +
                }
         | 
| 20 | 
            +
              end
         | 
| 21 | 
            +
             | 
| 22 | 
            +
              protected
         | 
| 23 | 
            +
              def ns_key key
         | 
| 24 | 
            +
                "#{namespace}:#{key}"
         | 
| 25 | 
            +
              end
         | 
| 26 | 
            +
            end
         |