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

Instance Method Details

#accountHash

Get the current

Examples:

{
  "email" => "[email protected]",
  "tz" => -28800000,
  "name" => "Drisha",
  "firstname" => "Drisha",
  "lastname" => "Wabudeya",
  "gender" => "FEMALE",
  "gender_other" => "",
  "height" => 160,
  "weight" => 68000,
  "created" => 1420099200000,
  "last_modified" => 1420099200000,
  "email_verified" => true,
  "profile_photo" => nil,
  "ext_id" => "fded667b-9e91-43f5-91de-258ac1fee9c2",
  "dob" => "1990-01-01",
  "id" => "fded667b-9e91-43f5-91de-258ac1fee9c2"
}

Returns:

  • (Hash)


32
33
34
# File 'lib/hello_sense/account.rb', line 32

def 
  get('/v1/account')
end

#create_account(data) ⇒ Object

Parameters:

  • data (Hash)

See Also:



40
41
42
# File 'lib/hello_sense/account.rb', line 40

def (data)
  put('/v1/account', data)
end

#current_timezoneHash

Examples:

{
  "timezone_offset" => -25200000,
  "timezone_id" => "America/Los_Angeles"
}

Returns:

  • (Hash)


116
117
118
# File 'lib/hello_sense/account.rb', line 116

def current_timezone
  get('/v1/timezone')
end

#delete_profile_pictureObject



77
78
79
# File 'lib/hello_sense/account.rb', line 77

def delete_profile_picture
  delete('/v1/photo/profile')
end

#preferencesHash

Examples:

{
  "TIME_TWENTY_FOUR_HOUR" => true,
  "PUSH_SCORE" => true,
  "WEIGHT_METRIC" => false,
  "TEMP_CELSIUS" => true,
  "HEIGHT_METRIC" => false,
  "ENHANCED_AUDIO" => true,
  "PUSH_ALERT_CONDITIONS" => true
}

Returns:

  • (Hash)


65
66
67
# File 'lib/hello_sense/account.rb', line 65

def preferences
  get('/v2/account/preferences')
end

#update_account(data) ⇒ Object

Parameters:

  • data (Hash)

See Also:



48
49
50
# File 'lib/hello_sense/account.rb', line 48

def (data)
  post('/v1/account', data)
end

#update_email(email) ⇒ Object

Returns XXX.

Parameters:

  • email (String)

    the new email address for the account

Returns:

  • XXX

Raises:



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 = .merge('email' => email)

  post('/v1/account/email', data)
end

#update_password(current_password, new_password) ⇒ Object

Note:

Examples:

client.update_password('My super secure password!',
                       'My even better new password (my second)!')

Parameters:

  • current_password (String)

    the user’s current password

  • new_password (String)

    the new password to use

Raises:



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