Class: Assonnato::User

Inherits:
Object
  • Object
show all
Defined in:
lib/assonnato/api/user.rb

Instance Method Summary collapse

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_tokenObject



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 (username, password)
  path = '/api/v1/user/login'
  data = { username: username, password: password }

  @client.post path, data
end

#logoutObject



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