openapi: 3.0.0
info:
  title: Odyssey Transfer Supplier API
  description: API for local transport and limo companies to upload rates and receive bookings.
  version: 1.0.0
servers:
  - url: https://wvjaseexkfrcahmzfxkl.supabase.co/functions/v1/transfer-supplier-api
    description: Production Odyssey Transfer Supplier API Gateway
paths:
  /rates:
    get:
      summary: List active transfer rates
      description: Retrieve all route rates currently uploaded for the authenticated supplier.
      security:
        - ApiKeyAuth: []
      responses:
        '200':
          description: List of supplier rates
        '401':
          description: Unauthorized
    post:
      summary: Upsert transfer rates
      description: Upload or update a batch of confidential net wholesale rates (USD, tax/VAT inclusive) for specific routes.
      security:
        - ApiKeyAuth: []
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              properties:
                rates:
                  type: array
                  items:
                    $ref: '#/components/schemas/Rate'
      responses:
        '200':
          description: Rates successfully updated
        '400':
          description: Invalid payload
        '401':
          description: Unauthorized
  /bookings:
    get:
      summary: List assigned bookings
      description: Retrieve pending and confirmed chauffeur dispatch bookings assigned to the authenticated supplier.
      security:
        - ApiKeyAuth: []
      parameters:
        - in: query
          name: status
          required: false
          schema:
            type: string
            enum: [pending, confirmed, rejected, completed]
      responses:
        '200':
          description: List of supplier bookings
        '401':
          description: Unauthorized
  /bookings/{bookingId}/confirm:
    post:
      summary: Confirm a booking
      description: Accept a booking that was sent via webhook.
      security:
        - ApiKeyAuth: []
      parameters:
        - in: path
          name: bookingId
          required: true
          schema:
            type: string
          description: The unique identifier of the booking.
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              properties:
                driverName:
                  type: string
                  description: Optional name of the assigned driver.
                driverPhone:
                  type: string
                  description: Optional phone number of the assigned driver.
                vehiclePlate:
                  type: string
                  description: Optional license plate of the vehicle.
      responses:
        '200':
          description: Booking confirmed successfully
        '404':
          description: Booking not found
  /bookings/{bookingId}/reject:
    post:
      summary: Reject a booking
      description: Reject a booking if unable to fulfill.
      security:
        - ApiKeyAuth: []
      parameters:
        - in: path
          name: bookingId
          required: true
          schema:
            type: string
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              properties:
                reason:
                  type: string
                  description: Reason for rejection.
      responses:
        '200':
          description: Booking rejected successfully
  /vehicle-images:
    post:
      summary: Upload a vehicle image
      description: Upload a raw image file to obtain a URI for use in the /rates endpoint.
      security:
        - ApiKeyAuth: []
      requestBody:
        required: true
        content:
          multipart/form-data:
            schema:
              type: object
              properties:
                image:
                  type: string
                  format: binary
                  description: The vehicle image file (JPEG, PNG). Max size 5MB.
      responses:
        '200':
          description: Image uploaded successfully
          content:
            application/json:
              schema:
                type: object
                properties:
                  vehicleImage:
                    type: string
                    format: uri
                    description: The URI of the uploaded image to be used in the rates payload.
        '400':
          description: Invalid file or file too large
        '401':
          description: Unauthorized

components:
  securitySchemes:
    ApiKeyAuth:
      type: apiKey
      in: header
      name: X-Supplier-API-Key
  schemas:
    Rate:
      type: object
      required:
        - fromPlaceId
        - toPlaceId
        - vehicleCategory
        - price
        - currency
      properties:
        fromPlaceId:
          type: string
          description: Google Place ID of the pickup location.
        toPlaceId:
          type: string
          description: Google Place ID of the drop-off location.
        vehicleCategory:
          type: string
          enum: [standard, premium, luxury, van, suv]
          description: Category of the vehicle.
        price:
          type: number
          description: Net rate for this transfer.
        currency:
          type: string
          example: USD
        vehicleImage:
          type: string
          format: uri
          description: URL to a photo of the vehicle.
        freeWaitingTime:
          type: string
          example: "60 mins"
        cancellationPolicy:
          type: string
          example: "Free cancellation up to 24 hours before pickup."
