Class: Devrant::Users
- Inherits:
-
Object
show all
- Includes:
- Devrant, HTTParty
- Defined in:
- lib/devrant/users.rb
Constant Summary
Constants included
from Devrant
VERSION
Instance Attribute Summary collapse
Instance Method Summary
collapse
Methods included from Devrant
#extend_request, #structuralize
Instance Attribute Details
#parent ⇒ Object
Returns the value of attribute parent.
6
7
8
|
# File 'lib/devrant/users.rb', line 6
def parent
@parent
end
|
Instance Method Details
#authenticate(username, password) ⇒ Object
24
25
26
27
28
29
30
|
# File 'lib/devrant/users.rb', line 24
def authenticate(username, password)
auth_token = structuralize(self.class.post("/users/auth-token", extend_request(:body, {username: username, password: password}))).auth_token
return auth_token unless auth_token.nil?
raise ArgumentError.new("Could not authenticate user #{username}")
end
|
#get_user_by_id(id) ⇒ Object
8
9
10
11
12
13
14
|
# File 'lib/devrant/users.rb', line 8
def get_user_by_id(id)
user = structuralize(self.class.get("/users/#{id}")).profile
return user unless user.nil?
raise ArgumentError.new("No user found for id #{id}")
end
|
#get_user_id(username) ⇒ Object
16
17
18
19
20
21
22
|
# File 'lib/devrant/users.rb', line 16
def get_user_id(username)
id = structuralize(self.class.get('/get-user-id', extend_request(:query, {username: username}))).user_id
return id unless id.nil?
raise ArgumentError.new("No user called #{username} found.")
end
|