Module: Sense::Account
- Included in:
- Client
- Defined in:
- lib/hello_sense/account.rb
Constant Summary collapse
- EMAIL_PATTERN =
/^.+@.+\\..+$/- MIN_PASSWORD_LENGTH =
6
Instance Method Summary collapse
-
#account ⇒ Hash
Get the current.
- #create_account(data) ⇒ Object
- #current_timezone ⇒ Hash
- #delete_profile_picture ⇒ Object
- #preferences ⇒ Hash
- #update_account(data) ⇒ Object
-
#update_email(email) ⇒ Object
XXX.
- #update_password(current_password, new_password) ⇒ Object
- #update_photo(data) ⇒ Object
- #update_preferences(data) ⇒ Object
- #update_timezone(data) ⇒ Object
Instance Method Details
#account ⇒ Hash
Get the current
32 33 34 |
# File 'lib/hello_sense/account.rb', line 32 def account get('/v1/account') end |
#create_account(data) ⇒ Object
40 41 42 |
# File 'lib/hello_sense/account.rb', line 40 def create_account(data) put('/v1/account', data) end |
#current_timezone ⇒ Hash
116 117 118 |
# File 'lib/hello_sense/account.rb', line 116 def current_timezone get('/v1/timezone') end |
#delete_profile_picture ⇒ Object
77 78 79 |
# File 'lib/hello_sense/account.rb', line 77 def delete_profile_picture delete('/v1/photo/profile') end |
#preferences ⇒ Hash
65 66 67 |
# File 'lib/hello_sense/account.rb', line 65 def preferences get('/v2/account/preferences') end |
#update_account(data) ⇒ Object
48 49 50 |
# File 'lib/hello_sense/account.rb', line 48 def update_account(data) post('/v1/account', data) end |
#update_email(email) ⇒ Object
Returns XXX.
84 85 86 87 88 89 90 |
# File 'lib/hello_sense/account.rb', line 84 def update_email(email) raise InvalidEmailError if !normalize(email).match(EMAIL_PATTERN) data = account.merge('email' => email) post('/v1/account/email', data) end |
#update_password(current_password, new_password) ⇒ Object
Note:
101 102 103 104 105 106 |
# File 'lib/hello_sense/account.rb', line 101 def update_password(current_password, new_password) raise InvalidPasswordError if normalize(new_password).length < MIN_PASSWORD_LENGTH post('/v1/account/password', currentPassword: current_password, newPassword: new_password) end |
#update_photo(data) ⇒ Object
73 74 75 |
# File 'lib/hello_sense/account.rb', line 73 def update_photo(data) post('/v1/photo/profile', data) end |
#update_preferences(data) ⇒ Object
69 70 71 |
# File 'lib/hello_sense/account.rb', line 69 def update_preferences(data) put('/v2/account/preferences', data) end |
#update_timezone(data) ⇒ Object
120 121 122 |
# File 'lib/hello_sense/account.rb', line 120 def update_timezone(data) post('/v1/timezone', data) end |