API Documentation

Overview

The Order Management API provides comprehensive functionality for managing orders within the Bee O'clock panel service. This module handles the complete order lifecycle, including creation, updates, status management, and deletion of orders containing services and products.

Base Configuration

Authentication

All endpoints require Bearer token authentication.

Headers

  • Authorization: Bearer <token> - Required for all endpoints

  • x-business-tenant-id: <tenant_id> - Required for multi-tenancy support

  • Content-Type: application/json - For POST/PUT requests

Base URL

/api/v1/order

Endpoints

1. Get Paginated Orders

Endpoint: GET /api/v1/order/paged

Description: Retrieves a paginated list of orders with advanced filtering capabilities.

Query Parameters:

Response:

Example Request:

Example Response:

2. Get Order by ID

Endpoint: GET /api/v1/order/{id}

Description: Retrieves a specific order by its ID with permission validation.

Path Parameters:

  • id (string, required) - Order ID

Response: OrderDto

Example Request:

Example Response:

3. Create Order

Endpoint: POST /api/v1/order

Description: Creates a new order with services and products through a saga pattern with validation and rollback capabilities.

Request Body: OrderDto

Response: OrderDto

Example Request:

Example Response:

4. Update Order

Endpoint: PUT /api/v1/order/{id}

Description: Updates an existing order with validation and permission checks.

Path Parameters:

  • id (string, required) - Order ID

Request Body: OrderDto

Response: OrderDto

Example Request:

5. Delete Order

Endpoint: DELETE /api/v1/order/{id}

Description: Soft deletes an order with permission validation and dependency checking.

Path Parameters:

  • id (string, required) - Order ID

Response: void (204 No Content)

Example Request:

Data Models

OrderDto

OrderServiceDto

OrderProductDto

OrderAppointmentDetailsDto

OrderPaginationDto

Enums

OrderStatusEnum

OrderServiceStatusEnum

ReservationTypeEnum

PaymentStatusEnum

Error Handling

Common Error Responses

400 Bad Request

401 Unauthorized

403 Forbidden

404 Not Found

409 Conflict

422 Unprocessable Entity

Business Rules

Order Creation

  1. Service Validation: All services must be valid and available

  2. Time Slot Validation: Appointment times must not conflict with existing bookings

  3. Specialist Availability: Assigned specialists must be available during requested times

  4. Customer Validation: Customer must exist and be valid

  5. Product Validation: All products must be available in inventory

Order Updates

  1. Status Transitions: Updates must follow valid status transition rules

  2. Service Modification: Changes to services require specialist availability validation

  3. Payment Constraints: Cannot modify orders with completed payments

  4. Time Constraints: Cannot modify past appointments

  5. Permission Validation: User must have appropriate permissions for the scope of changes

Order Deletion

  1. Soft Delete: Orders are marked as deleted rather than physically removed

  2. Payment Check: Cannot delete orders with active or completed payments

  3. Dependency Validation: Cannot delete orders with dependent records

  4. History Preservation: All historical data is maintained for audit purposes

Permission Scopes

  1. OWN: Users can only access orders assigned to them

  2. TEAM: Users can access orders within their team

  3. BUSINESS: Users can access all orders within the business

  4. ADMIN: Full access to all order operations

Performance Considerations

Pagination

  • Default page size: 10 items

  • Maximum page size: 100 items

  • Use pagination for large datasets to maintain performance

Filtering

  • Date range filters are optimized with database indexes

  • Status filtering uses enum indexes for fast queries

  • Member ID filtering supports array-based queries

Caching

  • Order data is cached for frequently accessed items

  • Cache invalidation occurs on order updates

  • Cache warming for dashboard queries

Database Optimization

  • Compound indexes on status, dates, and member IDs

  • Separate collections for order services and products

  • Optimized queries with projection for large orders

Rate Limiting

  • Read Operations: 100 requests per minute per user

  • Write Operations: 30 requests per minute per user

  • Bulk Operations: 10 requests per minute per user

Monitoring and Logging

Request Logging

All API requests are logged with:

  • Request ID for tracing

  • User context and permissions

  • Performance metrics

  • Error details and stack traces

Business Event Logging

  • Order status changes

  • Payment status updates

  • Service assignments and modifications

  • Customer interactions and notes

Performance Monitoring

  • Response time tracking

  • Database query performance

  • Cache hit rates

  • Error rate monitoring

Last updated

Was this helpful?