{
  "openapi": "3.0.3",
  "info": {
    "title": "LOBI SHOP API",
    "description": "API nền tảng dịch vụ số và thuê sim nhận OTP tự động 24/7 của LOBI SHOP.",
    "version": "1.0.0",
    "contact": {
      "name": "LOBI SHOP Support",
      "url": "https://lobishop.vercel.app",
      "email": "hocongchien113@gmail.com"
    }
  },
  "servers": [
    {
      "url": "https://lobishop.vercel.app/api",
      "description": "Production Server"
    },
    {
      "url": "http://localhost:3000/api",
      "description": "Local Development Server"
    }
  ],
  "paths": {
    "/user/smart-auth": {
      "post": {
        "summary": "Đăng ký hoặc Đăng nhập tự động bằng Email/Password",
        "description": "Xác thực tài khoản người dùng, tự động tạo mới nếu email chưa tồn tại.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": ["email", "password"],
                "properties": {
                  "email": { "type": "string", "format": "email" },
                  "password": { "type": "string" },
                  "name": { "type": "string" }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Đăng nhập thành công",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "success": { "type": "boolean" },
                    "token": { "type": "string" },
                    "user": { "type": "object" },
                    "balance": { "type": "number" }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/user/session-check": {
      "post": {
        "summary": "Kiểm tra phiên làm việc người dùng",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": ["email", "token"],
                "properties": {
                  "email": { "type": "string" },
                  "token": { "type": "string" }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Thông tin trạng thái phiên làm việc"
          }
        }
      }
    },
    "/otp/services": {
      "get": {
        "summary": "Lấy danh mục dịch vụ thuê SIM OTP",
        "description": "Trả về danh sách các dịch vụ OTP khả dụng (Telegram, TikTok, Google, Facebook...) kèm giá niêm yết.",
        "responses": {
          "200": {
            "description": "Danh sách dịch vụ OTP",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "type": "object",
                    "properties": {
                      "id": { "type": "string" },
                      "label": { "type": "string" },
                      "price": { "type": "number" },
                      "note": { "type": "string" },
                      "available": { "type": "boolean" }
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/otp/get-number": {
      "post": {
        "summary": "Yêu cầu thuê số điện thoại lấy OTP",
        "security": [{ "BearerAuth": [] }],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": ["serviceId"],
                "properties": {
                  "serviceId": { "type": "string" }
                }
              }
            }
          }
        },
        "responses": {
          "200": { "description": "Cấp số thuê thành công" }
        }
      }
    },
    "/otp/check-code": {
      "post": {
        "summary": "Kiểm tra mã tin nhắn OTP đã về hay chưa",
        "security": [{ "BearerAuth": [] }],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": ["requestId"],
                "properties": {
                  "requestId": { "type": "string" }
                }
              }
            }
          }
        },
        "responses": {
          "200": { "description": "Trạng thái tin nhắn OTP" }
        }
      }
    },
    "/otp/refund": {
      "post": {
        "summary": "Hủy đơn số và hoàn tiền nếu không có OTP",
        "security": [{ "BearerAuth": [] }],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": ["requestId"],
                "properties": {
                  "requestId": { "type": "string" }
                }
              }
            }
          }
        },
        "responses": {
          "200": { "description": "Kết quả hoàn tiền" }
        }
      }
    },
    "/shop/products": {
      "get": {
        "summary": "Lấy danh sách sản phẩm tài khoản số & bản quyền",
        "responses": {
          "200": {
            "description": "Danh sách sản phẩm shop khả dụng",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "type": "object",
                    "properties": {
                      "id": { "type": "string" },
                      "label": { "type": "string" },
                      "price": { "type": "number" },
                      "stock": { "type": "number" },
                      "warranty": { "type": "string" },
                      "available": { "type": "boolean" }
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/shop/buy": {
      "post": {
        "summary": "Mua sản phẩm bản quyền / tài khoản số",
        "security": [{ "BearerAuth": [] }],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": ["productId", "quantity"],
                "properties": {
                  "productId": { "type": "string" },
                  "quantity": { "type": "integer", "minimum": 1 }
                }
              }
            }
          }
        },
        "responses": {
          "200": { "description": "Mua hàng thành công kèm key/tài khoản" }
        }
      }
    },
    "/deposit/note": {
      "get": {
        "summary": "Lấy thông tin hướng dẫn và lưu ý nạp tiền",
        "responses": {
          "200": {
            "description": "Nội dung lưu ý nạp tiền"
          }
        }
      }
    },
    "/user/transactions": {
      "get": {
        "summary": "Xem lịch sử giao dịch người dùng",
        "security": [{ "BearerAuth": [] }],
        "parameters": [
          {
            "name": "category",
            "in": "query",
            "required": false,
            "schema": { "type": "string", "enum": ["otp", "shop", "deposit"] }
          }
        ],
        "responses": {
          "200": { "description": "Danh sách lịch sử giao dịch" }
        }
      }
    }
  },
  "components": {
    "securitySchemes": {
      "BearerAuth": {
        "type": "http",
        "scheme": "bearer"
      }
    }
  }
}
