Sha256: 5c685a430286b1b7a5bcc37c440c3de663cd0ff0d98b44f679e3cfc7e724202a
Contents?: true
Size: 1.48 KB
Versions: 1
Compression:
Stored size: 1.48 KB
Contents
# frozen_string_literal: true require 'http' module Ebay # Adds an HTTP client and ability to switch to the eBay Sandbox environment module Requestable class << self private def included(base) class << base attr_accessor :endpoint end end end # @return [HTTP::Client] attr_writer :http # @!attribute [r] http # @return [HTTP::Client] def http @http ||= HTTP::Client.new end # @!attribute [r] endpoint # @return [String] def endpoint @endpoint ||= self.class.endpoint end # Switches to the eBay Sandbox environment # # @return [self] def sandbox @endpoint = endpoint.sub('ebay', 'sandbox.ebay') self end # Flags request as persistent # # @param [Integer] timeout # @return [self] def persistent(timeout: 5) self.http = http.persistent(endpoint, timeout: timeout) self end # @!method use(*features) # Turns on {https://github.com/httprb/http HTTP} features # # @param features # @return [self] # # @!method via(*proxy) # Makes a request through an HTTP proxy # # @param [Array] proxy # @raise [HTTP::Request::Error] if HTTP proxy is invalid # @return [self] %i[timeout via through headers use].each do |method_name| define_method(method_name) do |*args, &block| self.http = http.send(method_name, *args, &block) self end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
ebay-ruby-0.3.4 | lib/ebay/requestable.rb |