Order Service
core/services/order_service.dart
Overview
Four endpoints: getOrders (customer list), getOrder (single, role-aware), getSellerOrders (vendor list with field selection), cancelSellerOrder (vendor POST cancel).
User Flow
- getOrders → GET /store/orders with authScope:'customer'.
- getOrder routes path by isSeller flag and attaches the seller field-selection query.
- getSellerOrders → GET /vendor/orders?fields=… + optional status filter.
- cancelSellerOrder → POST /vendor/orders/{id}/cancel.
- All list responses parse orders one at a time and skip-on-error to avoid one bad row killing the whole list.
Cases & Edge Cases
- Per-order parse failures are debugPrinted and the row is dropped — they never crash the controller.
- Reversed list ordering is applied here (newest first) — controllers and screens rely on this invariant.
- Seller endpoints rely on the DioHelper path heuristic (/vendor/* → seller token) to attach the right Authorization header.
Code References
- lib/src/core/services/order_service.dart:12 // getOrders
- lib/src/core/services/order_service.dart:44 // getOrder
- lib/src/core/services/order_service.dart:76 // getSellerOrders
- lib/src/core/services/order_service.dart:117 // cancelSellerOrder
API Calls
- GET
/store/ordersno statusCustomer order list (newest-first).
Response{ orders: Order[] }lib/src/features/shared/orders/views/orders_screen.dartauth: customer. Service reverses to newest-first client-side.
- GET
/store/orders/:orderIdno statusCustomer order detail.
Response{ order: Order }lib/src/features/shared/orders/views/order_detail_screen.dartauth: customer.
- GET
/vendor/orders?fields=*customer,+payment_status,*split_order_payment&status=:statusno statusSeller order list with embedded customer + split-payment info.
Response{ orders: Order[] /* with customer + splitOrderPayment */, count, offset, limit }lib/src/features/shared/orders/views/orders_screen.dart // role=freelancerauth: seller.
- GET
/vendor/orders/:orderId?fields=*customer,+payment_status,*split_order_paymentno statusSeller order detail with customer + split-payment.
Response{ order: Order }lib/src/features/shared/orders/views/order_detail_screen.dartauth: seller.
- POST
/vendor/orders/:orderId/cancelno statusSeller-initiated order cancellation and refund.
Response{ order: { status: 'canceled', split_order_payment: { status: 'refunded', refunded_amount: number }, payment_status: 'refunded' } }lib/src/features/shared/orders/views/order_detail_screen.dart // Cancel buttonauth: seller.
Notes
Each call carries a RequestTrace with feature='orders/customer' or 'orders/seller' — useful when grep-debugging real network traces.