arch-atlas

ProvisionService (Customer-side)

core/services/provision_service.dart

data

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

  1. getProvisions: paginated / filtered list — analogous to MarketplaceService.getProducts but for service-type.
  2. getProvisionsWithDistance: same shape with lat/lng/radius for /store/product-location.
  3. getProvisionById: single full provision with `*seller,*reviews` field selection.
  4. 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 status

    Customer view of published provisions for the marketplace home / client grid tile.

    Request
    Query: 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.dart

    auth: customer.

  • GET/store/product-locationno status

    Map-driven nearby provisions search (lat/lng/radius).

    Request
    Query: 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 status

    Provision 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.dart

    auth: customer.

  • GET/store/provisions/:id?fields=metadatano status

    Metadata-only slice used by the booking screen.

    Response
    { product: Product /* metadata only */ }
    lib/src/features/shared/provision_details/views/provision_booking_screen.dart

    auth: customer.

  • GET/store/provisions/:productId/slotsno status

    Available booking slots used by the calendar.

    Response
    { slots: ProvisionSlot[] }
    lib/src/features/shared/provision_details/views/provision_booking_screen.dart

    auth: customer.

  • GET/store/provisions/:productId/policyno status

    Customer 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.dart

    auth: customer.

  • GET/store/provisions/:productId/booking-questionsno status

    Booking 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.dart

    auth: customer.

Notes

Keep ProvisionService and the vendor side aligned — a field added to the create payload usually needs surfacing in both sides.