Class: Epitech::Api::Connection
- Inherits:
-
Object
- Object
- Epitech::Api::Connection
- Includes:
- Epitech::Api, CheckApi, InfoApi, SearchApi
- Defined in:
- lib/api/connection.rb
Overview
Class provided to maintain a connection to the API
Constant Summary
Constants included from Epitech::Api
Instance Method Summary collapse
-
#call_api(opts = {}) ⇒ Object
Overloading of Epitech::Api::call_api, will use instance variables for auth_login and auth_password.
-
#connect! ⇒ Object
Try to connect to the API with the instance variables.
-
#initialize(login, pwd) ⇒ Boolean
constructor
Constructor.
-
#is_connected? ⇒ Boolean
True if the connection is established, false otherwise.
Methods included from SearchApi
Methods included from InfoApi
#get_infos, #get_login_from_uid
Methods included from CheckApi
#check_auth, #check_password, #is_login?
Constructor Details
#initialize(login, pwd) ⇒ Boolean
Constructor
17 18 19 20 21 |
# File 'lib/api/connection.rb', line 17 def initialize(login, pwd) @login = login @pwd = pwd connect! end |
Instance Method Details
#call_api(opts = {}) ⇒ Object
Overloading of Epitech::Api::call_api, will use instance variables for auth_login and auth_password
25 26 27 28 29 |
# File 'lib/api/connection.rb', line 25 def call_api(opts={}) opts[:auth_login] ||= @login opts[:auth_password] ||= @pwd super(opts) end |
#connect! ⇒ Object
Try to connect to the API with the instance variables
32 33 34 |
# File 'lib/api/connection.rb', line 32 def connect! @connected = check_auth end |
#is_connected? ⇒ Boolean
Returns True if the connection is established, false otherwise.
37 38 39 |
# File 'lib/api/connection.rb', line 37 def is_connected? @connected end |