Phase 1 Integration¶
Overview¶
Our integration approach focuses on simplicity and reliability, starting with essential provider integrations.
API Design¶
Bulk Order Upload¶
Route Optimization Request¶
POST /api/v1/routes/optimize
Content-Type: application/json
{
"orders": ["order_id_1", "order_id_2"],
"constraints": {
"time_window": {
"start": "2024-01-01T09:00:00Z",
"end": "2024-01-01T17:00:00Z"
},
"priority": "normal"
}
}
Provider Integration¶
Get Quotes¶
POST /api/v1/quotes
Content-Type: application/json
{
"pickup": {
"address": "string",
"latitude": number,
"longitude": number
},
"dropoffs": [
{
"address": "string",
"latitude": number,
"longitude": number
}
]
}
Data Models¶
Order¶
class Order:
id: str
merchant_id: str
pickup: Location
dropoff: Location
time_window: TimeWindow
priority: Priority
status: OrderStatus
Route¶
class Route:
id: str
orders: List[Order]
provider: Provider
estimated_cost: float
estimated_duration: int
Integration Flow¶
- Order Upload
- Validate CSV/JSON format
- Process orders in batch
-
Return batch ID
-
Route Optimization
- Group orders by area
- Calculate optimal routes
-
Consider time constraints
-
Provider Integration
- Get quotes from providers
- Select best options
- Submit orders
- Track status
Error Handling¶
Validation Errors¶
{
"error": "validation_error",
"message": "Invalid order data",
"details": [
{
"field": "dropoff.address",
"error": "required"
}
]
}
Processing Errors¶
{
"error": "processing_error",
"message": "Unable to optimize route",
"batch_id": "batch_123",
"failed_orders": ["order_id_1"]
}
Best Practices¶
- Input Validation
- Validate all input data
- Provide clear error messages
-
Handle partial failures
-
Error Recovery
- Implement retry logic
- Log all failures
-
Enable manual intervention
-
Monitoring
- Track success rates
- Monitor processing times
- Alert on failures