{
    "openapi": "3.0.0",
    "info": {
        "title": "Priskomotors API",
        "description": "Priskomotors Application API Documentation",
        "contact": {
            "email": "support@blockstack.com"
        },
        "version": "1.0.0"
    },
    "servers": [
        {
            "url": "http://127.0.0.1:8000/api",
            "description": "Local API Server"
        },
        {
            "url": "https://api.priskomotors.com/public/api",
            "description": "Production API Server"
        }
    ],
    "paths": {
        "/hello": {
            "get": {
                "tags": ["Test"],
                "summary": "Hello World API",
                "description": "Returns a Hello World message",
                "operationId": "7dc5d2524c671257eb34a2447eab8e9f",
                "responses": {
                    "200": {
                        "description": "Successful response",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "properties": {
                                        "message": {
                                            "type": "string",
                                            "example": "Hello World 🚀"
                                        }
                                    },
                                    "type": "object"
                                }
                            }
                        }
                    }
                }
            }
        },
        "/up": {
            "get": {
                "tags": ["Test"],
                "summary": "Health check",
                "description": "Checks if the API is running",
                "operationId": "healthCheck",
                "responses": {
                    "200": {
                        "description": "API is healthy",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "type": "object",
                                    "properties": {
                                        "status": {
                                            "type": "string",
                                            "example": "ok"
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
        },
        "/auth/register": {
            "post": {
                "tags": ["Auth"],
                "summary": "Register a new user",
                "requestBody": {
                    "required": true,
                    "content": {
                        "application/json": {
                            "schema": {
                                "type": "object",
                                "required": [
                                    "first_name",
                                    "last_name",
                                    "username",
                                    "password",
                                    "password_confirmation"
                                ],
                                "properties": {
                                    "first_name": {
                                        "type": "string",
                                        "example": "partick"
                                    },
                                    "last_name": {
                                        "type": "string",
                                        "example": "attakorrah"
                                    },
                                    "email": {
                                        "type": "string",
                                        "example": "john@example.com"
                                    },
                                    "username": {
                                        "type": "string",
                                        "example": "john"
                                    },
                                    "address": {
                                        "type": "string",
                                        "example": "address"
                                    },
                                    "password": {
                                        "type": "string",
                                        "example": "password123"
                                    },
                                    "password_confirmation": {
                                        "type": "string",
                                        "example": "password123"
                                    }
                                }
                            }
                        }
                    }
                },
                "responses": {
                    "201": {
                        "description": "User registered successfully"
                    },
                    "422": {
                        "description": "Validation error"
                    }
                }
            }
        },

        "/auth/login": {
            "post": {
                "tags": ["Auth"],
                "summary": "Login user",
                "requestBody": {
                    "required": true,
                    "content": {
                        "application/json": {
                            "schema": {
                                "required": ["email", "password"],
                                "properties": {
                                    "email": {
                                        "type": "string",
                                        "example": "john@example.com"
                                    },
                                    "password": {
                                        "type": "string",
                                        "example": "password123"
                                    }
                                }
                            }
                        }
                    }
                },
                "responses": {
                    "200": {
                        "description": "JWT token returned"
                    },
                    "401": {
                        "description": "Unauthorized"
                    }
                }
            }
        },

        "/user/me": {
            "get": {
                "tags": ["Auth"],
                "summary": "Get current authenticated user",
                "security": [{ "bearerAuth": [] }],
                "responses": {
                    "200": {
                        "description": "Authenticated user"
                    },
                    "401": {
                        "description": "Unauthenticated"
                    }
                }
            }
        },
        "/user/profile": {
            "put": {
                "tags": ["User"],
                "summary": "Update authenticated user's profile",
                "security": [
                    {
                        "bearerAuth": []
                    }
                ],
                "requestBody": {
                    "required": true,
                    "content": {
                        "application/json": {
                            "schema": {
                                "type": "object",
                                "properties": {
                                    "first_name": {
                                        "type": "string",
                                        "example": "John"
                                    },
                                    "last_name": {
                                        "type": "string",
                                        "example": "Doe"
                                    },
                                    "username": {
                                        "type": "string",
                                        "example": "johndoe"
                                    },
                                    "email": {
                                        "type": "string",
                                        "format": "email",
                                        "example": "john@example.com"
                                    },
                                    "address": {
                                        "type": "string",
                                        "example": "123 Main St"
                                    },
                                    "phone": {
                                        "type": "string",
                                        "example": "+1234567890"
                                    }
                                }
                            }
                        }
                    }
                },
                "responses": {
                    "200": {
                        "description": "Profile updated successfully",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "type": "object",
                                    "properties": {
                                        "message": {
                                            "type": "string",
                                            "example": "Profile updated successfully"
                                        },
                                        "user": {
                                            "type": "object",
                                            "properties": {
                                                "id": {
                                                    "type": "integer",
                                                    "example": 1
                                                },
                                                "first_name": {
                                                    "type": "string",
                                                    "example": "John"
                                                },
                                                "last_name": {
                                                    "type": "string",
                                                    "example": "Doe"
                                                },
                                                "username": {
                                                    "type": "string",
                                                    "example": "johndoe"
                                                },
                                                "email": {
                                                    "type": "string",
                                                    "example": "john@example.com"
                                                },
                                                "address": {
                                                    "type": "string",
                                                    "example": "123 Main St"
                                                },
                                                "phone": {
                                                    "type": "string",
                                                    "example": "+1234567890"
                                                }
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    },
                    "422": { "description": "Validation errors" },
                    "401": { "description": "Unauthorized" }
                }
            }
        },
        "/user/payments": {
            "get": {
                "tags": ["Payments"],
                "summary": "Get logged-in user payment history",
                "description": "Returns a list of payment transactions belonging to the authenticated user.",
                "security": [
                    {
                        "bearerAuth": []
                    }
                ],
                "responses": {
                    "200": {
                        "description": "Payment history retrieved successfully",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "type": "array",
                                    "items": {
                                        "type": "object",
                                        "properties": {
                                            "id": {
                                                "type": "integer",
                                                "example": 12
                                            },
                                            "user_id": {
                                                "type": "integer",
                                                "example": 5
                                            },
                                            "invoice": {
                                                "type": "string",
                                                "example": "INV-2025-001"
                                            },
                                            "policy_number": {
                                                "type": "string",
                                                "example": "POL-889293"
                                            },
                                            "amount": {
                                                "type": "number",
                                                "format": "float",
                                                "example": 25000
                                            },
                                            "status": {
                                                "type": "string",
                                                "example": "paid"
                                            },
                                            "payment_method": {
                                                "type": "string",
                                                "example": "paystack"
                                            },
                                            "reference": {
                                                "type": "string",
                                                "example": "PSK_8JSHD92J"
                                            },
                                            "created_at": {
                                                "type": "string",
                                                "format": "date-time",
                                                "example": "2025-01-18T10:45:22Z"
                                            },
                                            "updated_at": {
                                                "type": "string",
                                                "format": "date-time",
                                                "example": "2025-01-18T10:45:22Z"
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    },
                    "401": {
                        "description": "Unauthorized - invalid or missing token"
                    }
                }
            }
        },
        "/logout": {
            "post": {
                "tags": ["Auth"],
                "summary": "Logout user",
                "security": [{ "bearerAuth": [] }],
                "responses": {
                    "200": {
                        "description": "Logged out successfully"
                    }
                }
            }
        },

        "/refresh": {
            "post": {
                "tags": ["Auth"],
                "summary": "Refresh JWT token",
                "security": [{ "bearerAuth": [] }],
                "responses": {
                    "200": {
                        "description": "Token refreshed"
                    }
                }
            }
        },
        "/admin/dashboard": {
            "get": {
                "tags": ["Admin"],
                "summary": "Admin dashboard",
                "security": [{ "bearerAuth": [] }],
                "responses": {
                    "200": { "description": "Admin dashboard data" },
                    "403": { "description": "Forbidden" }
                }
            }
        },
        "/admin/users": {
            "get": {
                "tags": ["Admin"],
                "summary": "Get all users (admin only)",
                "security": [{ "bearerAuth": [] }],
                "responses": {
                    "200": { "description": "List of all users" },
                    "403": { "description": "Forbidden" }
                }
            }
        },
        "/admin/users/{user}/assign-role": {
            "post": {
                "tags": ["Admin"],
                "summary": "Assign role to user (admin only)",
                "security": [{ "bearerAuth": [] }],
                "parameters": [
                    {
                        "name": "user",
                        "in": "path",
                        "required": true,
                        "schema": { "type": "integer" }
                    }
                ],
                "requestBody": {
                    "required": true,
                    "content": {
                        "application/json": {
                            "schema": {
                                "type": "object",
                                "properties": {
                                    "role": {
                                        "type": "string",
                                        "example": "vendor"
                                    }
                                }
                            }
                        }
                    }
                },
                "responses": {
                    "200": { "description": "Role updated" },
                    "403": { "description": "Forbidden" }
                }
            }
        },
        "/vendor/dashboard": {
            "get": {
                "tags": ["Vendor"],
                "summary": "Vendor dashboard",
                "security": [{ "bearerAuth": [] }],
                "responses": {
                    "200": { "description": "Vendor dashboard data" },
                    "403": { "description": "Forbidden" }
                }
            }
        },
         "/vendor/cars": {
    "post": {
      "tags": ["Vendor"],
      "summary": "Add a new car",
      "description": "Create a new car for the authenticated vendor. Car will be pending admin approval.",
      "security": [{ "bearerAuth": [] }],
      "requestBody": {
        "required": true,
        "content": {
          "application/json": {
            "schema": {
              "type": "object",
              "required": [
                "title",
                "image",
                "mileage",
                "run_and_drive",
                "key_available",
                "car_information",
                "car_history",
                "sell_information"
              ],
              "properties": {
                "title": { "type": "string", "example": "Toyota Camry 2018" },
                "image": { "type": "string", "example": "cars/camry.jpg" },
                "detail_url": { "type": "string", "nullable": true },
                "buy_now_price": { "type": "string", "nullable": true },
                "mileage": { "type": "string", "example": "45,000km" },
                "run_and_drive": { "type": "boolean", "example": true },
                "key_available": { "type": "boolean", "example": true },

                "car_information": {
                  "type": "object",
                  "properties": {
                    "vinMasked": { "type": "string" },
                    "vinStatus": { "type": "string", "enum": ["OK", "NOT OK"] },
                    "vehicleType": { "type": "string" },
                    "bodyStyle": { "type": "string" },
                    "engine": { "type": "string" },
                    "transmission": { "type": "string" },
                    "driveLine": { "type": "string" },
                    "fuelType": { "type": "string" },
                    "cylinders": { "type": "string" },
                    "restraintSystem": {
                      "type": "array",
                      "items": { "type": "string" }
                    },
                    "exteriorColor": { "type": "string" },
                    "interiorColor": { "type": "string" },
                    "options": {
                      "type": "array",
                      "items": { "type": "string" }
                    },
                    "manufacturedIn": { "type": "string" },
                    "vehicleClass": { "type": "string" },
                    "model": { "type": "string" },
                    "series": { "type": "string" }
                  }
                },

                "car_history": {
                  "type": "object",
                  "properties": {
                    "lossType": { "type": "string" },
                    "primaryDamage": { "type": "string" },
                    "secondaryDamage": { "type": "string", "nullable": true },
                    "airbags": { "type": "string" },
                    "odometer": {
                      "type": "object",
                      "properties": {
                        "value": { "type": "string" },
                        "status": {
                          "type": "string",
                          "enum": ["Actual", "Not Actual", "Exempt"]
                        }
                      }
                    },
                    "startCode": { "type": "string" },
                    "keyStatus": {
                      "type": "string",
                      "enum": ["Present", "Missing"]
                    }
                  }
                },

                "sell_information": {
                  "type": "object",
                  "properties": {
                    "stockNumber": { "type": "string" },
                    "sellingBranch": { "type": "string" },
                    "vehicleLocation": { "type": "string" },
                    "auctionDateTime": {
                      "type": "string",
                      "format": "date-time"
                    },
                    "laneRun": { "type": "string" },
                    "aisleStall": { "type": "string" },
                    "actualCashValue": { "type": "string" },
                    "estimatedRepairCost": { "type": "string" },
                    "seller": { "type": "string" },
                    "titleStatus": { "type": "string" }
                  }
                }
              }
            }
          }
        }
      },
      "responses": {
        "201": { "description": "Car added successfully (pending approval)" },
        "401": { "description": "Unauthorized" },
        "422": { "description": "Validation error" }
      }
    },

    "get": {
      "tags": ["Vendor"],
      "summary": "Get all cars for logged-in vendor",
      "description": "Returns all cars belonging to the authenticated vendor.",
      "security": [{ "bearerAuth": [] }],
      "responses": {
        "200": { "description": "List of vendor cars" },
        "401": { "description": "Unauthorized" }
      }
    }
  },
        "/merchant/dashboard": {
            "get": {
                "tags": ["Merchant"],
                "summary": "Merchant dashboard",
                "security": [{ "bearerAuth": [] }],
                "responses": {
                    "200": { "description": "Merchant dashboard data" },
                    "403": { "description": "Forbidden" }
                }
            }
        },
        "/user/dashboard": {
            "get": {
                "tags": ["User"],
                "summary": "User dashboard",
                "security": [{ "bearerAuth": [] }],
                "responses": {
                    "200": { "description": "User dashboard data" },
                    "403": { "description": "Forbidden" }
                }
            }
        },
        "/products": {
            "get": {
                "tags": ["Products"],
                "summary": "Get all products",
                "description": "Returns a list of all products (public endpoint)",
                "operationId": "getAllProducts",
                "responses": {
                    "200": {
                        "description": "List of products",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "type": "array",
                                    "items": {
                                        "type": "object",
                                        "properties": {
                                            "id": {
                                                "type": "integer",
                                                "example": 1
                                            },
                                            "name": {
                                                "type": "string",
                                                "example": "Blockchain Wallet"
                                            },
                                            "description": {
                                                "type": "string",
                                                "example": "Secure decentralized wallet"
                                            },
                                            "price": {
                                                "type": "number",
                                                "format": "float",
                                                "example": 199.99
                                            },
                                            "created_at": {
                                                "type": "string",
                                                "format": "date-time",
                                                "example": "2025-01-01T12:00:00Z"
                                            },
                                            "updated_at": {
                                                "type": "string",
                                                "format": "date-time",
                                                "example": "2025-01-01T12:00:00Z"
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
    },
    "components": {
        "securitySchemes": {
            "bearerAuth": {
                "type": "http",
                "scheme": "bearer",
                "bearerFormat": "JWT"
            }
        }
    },
    "security": [
        {
            "bearerAuth": []
        }
    ],
    "tags": [
        {
            "name": "Test",
            "description": "Test"
        }
    ]
}
