{
  "openapi": "3.0.1",
  "info": {
    "title": "LTM Client Report API",
    "description": "Secure API exposing the booking datasheet report. Authenticate at /api/auth/login to obtain a bearer token, then call /api/report/datasheet.",
    "version": "v1"
  },
  "paths": {
    "/api/Auth/login": {
      "post": {
        "tags": [
          "Auth"
        ],
        "summary": "Authenticate and obtain a JWT access token.",
        "requestBody": {
          "description": "Username and password.",
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/LoginRequest"
              }
            },
            "text/json": {
              "schema": {
                "$ref": "#/components/schemas/LoginRequest"
              }
            },
            "application/*+json": {
              "schema": {
                "$ref": "#/components/schemas/LoginRequest"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Authentication succeeded; token returned.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/TokenResponseApiResponse"
                }
              }
            }
          },
          "401": {
            "description": "Invalid credentials.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ObjectApiResponse"
                }
              }
            }
          }
        }
      }
    },
    "/api/Report/datasheet": {
      "post": {
        "tags": [
          "Report"
        ],
        "summary": "Retrieve the booking datasheet for a date range.",
        "description": "Sample request:\r\n            \r\n    POST /api/report/datasheet\r\n    {\r\n       \"fromDate\": \"2026-06-25\",\r\n       \"toDate\": \"2026-06-29\",\r\n       \"searchBy\": \"CheckIn\"\r\n    }\r\n            \r\n`searchBy` accepts: Booked, CheckIn, CheckOut.",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/ReportRequest"
              }
            },
            "text/json": {
              "schema": {
                "$ref": "#/components/schemas/ReportRequest"
              }
            },
            "application/*+json": {
              "schema": {
                "$ref": "#/components/schemas/ReportRequest"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Report generated successfully.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ReportResultApiResponse"
                }
              }
            }
          },
          "400": {
            "description": "Validation failed.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ObjectApiResponse"
                }
              }
            }
          },
          "401": {
            "description": "Missing or invalid token.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        }
      }
    }
  },
  "components": {
    "schemas": {
      "LoginRequest": {
        "required": [
          "password",
          "username"
        ],
        "type": "object",
        "properties": {
          "username": {
            "maxLength": 100,
            "minLength": 3,
            "type": "string"
          },
          "password": {
            "maxLength": 200,
            "minLength": 6,
            "type": "string"
          }
        },
        "additionalProperties": false,
        "description": "Credentials used to obtain a JWT access token."
      },
      "ObjectApiResponse": {
        "type": "object",
        "properties": {
          "success": {
            "type": "boolean"
          },
          "message": {
            "type": "string",
            "nullable": true
          },
          "data": {
            "nullable": true
          },
          "traceId": {
            "type": "string",
            "description": "Correlation id useful for tracing a request in the logs.",
            "nullable": true
          }
        },
        "additionalProperties": false,
        "description": "Standard envelope returned by all endpoints so clients get a consistent shape."
      },
      "ProblemDetails": {
        "type": "object",
        "properties": {
          "type": {
            "type": "string",
            "nullable": true
          },
          "title": {
            "type": "string",
            "nullable": true
          },
          "status": {
            "type": "integer",
            "format": "int32",
            "nullable": true
          },
          "detail": {
            "type": "string",
            "nullable": true
          },
          "instance": {
            "type": "string",
            "nullable": true
          }
        },
        "additionalProperties": { }
      },
      "ReportRequest": {
        "required": [
          "fromDate",
          "searchBy",
          "toDate"
        ],
        "type": "object",
        "properties": {
          "fromDate": {
            "type": "string",
            "description": "Start date (inclusive). Format: yyyy-MM-dd (date only).",
            "format": "date"
          },
          "toDate": {
            "type": "string",
            "description": "End date (inclusive). Format: yyyy-MM-dd (date only).",
            "format": "date"
          },
          "searchBy": {
            "$ref": "#/components/schemas/SearchBy"
          }
        },
        "additionalProperties": false,
        "description": "Request payload for the booking datasheet report."
      },
      "ReportResult": {
        "type": "object",
        "properties": {
          "rowCount": {
            "type": "integer",
            "format": "int32"
          },
          "rows": {
            "type": "array",
            "items": {
              "type": "object",
              "additionalProperties": { }
            },
            "nullable": true
          }
        },
        "additionalProperties": false,
        "description": "Result for the report endpoint: column metadata plus the row data."
      },
      "ReportResultApiResponse": {
        "type": "object",
        "properties": {
          "success": {
            "type": "boolean"
          },
          "message": {
            "type": "string",
            "nullable": true
          },
          "data": {
            "$ref": "#/components/schemas/ReportResult"
          },
          "traceId": {
            "type": "string",
            "description": "Correlation id useful for tracing a request in the logs.",
            "nullable": true
          }
        },
        "additionalProperties": false,
        "description": "Standard envelope returned by all endpoints so clients get a consistent shape."
      },
      "SearchBy": {
        "enum": [
          "Booked",
          "CheckIn",
          "CheckOut"
        ],
        "type": "string",
        "description": "Search dimension used to filter the report by date."
      },
      "TokenResponse": {
        "type": "object",
        "properties": {
          "accessToken": {
            "type": "string",
            "nullable": true
          },
          "tokenType": {
            "type": "string",
            "nullable": true
          },
          "expiresInSeconds": {
            "type": "integer",
            "format": "int32"
          },
          "expiresAtUtc": {
            "type": "string",
            "format": "date-time"
          }
        },
        "additionalProperties": false,
        "description": "Token returned on successful authentication."
      },
      "TokenResponseApiResponse": {
        "type": "object",
        "properties": {
          "success": {
            "type": "boolean"
          },
          "message": {
            "type": "string",
            "nullable": true
          },
          "data": {
            "$ref": "#/components/schemas/TokenResponse"
          },
          "traceId": {
            "type": "string",
            "description": "Correlation id useful for tracing a request in the logs.",
            "nullable": true
          }
        },
        "additionalProperties": false,
        "description": "Standard envelope returned by all endpoints so clients get a consistent shape."
      }
    },
    "securitySchemes": {
      "Bearer": {
        "type": "http",
        "description": "Enter the JWT token (without the 'Bearer ' prefix).",
        "scheme": "bearer",
        "bearerFormat": "JWT"
      }
    }
  },
  "security": [
    {
      "Bearer": [ ]
    }
  ],
  "tags": [
    {
      "name": "Auth",
      "description": "Authentication endpoints. Exchange credentials for a JWT bearer token."
    },
    {
      "name": "Report",
      "description": "Booking datasheet report endpoints.\r\nAll endpoints require a valid JWT bearer token."
    }
  ]
}