Skip to main content

Version Docs Updated

Purpose

This endpoint checks whether a specific vehicle is available for rental within a selected date and time range, and calculates the current pricing.

πŸš— Availability Check Endpoint

Availability checking is the first and most critical step in the booking process. It returns real-time results using the Util::has_overlap() and PricingEngine classes.


πŸ“ Endpoint Details​

  • URL: /wp-json/mhm-rentiva/v1/availability
  • Method: POST
  • Permission: Public (if not an admin/vendor interface)

πŸ“₯ Request Parameters (JSON Body)​

ParameterTypeRequiredDescription
vehicle_idintYesThe ID of the vehicle to check.
pickup_datestringYesPickup date (YYYY-MM-DD).
pickup_timestringYesPickup time (HH:MM).
return_datestringYesReturn date (YYYY-MM-DD).
return_timestringYesReturn time (HH:MM).
location_idintNoDelivery location (may affect pricing).

πŸ“€ Successful Response Example​

{
"success": true,
"data": {
"available": true,
"pricing": {
"base_price": 1200.00,
"service_fee": 150.00,
"total_price": 1350.00,
"currency": "TRY"
},
"duration": {
"days": 3,
"hours": 0
}
}
}

πŸ›‘οΈ Security and Validation​

  1. Date Order: The return date cannot precede the pickup date.
  2. Time Check: The pickup time must comply with minimum booking duration rules.
  3. RateLimiter: Multiple queries from the same IP within a second are automatically throttled.
  4. Sanitization: All input data is sanitized via Sanitizer::absint() and sanitize_text_field().

❌ Error States​

CodeMessageReason
400INVALID_DATE_RANGEPickup/return dates are illogical.
404VEHICLE_NOT_FOUNDNo vehicle found with the specified ID.
409VEHICLE_NOT_AVAILABLEVehicle is already booked for the specified dates.
429TOO_MANY_REQUESTSRate limit exceeded.

Section Summary​

  • The availability endpoint provides both availability and pricing information.
  • Util::has_overlap() detects conflicts within seconds.
  • Used for reactive updates in front-end calendars and booking forms.

Changelog​

DateVersionNote
23.04.20264.27.2English translation added.
19.03.20264.21.2JSON request/response schema and error codes detailed.