Class: Fripa::Client

Inherits:
Object
  • Object
show all
Defined in:
lib/fripa/client.rb

Constant Summary collapse

API_PATH =
"/ipa/session/json"
API_VERSION =
"2.251"

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(username:, password:, config: nil) ⇒ Client

Returns a new instance of Client.



14
15
16
17
18
19
# File 'lib/fripa/client.rb', line 14

def initialize(username:, password:, config: nil)
  @config = config || Fripa.config
  @username = username
  @password = password
  @session_cookie = authenticator.login!
end

Instance Attribute Details

#configObject (readonly)

Returns the value of attribute config.



11
12
13
# File 'lib/fripa/client.rb', line 11

def config
  @config
end

#passwordObject (readonly)

Returns the value of attribute password.



11
12
13
# File 'lib/fripa/client.rb', line 11

def password
  @password
end

Returns the value of attribute session_cookie.



12
13
14
# File 'lib/fripa/client.rb', line 12

def session_cookie
  @session_cookie
end

#usernameObject (readonly)

Returns the value of attribute username.



11
12
13
# File 'lib/fripa/client.rb', line 11

def username
  @username
end

Instance Method Details

#authenticatorObject



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

def authenticator
  @authenticator ||= Authenticator.new(self)
end

#call(method, args = [], options = {}) ⇒ Object

Raises:



37
38
39
40
41
42
43
# File 'lib/fripa/client.rb', line 37

def call(method, args = [], options = {})
  response = perform_request(method, args, options)

  raise ConnectionError, "API call failed: #{response.status}" unless response.success?

  parse_response(response)
end

#groupsObject



25
26
27
# File 'lib/fripa/client.rb', line 25

def groups
  @groups ||= Resources::Group.new(self)
end

#usersObject



21
22
23
# File 'lib/fripa/client.rb', line 21

def users
  @users ||= Resources::User.new(self)
end

#vaultObject



29
30
31
# File 'lib/fripa/client.rb', line 29

def vault
  @vault ||= Resources::Vault.new(self)
end