Class: ContextIO::Lite::User
- Inherits:
-
Object
- Object
- ContextIO::Lite::User
- Includes:
- API::Resource
- Defined in:
- lib/contextio/lite/user.rb
Instance Attribute Summary collapse
- #created_at ⇒ Object readonly
-
#first_name ⇒ String
readonly
The account holder’s first name.
-
#id ⇒ String
readonly
The id assigned to this account by Context.IO.
-
#last_name ⇒ String
readonly
The account holder’s last name.
-
#username ⇒ String
readonly
The username assigned to this account by Context.IO.
Attributes included from API::Resource
#api, #api_attributes, #primary_key, #resource_url, #with_constraints
Instance Method Summary collapse
- #delete ⇒ Object
-
#update(options = {}) ⇒ Object
Updates the account.
Methods included from API::Resource
Instance Attribute Details
#created_at ⇒ Object (readonly)
28 29 30 |
# File 'lib/contextio/lite/user.rb', line 28 def created_at @created_at ||= Time.at(created) end |
#first_name ⇒ String (readonly)
Returns The account holder’s first name.
23 |
# File 'lib/contextio/lite/user.rb', line 23 lazy_attributes :id, :email_addresses, :username, :created, :first_name, :last_name |
#id ⇒ String (readonly)
Returns The id assigned to this account by Context.IO.
23 |
# File 'lib/contextio/lite/user.rb', line 23 lazy_attributes :id, :email_addresses, :username, :created, :first_name, :last_name |
#last_name ⇒ String (readonly)
Returns The account holder’s last name.
23 |
# File 'lib/contextio/lite/user.rb', line 23 lazy_attributes :id, :email_addresses, :username, :created, :first_name, :last_name |
#username ⇒ String (readonly)
Returns The username assigned to this account by Context.IO.
23 |
# File 'lib/contextio/lite/user.rb', line 23 lazy_attributes :id, :email_addresses, :username, :created, :first_name, :last_name |
Instance Method Details
#delete ⇒ Object
56 57 58 |
# File 'lib/contextio/lite/user.rb', line 56 def delete api.request(:delete, resource_url)['success'] end |
#update(options = {}) ⇒ Object
Updates the account.
36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 |
# File 'lib/contextio/lite/user.rb', line 36 def update(={}) first_name = [:first_name] || ['first_name'] last_name = [:last_name] || ['last_name'] attrs = {} attrs[:first_name] = first_name if first_name attrs[:last_name] = last_name if last_name return nil if attrs.empty? it_worked = api.request(:post, resource_url, attrs)['success'] if it_worked @first_name = first_name || @first_name @last_name = last_name || @last_name end it_worked end |