module GunBroker

Constants

VERSION
WEB_URL
WEB_URL_SANDBOX

Public Class Methods

base_url(api: true) click to toggle source

Sets the developer key obtained from GunBroker.com. @param api [Boolean] whether to use api endpoint or public website endpoint

# File lib/gun_broker.rb, line 21
def self.base_url(api: true)
  if sandbox?
    return API::ROOT_URL_SANDBOX if api
    WEB_URL_SANDBOX
  else
    return API::ROOT_URL if api
    WEB_URL
  end
end
dev_key() click to toggle source

Returns the set developer key, or raises GunBroker::Error if not set. @raise [GunBroker::Error] If the {.dev_key} has not been set. @return [String] The developer key.

# File lib/gun_broker.rb, line 40
def self.dev_key
  raise GunBroker::Error.new('GunBroker developer key not set.') unless dev_key_present?
  @@dev_key
end
dev_key=(_dev_key) click to toggle source

Sets the developer key obtained from GunBroker.com. @param dev_key [String]

# File lib/gun_broker.rb, line 33
def self.dev_key=(_dev_key)
  @@dev_key = _dev_key
end
proxy_url() click to toggle source

Fully-qualified URL for remote proxy (including host, port, user, and password) @return [String] Defaults to `nil`.

# File lib/gun_broker.rb, line 53
def self.proxy_url
  defined?(@@proxy_url) ? @@proxy_url : nil
end
proxy_url=(_proxy_url) click to toggle source

Set URL for remote proxy (including host, port, user, and password) @return [String] Defaults to `nil`.

# File lib/gun_broker.rb, line 47
def self.proxy_url=(_proxy_url)
  @@proxy_url = _proxy_url
end
proxy_url?() click to toggle source

Convenience method for finding out if a proxy_url has been set @return [Boolean] Defaults to `false`.

# File lib/gun_broker.rb, line 59
def self.proxy_url?
  defined?(@@proxy_url) && ! @@proxy_url.nil? || false
end
sandbox() click to toggle source

If `true`, this library will use the 'sandbox' GunBroker API. @return [Boolean] Defaults to `false`.

# File lib/gun_broker.rb, line 71
def self.sandbox
  defined?(@@sandbox) ? @@sandbox : false
end
sandbox=(_sandbox) click to toggle source

Determines if this library will use the production API or the 'sandbox' API. @param sandbox [Boolean]

# File lib/gun_broker.rb, line 65
def self.sandbox=(_sandbox)
  @@sandbox = _sandbox
end
sandbox?() click to toggle source

An alias to {.sandbox} method

# File lib/gun_broker.rb, line 76
def self.sandbox?
  sandbox
end
time() click to toggle source

Returns a hash containing the time on GunBroker's servers in UTC and the current version of the GunBroker API.

For example:

{
  "gunBrokerTime" => "2015-02-06T20:23:08Z",
  "gunBrokerVersion" => "6 4.4.2.12"
}

@return [Hash] Containing the time and API version.

# File lib/gun_broker.rb, line 91
def self.time
  GunBroker::API.get('/GunBrokerTime')
end
timeout() click to toggle source

Amount (in seconds) to wait before raising a GunBroker::Error::TimeoutError @return [Integer] Defaults to `30`.

# File lib/gun_broker.rb, line 103
def self.timeout
  defined?(@@timeout) ? @@timeout : 30
end
timeout=(value) click to toggle source

Determines how long to wait on the API until raising a GunBroker::Error::TimeoutError. @param value [Integer]

# File lib/gun_broker.rb, line 97
def self.timeout=(value)
  @@timeout = value
end

Private Class Methods

dev_key_present?() click to toggle source
# File lib/gun_broker.rb, line 109
def self.dev_key_present?
  defined?(@@dev_key) && !@@dev_key.nil? && !@@dev_key.empty?
end