1.8 KiB
1.8 KiB
City and Ward API Implementation - Complete Guide
Files Created ✅
- ✅
lib/features/account/domain/entities/city.dart - ✅
lib/features/account/domain/entities/ward.dart - ✅
lib/features/account/data/models/city_model.dart - ✅
lib/features/account/data/models/ward_model.dart - ✅ Updated
lib/core/constants/storage_constants.dart- Added
cityBoxandwardBox - Added
cityModel = 31andwardModel = 32 - Shifted all enum IDs by +2
- Added
Implementation Status
Completed:
- ✅ Domain entities (City, Ward)
- ✅ Hive models with type adapters
- ✅ Storage constants updated
- ✅ Build runner generated .g.dart files
Remaining (Need to implement):
- Remote Datasource -
lib/features/account/data/datasources/location_remote_datasource.dart - Local Datasource -
lib/features/account/data/datasources/location_local_datasource.dart - Repository Interface -
lib/features/account/domain/repositories/location_repository.dart - Repository Implementation -
lib/features/account/data/repositories/location_repository_impl.dart - Providers -
lib/features/account/presentation/providers/location_provider.dart - Update AddressFormPage to use the providers
API Endpoints (from docs/auth.sh)
Get Cities:
POST /api/method/frappe.client.get_list
Body: {
"doctype": "City",
"fields": ["city_name","name","code"],
"limit_page_length": 0
}
Get Wards (filtered by city):
POST /api/method/frappe.client.get_list
Body: {
"doctype": "Ward",
"fields": ["ward_name","name","code"],
"filters": {"city": "96"},
"limit_page_length": 0
}
Offline-First Strategy
- Cities: Cache in Hive, refresh from API periodically
- Wards: Load from API when city selected, cache per city
Would you like me to generate the remaining implementation files now?