Class: QuickBlox::UserSession
- Defined in:
- lib/quick_blox/user_session.rb
Instance Attribute Summary collapse
-
#user ⇒ Object
Returns the value of attribute user.
Attributes inherited from Session
#_id, #application_id, #created_at, #device_id, #id, #nonce, #token, #ts, #updated_at, #user_id
Class Method Summary collapse
Instance Method Summary collapse
Methods inherited from Session
Constructor Details
This class inherits a constructor from QuickBlox::Session
Instance Attribute Details
#user ⇒ Object
Returns the value of attribute user.
4 5 6 |
# File 'lib/quick_blox/user_session.rb', line 4 def user @user end |
Class Method Details
.destroy_by_token(token) ⇒ Object
56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 |
# File 'lib/quick_blox/user_session.rb', line 56 def self.destroy_by_token(token) RestClient::Request.execute( method: :delete, url: "#{ QuickBlox.configuration.host }/login.json", headers: { 'Content-Type': 'application/json', 'QuickBlox-REST-API-Version': QuickBlox.configuration.api_version, 'QB-Token': token } ){ |response, request, result| case result.code.to_i when 200 else response = JSON.parse(response) raise QuickBlox::Exceptions::Response, response['errors'] end } end |
.new(application_session, options = {}) ⇒ Object
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/quick_blox/user_session.rb', line 6 def self.new(application_session, ={}) raise QuickBlox::Exceptions::MissingConfiguration unless QuickBlox.configuration RestClient::Request.execute( method: :post, url: "#{ QuickBlox.configuration.host }/login.json", payload: { login: [:login], password: [:password] }.to_json, headers: { 'Content-Type': 'application/json', 'QuickBlox-REST-API-Version': QuickBlox.configuration.api_version, 'QB-Token': application_session.token } ){ |response, request, result| response = JSON.parse(response) case result.code.to_i when 200, 201, 202 user = QuickBlox::User.new response['user'].each do |k, v| user.instance_variable_set "@#{k}", v end else raise QuickBlox::Exceptions::Response, response['errors'] end } end |
Instance Method Details
#destroy(application_session) ⇒ Object
36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 |
# File 'lib/quick_blox/user_session.rb', line 36 def destroy(application_session) RestClient::Request.execute( method: :delete, url: "#{ QuickBlox.configuration.host }/login.json", headers: { 'Content-Type': 'application/json', 'QuickBlox-REST-API-Version': QuickBlox.configuration.api_version, 'QB-Token': application_session.token } ){ |response, request, result| case result.code.to_i when 200 else response = JSON.parse(response) raise QuickBlox::Exceptions::Response, response['errors'] end } end |