Skip to main content

Profile

The Profile module provides access to the authenticated member's personal data. You can retrieve the current profile and update editable fields.


Data Model

MemberProfile

FieldTypeDescription
uniqueIdString?Server-assigned unique identifier. Read-only.
memberIdString?Member ID within the organization. Read-only.
firstNameString?Given name.
middleNameString?Middle name.
lastNameString?Family name.
emailString?Email address.
genderString?"M" or "F".
dobString?Date of birth in ISO-8601 format (YYYY-MM-DD).
dayPhoneString?Daytime or landline phone number.
cellPhoneString?Mobile phone number.
addressMemberAddress?Structured mailing address.

MemberAddress

FieldTypeDescription
line1String?Primary street address.
line2String?Apartment, suite, or unit number.
cityString?City or town.
stateString?Two-letter state code (e.g., CA).
zipCodeString?Postal or ZIP code.

Get Profile

Retrieve the authenticated member's profile.

lifecycleScope.launch {
try {
val profile = AFCore.profile().get()
// Populate the UI with the member's data
nameField.text = "${profile.firstName} ${profile.lastName}"
emailField.text = profile.email ?: "Not provided"
} catch (e: Exception) {
showError("Could not load profile: ${e.message}")
}
}

Update Profile

Send a MemberProfile object with the fields you want to change. Only non-nil fields are updated server-side; omitted fields remain unchanged.

update() returns an AFResult, not the updated profile. Check result.status for success, and surface server-side validation errors via result.exception?.errors.

lifecycleScope.launch {
val updates = MemberProfile(
firstName = "Alex",
cellPhone = "+1-555-0199",
address = MemberAddress(
line1 = "456 Oak Avenue",
city = "San Diego",
state = "CA",
zipCode = "92101"
)
)
val result = AFCore.profile().update(profileData = updates)
if (result.status) {
showSuccess("Profile updated")
} else {
val errors = result.exception?.errors?.joinToString("\n") ?: result.statusMessage
showError("Update failed: ${errors ?: "Unknown error"}")
}
}

AFResult

update() resolves to an AFResult describing the outcome. For the full error-handling model, see Error Handling.

FieldTypeDescription
statusBooleantrue when the update succeeded.
statusMessageString?Human-readable status or error message.
messageCodeString?Machine-readable code for the outcome, when provided.
exceptionAFException?Present on failure; exception.errors holds server-side validation messages.
queuedBooleantrue (with status == true) when the change was accepted into the offline outbox and will be delivered later — no manual retry needed.

Search Colleagues

Look up colleague profiles within the member's organization (directory-style search). Returns a list of ColleagueProfile, which may be empty.

lifecycleScope.launch {
try {
val results = AFCore.profile().searchColleagueProfiles(query = "Wellness", maxResults = 5)
colleaguesAdapter.submitList(results)
} catch (e: Exception) {
showError("Search failed: ${e.message}")
}
}

ColleagueProfile

FieldTypeDescription
firstNameString?The colleague's first name.
lastNameString?The colleague's last name.
isEnrolledBooleanWhether the colleague is enrolled in the program.

Best Practices

  • Cache the profile locally to avoid redundant API calls. Refresh when the user navigates to the profile screen or pulls to refresh.
  • Validate inputs before submitting. Validate email format, phone number format, and ZIP code length on the client side to provide immediate feedback.
  • Handle read-only fields. uniqueId and memberId cannot be changed via update(). They are set by the server during account creation.

Quick Reference

// Android
AFCore.profile().get() // MemberProfile
AFCore.profile().update(profileData) // AFResult
AFCore.profile().searchColleagueProfiles(query, maxResults) // List<ColleagueProfile>