{
    "openapi": "3.1.0",
    "info": {
        "title": "Geolander Reservation API",
        "version": "1.1.0",
        "description": "Public customer quote and booking-request handoff plus Cloudflare Access authenticated mirrors for Geolander-operated agents. Checkout creates a request but does not confirm availability or payment.",
        "contact": {
            "name": "Geolander car rental",
            "email": "info@geo-lander.com",
            "url": "https://geo-lander.com/contact/"
        }
    },
    "servers": [
        {
            "url": "https://geo-lander.com",
            "description": "Geolander production website"
        }
    ],
    "externalDocs": {
        "description": "Geolander developer resources",
        "url": "https://geo-lander.com/developers/"
    },
    "paths": {
        "/wp-json/geolander/v1/quote": {
            "get": {
                "operationId": "getRentalQuote",
                "summary": "Get a read-only rental quote",
                "description": "Returns a server-priced quote for one published car, date range, pickup location, and return location. This operation does not create a booking.",
                "parameters": [
                    {
                        "name": "car",
                        "in": "query",
                        "required": true,
                        "schema": {
                            "type": "integer",
                            "minimum": 1
                        }
                    },
                    {
                        "name": "from",
                        "in": "query",
                        "required": true,
                        "schema": {
                            "type": "string",
                            "format": "date"
                        }
                    },
                    {
                        "name": "to",
                        "in": "query",
                        "required": true,
                        "schema": {
                            "type": "string",
                            "format": "date"
                        }
                    },
                    {
                        "name": "pickup",
                        "in": "query",
                        "required": false,
                        "schema": {
                            "$ref": "#/components/schemas/Location"
                        }
                    },
                    {
                        "name": "return",
                        "in": "query",
                        "required": false,
                        "schema": {
                            "$ref": "#/components/schemas/Location"
                        }
                    }
                ],
                "responses": {
                    "200": {
                        "description": "Calculated quote",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/Quote"
                                }
                            }
                        }
                    },
                    "400": {
                        "description": "Invalid car, dates, or location"
                    },
                    "404": {
                        "description": "Vehicle not found"
                    }
                }
            }
        },
        "/wp-json/geolander/v1/checkout": {
            "post": {
                "operationId": "createBookingRequest",
                "summary": "Create a booking request and WhatsApp handoff",
                "description": "Requires explicit traveller approval. Creates an internal booking request and returns a prepared WhatsApp URL. It does not confirm availability or the reservation.",
                "requestBody": {
                    "required": true,
                    "content": {
                        "application/json": {
                            "schema": {
                                "$ref": "#/components/schemas/BookingRequest"
                            }
                        }
                    }
                },
                "responses": {
                    "200": {
                        "description": "Booking request saved and handoff prepared",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/BookingHandoff"
                                }
                            }
                        }
                    },
                    "400": {
                        "description": "Invalid customer, vehicle, dates, or location"
                    },
                    "429": {
                        "description": "Request rate limit exceeded"
                    }
                }
            }
        },
        "/wp-json/geolander-agent/v1/quote": {
            "get": {
                "operationId": "getAuthenticatedRentalQuote",
                "summary": "Get a read-only rental quote",
                "description": "Returns a server-priced quote for one published car, date range, pickup location, and return location. This operation does not create a booking. This mirror requires Cloudflare Managed OAuth and validates the resulting Access JWT at the origin.",
                "parameters": [
                    {
                        "name": "car",
                        "in": "query",
                        "required": true,
                        "schema": {
                            "type": "integer",
                            "minimum": 1
                        }
                    },
                    {
                        "name": "from",
                        "in": "query",
                        "required": true,
                        "schema": {
                            "type": "string",
                            "format": "date"
                        }
                    },
                    {
                        "name": "to",
                        "in": "query",
                        "required": true,
                        "schema": {
                            "type": "string",
                            "format": "date"
                        }
                    },
                    {
                        "name": "pickup",
                        "in": "query",
                        "required": false,
                        "schema": {
                            "$ref": "#/components/schemas/Location"
                        }
                    },
                    {
                        "name": "return",
                        "in": "query",
                        "required": false,
                        "schema": {
                            "$ref": "#/components/schemas/Location"
                        }
                    }
                ],
                "responses": {
                    "200": {
                        "description": "Calculated quote",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/Quote"
                                }
                            }
                        }
                    },
                    "400": {
                        "description": "Invalid car, dates, or location"
                    },
                    "404": {
                        "description": "Vehicle not found"
                    },
                    "401": {
                        "description": "Missing or invalid Cloudflare Access authorization"
                    }
                },
                "security": [
                    {
                        "CloudflareManagedOAuth": [
                            "geolander.agent"
                        ]
                    }
                ]
            }
        },
        "/wp-json/geolander-agent/v1/checkout": {
            "post": {
                "operationId": "createAuthenticatedBookingRequest",
                "summary": "Create a booking request and WhatsApp handoff",
                "description": "Requires explicit traveller approval. Creates an internal booking request and returns a prepared WhatsApp URL. It does not confirm availability or the reservation. This mirror requires Cloudflare Managed OAuth and validates the resulting Access JWT at the origin.",
                "requestBody": {
                    "required": true,
                    "content": {
                        "application/json": {
                            "schema": {
                                "$ref": "#/components/schemas/BookingRequest"
                            }
                        }
                    }
                },
                "responses": {
                    "200": {
                        "description": "Booking request saved and handoff prepared",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/BookingHandoff"
                                }
                            }
                        }
                    },
                    "400": {
                        "description": "Invalid customer, vehicle, dates, or location"
                    },
                    "429": {
                        "description": "Request rate limit exceeded"
                    },
                    "401": {
                        "description": "Missing or invalid Cloudflare Access authorization"
                    }
                },
                "security": [
                    {
                        "CloudflareManagedOAuth": [
                            "geolander.agent"
                        ]
                    }
                ]
            }
        }
    },
    "components": {
        "schemas": {
            "Location": {
                "type": "string",
                "enum": [
                    "tbilisi_office",
                    "tbilisi_airport",
                    "kutaisi_airport",
                    "batumi_airport"
                ]
            },
            "Quote": {
                "type": "object",
                "required": [
                    "car",
                    "from",
                    "to",
                    "days",
                    "rental_total",
                    "pickup_fee",
                    "return_fee",
                    "total",
                    "prepayment",
                    "balance"
                ],
                "properties": {
                    "car": {
                        "type": "string"
                    },
                    "from": {
                        "type": "string",
                        "format": "date"
                    },
                    "to": {
                        "type": "string",
                        "format": "date"
                    },
                    "days": {
                        "type": "integer",
                        "minimum": 1
                    },
                    "rental_total": {
                        "type": "number"
                    },
                    "pickup_fee": {
                        "type": "number"
                    },
                    "return_fee": {
                        "type": "number"
                    },
                    "total": {
                        "type": "number"
                    },
                    "prepayment": {
                        "type": "number"
                    },
                    "balance": {
                        "type": "number"
                    }
                }
            },
            "BookingRequest": {
                "type": "object",
                "required": [
                    "car",
                    "from",
                    "to",
                    "pickup",
                    "return",
                    "name",
                    "email"
                ],
                "properties": {
                    "car": {
                        "type": "integer",
                        "minimum": 1
                    },
                    "from": {
                        "type": "string",
                        "format": "date"
                    },
                    "to": {
                        "type": "string",
                        "format": "date"
                    },
                    "pickup": {
                        "$ref": "#/components/schemas/Location"
                    },
                    "return": {
                        "$ref": "#/components/schemas/Location"
                    },
                    "name": {
                        "type": "string",
                        "minLength": 1
                    },
                    "email": {
                        "type": "string",
                        "format": "email"
                    }
                }
            },
            "BookingHandoff": {
                "type": "object",
                "required": [
                    "redirect",
                    "reference"
                ],
                "properties": {
                    "redirect": {
                        "type": "string",
                        "format": "uri"
                    },
                    "reference": {
                        "type": "string",
                        "pattern": "^GL-[0-9]+$"
                    },
                    "message": {
                        "type": "string"
                    },
                    "emailSent": {
                        "type": "boolean"
                    }
                }
            }
        },
        "securitySchemes": {
            "CloudflareManagedOAuth": {
                "type": "oauth2",
                "description": "Cloudflare Access Managed OAuth. Authorization is restricted to the identity providers and policies configured for the Geolander Agent API application.",
                "flows": {
                    "authorizationCode": {
                        "authorizationUrl": "https://jolly-sound-4ff2.cloudflareaccess.com/cdn-cgi/access/oauth/authorization",
                        "tokenUrl": "https://jolly-sound-4ff2.cloudflareaccess.com/cdn-cgi/access/oauth/token",
                        "refreshUrl": "https://jolly-sound-4ff2.cloudflareaccess.com/cdn-cgi/access/oauth/token",
                        "scopes": {
                            "geolander.agent": "Access the Cloudflare-protected Geolander Agent Reservation API"
                        }
                    }
                }
            }
        }
    }
}