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
| Field | Type | Description |
|---|---|---|
uniqueId | String? | Server-assigned unique identifier. Read-only. |
memberId | String? | Member ID within the organization. Read-only. |
firstName | String? | Given name. |
middleName | String? | Middle name. |
lastName | String? | Family name. |
email | String? | Email address. |
gender | String? | "M" or "F". |
dob | String? | Date of birth in ISO-8601 format (YYYY-MM-DD). |
dayPhone | String? | Daytime or landline phone number. |
cellPhone | String? | Mobile phone number. |
address | MemberAddress? | Structured mailing address. |
MemberAddress
| Field | Type | Description |
|---|---|---|
line1 | String? | Primary street address. |
line2 | String? | Apartment, suite, or unit number. |
city | String? | City or town. |
state | String? | Two-letter state code (e.g., CA). |
zipCode | String? | Postal or ZIP code. |
Get Profile
Retrieve the authenticated member's profile.
- Android (Kotlin)
- iOS (Swift)
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}")
}
}
do {
let profile = try await AFCore.shared.profile().get()
nameLabel.text = "\(profile.firstName ?? "") \(profile.lastName ?? "")"
emailLabel.text = profile.email ?? "Not provided"
} catch {
showError("Could not load profile: \(error)")
}
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.
- Android (Kotlin)
- iOS (Swift)
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"}")
}
}
let updates = MemberProfile(
firstName: "Alex",
cellPhone: "+1-555-0199",
address: MemberAddress(
line1: "456 Oak Avenue",
city: "San Diego",
state: "CA",
zipCode: "92101"
)
)
let result = await AFCore.shared.profile().update(profileData: updates)
if result.status {
showSuccess("Profile updated")
} else {
let errors = result.exception?.errors?.joined(separator: "\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.
| Field | Type | Description |
|---|---|---|
status | Boolean | true when the update succeeded. |
statusMessage | String? | Human-readable status or error message. |
messageCode | String? | Machine-readable code for the outcome, when provided. |
exception | AFException? | Present on failure; exception.errors holds server-side validation messages. |
queued | Boolean | true (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.
- Android (Kotlin)
- iOS (Swift)
lifecycleScope.launch {
try {
val results = AFCore.profile().searchColleagueProfiles(query = "Wellness", maxResults = 5)
colleaguesAdapter.submitList(results)
} catch (e: Exception) {
showError("Search failed: ${e.message}")
}
}
do {
let results = try await AFCore.shared.profile().searchColleagueProfiles(query: "Wellness", maxResults: 5)
updateColleagueList(results)
} catch {
showError("Search failed: \(error)")
}
ColleagueProfile
| Field | Type | Description |
|---|---|---|
firstName | String? | The colleague's first name. |
lastName | String? | The colleague's last name. |
isEnrolled | Boolean | Whether 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.
uniqueIdandmemberIdcannot be changed viaupdate(). They are set by the server during account creation.
Quick Reference
- Android (Kotlin)
- iOS (Swift)
// Android
AFCore.profile().get() // MemberProfile
AFCore.profile().update(profileData) // AFResult
AFCore.profile().searchColleagueProfiles(query, maxResults) // List<ColleagueProfile>
// iOS
try await AFCore.shared.profile().get() // MemberProfile
await AFCore.shared.profile().update(profileData: updates) // AFResult
try await AFCore.shared.profile().searchColleagueProfiles(query: q, maxResults: n) // [ColleagueProfile]