Sha256: addf09ea8166558ea5dacd1a33a4952bfd1e4ddc13f7559d5d70fbd7a9b82a77

Contents?: true

Size: 668 Bytes

Versions: 1

Compression:

Stored size: 668 Bytes

Contents

require 'excon'
require 'ebay/config'
require 'ebay/parser'

module Ebay
  class Request
    %i(host path headers).each do |method|
      eval <<-DEF
        def self.#{method}(value = nil)
          value ? @#{method} = value : @#{method}
        end

        def #{method}
          @#{method} ||= self.class.send(:#{method})
        end
      DEF
    end

    def sandbox!
      return if host.include?('sandbox')
      host.sub!('ebay', 'sandbox.ebay')
    end

    def get(opts)
      response = connection.get(opts)
      Parser.new(response)
    end

    private

    def connection
      Excon.new("https://#{host}#{path}", headers: headers)
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
ebay-ruby-0.2.0 lib/ebay/request.rb