class Epitech::Api::Connection

Class provided to maintain a connection to the API

Public Class Methods

new(login, pwd) click to toggle source

Constructor @param login [String] Your ionis login @param pwd [String] Your ionis password @return [Boolean] True if the connection was successful (Raise a Epitech::Api::Errors::AuthFail otherwise)

# File lib/api/connection.rb, line 17
def initialize(login, pwd)
  @login = login
  @pwd = pwd
  connect!
end

Public Instance Methods

call_api(opts={}) click to toggle source

Overloading of Epitech::Api::call_api, will use instance variables for auth_login and auth_password

Calls superclass method Epitech::Api#call_api
# File lib/api/connection.rb, line 25
def call_api(opts={})
  opts[:auth_login] ||= @login
  opts[:auth_password] ||= @pwd
  super(opts)
end
connect!() click to toggle source

Try to connect to the API with the instance variables

# File lib/api/connection.rb, line 32
def connect!
  @connected = check_auth
end
is_connected?() click to toggle source

@return True if the connection is established, false otherwise

# File lib/api/connection.rb, line 37
def is_connected?
  @connected
end