Class: Lastpass::Client
- Inherits:
-
Object
- Object
- Lastpass::Client
- Defined in:
- lib/lastpass-api/client.rb
Overview
Main class to interact with Lastpass API
Instance Method Summary collapse
-
#accounts ⇒ Lastpass::Accounts
Interface to interacting with Lastpass accounts.
-
#groups ⇒ Lastpass::Groups
Interface to interacting with Lastpass groups.
-
#initialize(verbose: false) ⇒ Client
constructor
A new instance of Client.
-
#inspect ⇒ Object
private
Hide instance variables and values.
-
#logged_in? ⇒ Boolean
Check to see if currently logged into Lastpass.
-
#logged_out? ⇒ Boolean
Check to see if logged out of Lastpass.
-
#login(email:, password:) ⇒ Boolean
Login to Lastpass.
-
#logout ⇒ Boolean
Logout of Lastpass.
Constructor Details
Instance Method Details
#accounts ⇒ Lastpass::Accounts
Interface to interacting with Lastpass accounts
76 77 78 |
# File 'lib/lastpass-api/client.rb', line 76 def accounts Accounts.new end |
#groups ⇒ Lastpass::Groups
Interface to interacting with Lastpass groups
83 84 85 |
# File 'lib/lastpass-api/client.rb', line 83 def groups Groups.new end |
#inspect ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Hide instance variables and values
90 91 92 93 |
# File 'lib/lastpass-api/client.rb', line 90 def inspect original_inspect = super original_inspect.split( ' ' ).first << '>' end |
#logged_in? ⇒ Boolean
Check to see if currently logged into Lastpass
60 61 62 63 64 |
# File 'lib/lastpass-api/client.rb', line 60 def logged_in? Cli.status.include? 'Logged in' rescue false end |
#logged_out? ⇒ Boolean
Check to see if logged out of Lastpass
69 70 71 |
# File 'lib/lastpass-api/client.rb', line 69 def logged_out? !logged_in? end |
#login(email:, password:) ⇒ Boolean
This is not thread safe. Only one login session can be active at a time.
If there is a valid active login session already when this is called, it will use that session rather than create a new one.
Login to Lastpass
31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/lastpass-api/client.rb', line 31 def login( email:, password: ) if logged_in? Cli.sync return true end response = Cli.login( email, password: password ) raise "Login failed! #{response}" unless response.include? 'Success' Cli.sync @password = nil # Clear out password true end |