arch-atlas

UserService

core/services/profile_service.dart

data

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

  1. getClientInfo → CustomerProfileResponse.fromJson.
  2. updateCustomerProfile → POST with the changed-fields-only request body.
  3. 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 status

    Fetch the authenticated customer's full profile (identity + addresses + metadata).

    Response
    CustomerProfileResponse { id, first_name, last_name, email, phone, addresses[], metadata }
    lib/src/features/shared/profile/profile_details.dart, profile_tab_page.dart, manage_profile.dart // preload

    auth: customer.

  • POST/store/customers/meno status

    Update the authenticated customer's profile (changed fields only).

    Request
    CustomerProfileRequest { first_name?, last_name?, phone?, addresses?: Address[], ... }
    Response
    CustomerProfileResponse
    lib/src/features/shared/manage-profile/manage_profile.dart // Save

    auth: customer. Partial-update semantics — only changed fields are sent.

  • GET/store/customers/me/personal-infono status

    Fetch a lighter profile slice used by header widgets (display name, avatar, role badges).

    Response
    PersonalInfoResponse { displayName: string, photo: string, /* role-specific badges */ ... }
    lib/src/features/shared/profile/widgets/seaven_profile_header.dart, instagram_profile_header.dart

    auth: 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.