Class: UCLAPI::Client
- Inherits:
-
Object
- Object
- UCLAPI::Client
- Defined in:
- lib/uclapi/client.rb
Defined Under Namespace
Classes: BadRequestError, NotFoundError, Roombookings, Search, ServerError, UnauthorizedError
Constant Summary collapse
- ENDPOINT =
'uclapi.com'.freeze
Instance Attribute Summary collapse
-
#debug ⇒ Object
Returns the value of attribute debug.
-
#http ⇒ Object
Returns the value of attribute http.
-
#token ⇒ Object
Returns the value of attribute token.
Instance Method Summary collapse
- #get(path, params = {}) ⇒ Object
-
#initialize(options = {}) ⇒ Client
constructor
A new instance of Client.
- #roombookings ⇒ Object
- #search ⇒ Object
Constructor Details
#initialize(options = {}) ⇒ Client
Returns a new instance of Client.
15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/uclapi/client.rb', line 15 def initialize( = {}) @token = .fetch(:token) do ENV['UCLAPI_TOKEN'] || raise(KeyError, "Missing required argument: token") end @debug = ([:debug] || ENV['UCLAPI_DEBUG']) ? true : false @http = Net::HTTP.new(ENDPOINT, Net::HTTP.https_default_port) http.use_ssl = true http.set_debug_output $stderr if debug end |
Instance Attribute Details
#debug ⇒ Object
Returns the value of attribute debug.
13 14 15 |
# File 'lib/uclapi/client.rb', line 13 def debug @debug end |
#http ⇒ Object
Returns the value of attribute http.
13 14 15 |
# File 'lib/uclapi/client.rb', line 13 def http @http end |
#token ⇒ Object
Returns the value of attribute token.
13 14 15 |
# File 'lib/uclapi/client.rb', line 13 def token @token end |
Instance Method Details
#get(path, params = {}) ⇒ Object
35 36 37 38 39 |
# File 'lib/uclapi/client.rb', line 35 def get(path, params = {}) uri = uri_for(path, params) = Net::HTTP::Get.new(uri.request_uri) transmit() end |
#roombookings ⇒ Object
27 28 29 |
# File 'lib/uclapi/client.rb', line 27 def roombookings UCLAPI::Client::Roombookings.new(self) end |