Module: GunBroker
- Defined in:
- lib/gun_broker.rb,
lib/gun_broker/api.rb,
lib/gun_broker/item.rb,
lib/gun_broker/user.rb,
lib/gun_broker/error.rb,
lib/gun_broker/order.rb,
lib/gun_broker/version.rb,
lib/gun_broker/category.rb,
lib/gun_broker/feedback.rb,
lib/gun_broker/response.rb,
lib/gun_broker/token_header.rb,
lib/gun_broker/items_as_page.rb,
lib/gun_broker/item/constants.rb,
lib/gun_broker/orders_as_page.rb,
lib/gun_broker/order/constants.rb,
lib/gun_broker/user/items_delegate.rb,
lib/gun_broker/user/orders_delegate.rb,
lib/gun_broker/user/items_as_pages_delegate.rb,
lib/gun_broker/user/orders_as_pages_delegate.rb
Defined Under Namespace
Modules: TokenHeader Classes: API, Category, Error, Feedback, Item, ItemsAsPage, Order, OrdersAsPage, Response, User
Constant Summary collapse
- WEB_URL =
"https://www.gunbroker.com"
- WEB_URL_SANDBOX =
"https://www.sandbox.gunbroker.com"
- VERSION =
"1.4.8"
Class Method Summary collapse
-
.base_url(api: true) ⇒ Object
Sets the developer key obtained from GunBroker.com.
-
.dev_key ⇒ String
Returns the set developer key, or raises GunBroker::Error if not set.
-
.dev_key=(_dev_key) ⇒ Object
Sets the developer key obtained from GunBroker.com.
-
.proxy_url ⇒ String
Fully-qualified URL for remote proxy (including host, port, user, and password).
-
.proxy_url=(_proxy_url) ⇒ String
Set URL for remote proxy (including host, port, user, and password).
-
.proxy_url? ⇒ Boolean
Convenience method for finding out if a proxy_url has been set.
-
.sandbox ⇒ Boolean
If
true
, this library will use the 'sandbox' GunBroker API. -
.sandbox=(_sandbox) ⇒ Object
Determines if this library will use the production API or the 'sandbox' API.
-
.sandbox? ⇒ Boolean
An alias to GunBroker.sandbox method.
-
.time ⇒ Hash
Returns a hash containing the time on GunBroker's servers in UTC and the current version of the GunBroker API.
-
.timeout ⇒ Integer
Amount (in seconds) to wait before raising a GunBroker::Error::TimeoutError.
-
.timeout=(value) ⇒ Object
Determines how long to wait on the API until raising a GunBroker::Error::TimeoutError.
Class Method Details
.base_url(api: true) ⇒ Object
Sets the developer key obtained from GunBroker.com.
21 22 23 24 25 26 27 28 29 |
# 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 ⇒ String
Returns the set developer key, or raises GunBroker::Error if not set.
40 41 42 43 |
# 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) ⇒ Object
Sets the developer key obtained from GunBroker.com.
33 34 35 |
# File 'lib/gun_broker.rb', line 33 def self.dev_key=(_dev_key) @@dev_key = _dev_key end |
.proxy_url ⇒ String
Fully-qualified URL for remote proxy (including host, port, user, and password)
53 54 55 |
# File 'lib/gun_broker.rb', line 53 def self.proxy_url defined?(@@proxy_url) ? @@proxy_url : nil end |
.proxy_url=(_proxy_url) ⇒ String
Set URL for remote proxy (including host, port, user, and password)
47 48 49 |
# File 'lib/gun_broker.rb', line 47 def self.proxy_url=(_proxy_url) @@proxy_url = _proxy_url end |
.proxy_url? ⇒ Boolean
Convenience method for finding out if a proxy_url has been set
59 60 61 |
# File 'lib/gun_broker.rb', line 59 def self.proxy_url? defined?(@@proxy_url) && ! @@proxy_url.nil? || false end |
.sandbox ⇒ Boolean
If true
, this library will use the 'sandbox' GunBroker API.
71 72 73 |
# File 'lib/gun_broker.rb', line 71 def self.sandbox defined?(@@sandbox) ? @@sandbox : false end |
.sandbox=(_sandbox) ⇒ Object
Determines if this library will use the production API or the 'sandbox' API.
65 66 67 |
# File 'lib/gun_broker.rb', line 65 def self.sandbox=(_sandbox) @@sandbox = _sandbox end |
.sandbox? ⇒ Boolean
An alias to sandbox method
76 77 78 |
# File 'lib/gun_broker.rb', line 76 def self.sandbox? sandbox end |
.time ⇒ Hash
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"
}
91 92 93 |
# File 'lib/gun_broker.rb', line 91 def self.time GunBroker::API.get('/GunBrokerTime') end |
.timeout ⇒ Integer
Amount (in seconds) to wait before raising a GunBroker::Error::TimeoutError
103 104 105 |
# File 'lib/gun_broker.rb', line 103 def self.timeout defined?(@@timeout) ? @@timeout : 30 end |
.timeout=(value) ⇒ Object
Determines how long to wait on the API until raising a GunBroker::Error::TimeoutError.
97 98 99 |
# File 'lib/gun_broker.rb', line 97 def self.timeout=(value) @@timeout = value end |