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

Class Method Details

.base_url(api: true) ⇒ Object

Sets the developer key obtained from GunBroker.com.

Parameters:

  • api (Boolean) (defaults to: true)

    whether to use api endpoint or public website endpoint



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_keyString

Returns the set developer key, or raises GunBroker::Error if not set.

Returns:

  • (String)

    The developer key.

Raises:



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.

Parameters:

  • dev_key (String)


33
34
35
# File 'lib/gun_broker.rb', line 33

def self.dev_key=(_dev_key)
  @@dev_key = _dev_key
end

.proxy_urlString

Fully-qualified URL for remote proxy (including host, port, user, and password)

Returns:

  • (String)

    Defaults to nil.



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)

Returns:

  • (String)

    Defaults to nil.



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

Returns:

  • (Boolean)

    Defaults to false.



59
60
61
# File 'lib/gun_broker.rb', line 59

def self.proxy_url?
  defined?(@@proxy_url) && ! @@proxy_url.nil? || false
end

.sandboxBoolean

If true, this library will use the 'sandbox' GunBroker API.

Returns:

  • (Boolean)

    Defaults to false.



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.

Parameters:

  • sandbox (Boolean)


65
66
67
# File 'lib/gun_broker.rb', line 65

def self.sandbox=(_sandbox)
  @@sandbox = _sandbox
end

.sandbox?Boolean

An alias to sandbox method

Returns:

  • (Boolean)


76
77
78
# File 'lib/gun_broker.rb', line 76

def self.sandbox?
  sandbox
end

.timeHash

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"
}

Returns:

  • (Hash)

    Containing the time and API version.



91
92
93
# File 'lib/gun_broker.rb', line 91

def self.time
  GunBroker::API.get('/GunBrokerTime')
end

.timeoutInteger

Amount (in seconds) to wait before raising a GunBroker::Error::TimeoutError

Returns:

  • (Integer)

    Defaults to 30.



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.

Parameters:

  • value (Integer)


97
98
99
# File 'lib/gun_broker.rb', line 97

def self.timeout=(value)
  @@timeout = value
end