Class: Epitech::Api::Connection

Inherits:
Object
  • Object
show all
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

BASE_URL, VERSION

Instance Method Summary collapse

Methods included from SearchApi

#get_logins, #search

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

Parameters:

  • login (String)

    Your ionis login

  • pwd (String)

    Your ionis password



17
18
19
20
21
# File 'lib/api/connection.rb', line 17

def initialize(, pwd)
  @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.

Returns:

  • (Boolean)

    True if the connection is established, false otherwise



37
38
39
# File 'lib/api/connection.rb', line 37

def is_connected?
  @connected
end