{
  "openapi": "3.0.3",
  "info": {
    "title": "City Market Nakapitel — kassa API (SINOV)",
    "version": "1.0.0",
    "description": "Sinov muhiti, soxta ma'lumot. QR matni: 30–50 belgi (A–Z, 0–9), ichida CITY, oxirgi 12 belgi — mijoz kodi; oldingi qism har 30 soniyada almashadi (TOTP). Kalit: Authorization: Bearer <API_KEY>."
  },
  "servers": [
    {
      "url": "https://bonus.citymarked.uz"
    }
  ],
  "security": [
    {
      "bearer": []
    }
  ],
  "components": {
    "securitySchemes": {
      "bearer": {
        "type": "http",
        "scheme": "bearer"
      }
    },
    "schemas": {
      "CheckResult": {
        "type": "object",
        "required": [
          "ok",
          "found",
          "discount",
          "status"
        ],
        "properties": {
          "ok": {
            "type": "boolean"
          },
          "found": {
            "type": "boolean",
            "description": "Karta bazada bormi"
          },
          "discount": {
            "type": "boolean",
            "description": "true — a'zo narxi beriladi (faqat status=active)"
          },
          "status": {
            "type": "string",
            "enum": [
              "active",
              "expired",
              "unpaid",
              "qr_expired",
              "not_found",
              "invalid_code"
            ]
          },
          "card": {
            "type": "string",
            "nullable": true,
            "example": "7E5700000001",
            "description": "Mijoz kodi (QR'ning oxirgi 12 belgisi) — chekka yoziladi"
          },
          "member": {
            "type": "object",
            "nullable": true,
            "properties": {
              "id": {
                "type": "integer"
              },
              "name": {
                "type": "string"
              },
              "tariff": {
                "type": "string",
                "enum": [
                  "month",
                  "year"
                ]
              }
            }
          },
          "valid_until": {
            "type": "string",
            "format": "date-time",
            "nullable": true
          }
        }
      },
      "Error": {
        "type": "object",
        "properties": {
          "ok": {
            "type": "boolean",
            "example": false
          },
          "error": {
            "type": "string",
            "enum": [
              "unauthorized",
              "invalid_json",
              "not_found",
              "too_large",
              "internal"
            ]
          }
        }
      }
    }
  },
  "paths": {
    "/api/v1/cards/check": {
      "post": {
        "summary": "Skanerlangan QR bo'yicha: chegirmali (a'zo) mijozmi?",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "code"
                ],
                "properties": {
                  "code": {
                    "type": "string",
                    "example": "J33D3MBD4N8YTXU7BECITY3MQGNW7E5700000001",
                    "description": "Skaner bergan QR matni o'zgartirilmasdan (QR har 30 soniyada almashadi)"
                  },
                  "pos_id": {
                    "type": "string",
                    "example": "K1"
                  },
                  "store_id": {
                    "type": "string",
                    "example": "CM1"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Har doim 200: discount true/false",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CheckResult"
                }
              }
            }
          },
          "401": {
            "description": "Kalit yo'q yoki noto'g'ri",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      },
      "get": {
        "summary": "Xuddi shu, GET bilan (brauzer/curl sinovi uchun)",
        "parameters": [
          {
            "name": "code",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "CheckResult",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CheckResult"
                }
              }
            }
          }
        }
      }
    }
  }
}