UserService
core/services/profile_service.dart
Overview
Dio-backed client for the three customer-profile endpoints: GET /store/customers/me, POST /store/customers/me (update), GET /store/customers/me/personal-info.
User Flow
- getClientInfo → CustomerProfileResponse.fromJson.
- updateCustomerProfile → POST with the changed-fields-only request body.
- getPersonalInfo → PersonalInfoResponse.fromJson.
Cases & Edge Cases
- Every call carries authScope='customer' RequestTrace — Dio interceptor attaches the customer token even when the user is in freelancer mode.
- 401 from /store/customers/me is rethrown as 'Unauthorized' — the redirect guard will then bounce to /login.
- Error responses with HTML bodies are surfaced as 'Failed to fetch …' rather than the raw HTML.
Code References
- lib/src/core/services/profile_service.dart:9 // UserService
- lib/src/core/services/profile_service.dart:13 // updateCustomerProfile
- lib/src/core/services/profile_service.dart:49 // getClientInfo
- lib/src/core/services/profile_service.dart:114 // getPersonalInfo
API Calls
- GET
/store/customers/meno statusFetch the authenticated customer's full profile (identity + addresses + metadata).
ResponseCustomerProfileResponse { id, first_name, last_name, email, phone, addresses[], metadata }lib/src/features/shared/profile/profile_details.dart, profile_tab_page.dart, manage_profile.dart // preloadauth: customer.
- POST
/store/customers/meno statusUpdate the authenticated customer's profile (changed fields only).
RequestCustomerProfileRequest { first_name?, last_name?, phone?, addresses?: Address[], ... }ResponseCustomerProfileResponse
lib/src/features/shared/manage-profile/manage_profile.dart // Saveauth: customer. Partial-update semantics — only changed fields are sent.
- GET
/store/customers/me/personal-infono statusFetch a lighter profile slice used by header widgets (display name, avatar, role badges).
ResponsePersonalInfoResponse { displayName: string, photo: string, /* role-specific badges */ ... }lib/src/features/shared/profile/widgets/seaven_profile_header.dart, instagram_profile_header.dartauth: customer.
Notes
Despite being named UserService, the class only knows the customer endpoints — seller profile reads live in VendorService (see seller features). GET /vendor/sellers/me is consumed by userProfileIdsProvider when role=freelancer.