Class: Tick::Session
Constant Summary collapse
- SERVICE_NAME =
"Tick"
Instance Attribute Summary collapse
-
#company ⇒ Object
Returns the value of attribute company.
-
#email ⇒ Object
Returns the value of attribute email.
-
#first_name ⇒ Object
Returns the value of attribute first_name.
-
#last_name ⇒ Object
Returns the value of attribute last_name.
-
#password ⇒ Object
Returns the value of attribute password.
Attributes inherited from Base
#api_name, #api_path, #created_at, #id, #updated_at
Class Method Summary collapse
Instance Method Summary collapse
Methods inherited from Base
api_name, api_path, list, #set_properties_from_xml_node
Instance Attribute Details
#company ⇒ Object
Returns the value of attribute company.
7 8 9 |
# File 'lib/tick/session.rb', line 7 def company @company end |
#email ⇒ Object
Returns the value of attribute email.
7 8 9 |
# File 'lib/tick/session.rb', line 7 def email @email end |
#first_name ⇒ Object
Returns the value of attribute first_name.
7 8 9 |
# File 'lib/tick/session.rb', line 7 def first_name @first_name end |
#last_name ⇒ Object
Returns the value of attribute last_name.
7 8 9 |
# File 'lib/tick/session.rb', line 7 def last_name @last_name end |
#password ⇒ Object
Returns the value of attribute password.
7 8 9 |
# File 'lib/tick/session.rb', line 7 def password @password end |
Class Method Details
.create(params, &block) ⇒ Object
76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 |
# File 'lib/tick/session.rb', line 76 def self.create(params, &block) url = "https://#{params[:company]}.tickspot.com/api/users" company = params[:company] params.delete(:company) request_manager.GET(url, parameters:params, success:lambda{|operation, result| # TODO: Save first and last name @current = new @current.company = company @current.email = params[:email] @current.password = params[:password] block.call(@current) if block }, failure:lambda{|operation, error| ap error block.call(nil) if block }) self end |
.current ⇒ Object
97 98 99 |
# File 'lib/tick/session.rb', line 97 def self.current @current || new end |
.current=(value) ⇒ Object
101 102 103 |
# File 'lib/tick/session.rb', line 101 def self.current=(value) @current = value end |
.logged_in? ⇒ Boolean
105 106 107 |
# File 'lib/tick/session.rb', line 105 def self.logged_in? (current.company && current.email && current.password) ? true : false end |
Instance Method Details
#destroy ⇒ Object
22 23 24 25 26 27 |
# File 'lib/tick/session.rb', line 22 def destroy storage.removeObjectForKey("company") storage.removeObjectForKey("email") SSKeychain.deletePasswordForService(SERVICE_NAME, account:email) self.class.current = nil end |
#storage ⇒ Object
72 73 74 |
# File 'lib/tick/session.rb', line 72 def storage NSUserDefaults.standardUserDefaults end |