Class: CrowdRest::Session
- Inherits:
-
Object
- Object
- CrowdRest::Session
- Defined in:
- lib/crowd_rest/session.rb
Class Method Summary collapse
Class Method Details
.create(username, password) ⇒ Object
5 6 7 8 9 10 11 12 13 14 |
# File 'lib/crowd_rest/session.rb', line 5 def self.create(username, password) body = "<authentication-context> <username>#{username}</username> <password>#{password}</password> </authentication-context>" response = CrowdRest.post("/session", :body => body) normalize_response(response, 201) do |successful_response| successful_response.token = response['session']['token'] end end |
.find(token, options = {}) ⇒ Object
16 17 18 19 20 21 22 23 24 |
# File 'lib/crowd_rest/session.rb', line 16 def self.find(token, = {}) request_user = [:include] && [:include] == :user path = "/session/#{token}" path << "?expand=user" if request_user response = CrowdRest.get(path) normalize_response(response) do |successful_response| successful_response.user = response['session']['user'] end end |