Class: Assonnato::User
- Inherits:
-
Object
- Object
- Assonnato::User
- Defined in:
- lib/assonnato/api/user.rb
Instance Method Summary collapse
- #csrf_token ⇒ Object
-
#initialize(client) ⇒ User
constructor
A new instance of User.
- #login(username, password) ⇒ Object
- #logout ⇒ Object
Constructor Details
#initialize(client) ⇒ User
Returns a new instance of User.
11 12 13 |
# File 'lib/assonnato/api/user.rb', line 11 def initialize(client) @client = client end |
Instance Method Details
#csrf_token ⇒ Object
29 30 31 32 33 |
# File 'lib/assonnato/api/user.rb', line 29 def csrf_token path = '/api/v1/user/csrf_token' @client.get(path)['message'] end |
#login(username, password) ⇒ Object
15 16 17 18 19 20 |
# File 'lib/assonnato/api/user.rb', line 15 def login(username, password) path = '/api/v1/user/login' data = { username: username, password: password } @client.post path, data end |
#logout ⇒ Object
22 23 24 25 26 27 |
# File 'lib/assonnato/api/user.rb', line 22 def logout path = '/api/v1/user/logout' data = { _csrf: @client.user.csrf_token } @client.post path, data end |