ProvisionService (Customer-side)
core/services/provision_service.dart
Overview
Customer-facing counterpart that fetches /store/provisions — the public view of the same data the seller manages. Listed here because the seller features must understand how customers will see their published provisions.
User Flow
- getProvisions: paginated / filtered list — analogous to MarketplaceService.getProducts but for service-type.
- getProvisionsWithDistance: same shape with lat/lng/radius for /store/product-location.
- getProvisionById: single full provision with `*seller,*reviews` field selection.
- getProvisionSlots + getProvisionPolicy + getProvisionQuestions: feed the customer's booking flow.
Cases & Edge Cases
- Customer-side endpoints require status='published' on the backend — proposed/rejected provisions are invisible.
- getProvisionQuestions treats 404 as 'no questions configured' (per-provision optional).
- Mirroring fields: customer sees /policy as deposit/max-delay/rules — same shape the seller upserts via /vendor/bookings/policy.
Code References
- lib/src/core/services/provision_service.dart:8 // ProvisionService
- lib/src/core/services/provision_service.dart:12 // getProvisions
- lib/src/core/services/provision_service.dart:204 // getProvisionSlots
- lib/src/core/services/provision_service.dart:227 // getProvisionPolicy
API Calls
- GET
/store/provisionsno statusCustomer view of published provisions for the marketplace home / client grid tile.
RequestQuery: limit, offset, q?, category_id[i], collection_id[]?, tag_id[i]?, type_id[]?, order?, fields=*variants.calculated_price,*reviews,*reviews.customer
Response{ products: Product[] }lib/src/features/shared/provision_marketplace/views/provision_marketplace_home_screen.dart, lib/src/features/shared/home/presentation/widgets/first_page.dartauth: customer.
- GET
/store/product-locationno statusMap-driven nearby provisions search (lat/lng/radius).
RequestQuery: lat, lng, radius, q?, type_id[]?, category_id[i]
Response{ locations: Product[] /* location-shaped */ }lib/src/features/shared/map/*auth: customer.
- GET
/store/provisions/:id?fields=*variants.calculated_price,+variants.inventory_quantity,*seller,*reviews,*reviews.customerno statusProvision detail (full payload with seller + reviews + per-variant pricing).
Response{ product: Product /* with seller + reviews */ }lib/src/features/shared/provision_details/views/provision_details_screen.dartauth: customer.
- GET
/store/provisions/:id?fields=metadatano statusMetadata-only slice used by the booking screen.
Response{ product: Product /* metadata only */ }lib/src/features/shared/provision_details/views/provision_booking_screen.dartauth: customer.
- GET
/store/provisions/:productId/slotsno statusAvailable booking slots used by the calendar.
Response{ slots: ProvisionSlot[] }lib/src/features/shared/provision_details/views/provision_booking_screen.dartauth: customer.
- GET
/store/provisions/:productId/policyno statusCustomer view of the provision's booking policy (deposit %, cancellation window, refund rules).
Response{ policy: { deposit_percentage, max_cancellation_delay_hours, rules: [...] } }lib/src/features/shared/provision_details/views/provision_booking_screen.dart, lib/src/features/shared/checkout/views/widgets/checkout_booking_policy.dartauth: customer.
- GET
/store/provisions/:productId/booking-questionsno statusBooking questions the customer must answer before checkout.
Response{ booking_questions: [{ id, question_text, type, is_required, options? }, ...] }Errors- ·404 — no questions defined for this provision
lib/src/features/shared/provision_details/views/provision_booking_screen.dart, lib/src/features/shared/checkout/views/widgets/checkout_booking_questions.dartauth: customer.
Notes
Keep ProvisionService and the vendor side aligned — a field added to the create payload usually needs surfacing in both sides.