Class: Fripa::Client
- Inherits:
-
Object
- Object
- Fripa::Client
- Defined in:
- lib/fripa/client.rb
Constant Summary collapse
- API_PATH =
"/ipa/session/json"- API_VERSION =
"2.251"
Instance Attribute Summary collapse
-
#config ⇒ Object
readonly
Returns the value of attribute config.
-
#password ⇒ Object
readonly
Returns the value of attribute password.
-
#session_cookie ⇒ Object
Returns the value of attribute session_cookie.
-
#username ⇒ Object
readonly
Returns the value of attribute username.
Instance Method Summary collapse
- #authenticator ⇒ Object
- #call(method, args = [], options = {}) ⇒ Object
- #groups ⇒ Object
-
#initialize(username:, password:, config: nil) ⇒ Client
constructor
A new instance of Client.
- #users ⇒ Object
- #vault ⇒ Object
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
#config ⇒ Object (readonly)
Returns the value of attribute config.
11 12 13 |
# File 'lib/fripa/client.rb', line 11 def config @config end |
#password ⇒ Object (readonly)
Returns the value of attribute password.
11 12 13 |
# File 'lib/fripa/client.rb', line 11 def password @password end |
#session_cookie ⇒ Object
Returns the value of attribute session_cookie.
12 13 14 |
# File 'lib/fripa/client.rb', line 12 def @session_cookie end |
#username ⇒ Object (readonly)
Returns the value of attribute username.
11 12 13 |
# File 'lib/fripa/client.rb', line 11 def username @username end |
Instance Method Details
#authenticator ⇒ Object
33 34 35 |
# File 'lib/fripa/client.rb', line 33 def authenticator @authenticator ||= Authenticator.new(self) end |
#call(method, args = [], options = {}) ⇒ Object
37 38 39 40 41 42 43 |
# File 'lib/fripa/client.rb', line 37 def call(method, args = [], = {}) response = perform_request(method, args, ) raise ConnectionError, "API call failed: #{response.status}" unless response.success? parse_response(response) end |
#groups ⇒ Object
25 26 27 |
# File 'lib/fripa/client.rb', line 25 def groups @groups ||= Resources::Group.new(self) end |