openapi: 3.0.3
info:
  title: mphone API
  description: |
    Self-contained OpenAPI specification generated from original documentation.
    All endpoints use POST with JSON (UTF-8) and require BasicAuth + Token header.
  version: 1.0.0
servers:
  - url: https://mphone.su/api
  - url: http://localhost:8010/api

components:
  securitySchemes:
    basicAuth:
      type: http
      scheme: basic
    tokenAuth:
      type: apiKey
      in: header
      name: Token

  schemas:
    Product:
      type: object
      properties:
        id_tovar:
          type: string
          example: "01000"
        name:
          type: string
          example: "Apple iPhone 16 Pro 256Gb Titanium Natural"
        price:
          type: number
          example: 99999
        katID:
          type: integer
          example: 400
        brendID:
          type: integer
          nullable: true
          example: null
        stranaID:
          type: string
          example: "980"
        DataModified:
          type: string
          format: date-time
          example: "01.01.2024 12:00:00.000"

    Order:
      type: object
      properties:
        id:
          type: integer
          example: 1999
        name:
          type: string
          example: "Иван"
        phone:
          type: string
          example: "+799999999"
        status:
          type: string
          example: "Собран"
        summaRUB:
          type: number
          example: 10000
        DataModified:
          type: string
          format: date-time
          example: "01.01.2024 12:00:00.000"

    OrderItem:
      type: object
      properties:
        id:
          type: integer
          example: 100099
        OrderID:
          type: integer
          example: 1999
        id_tovar:
          type: string
          example: "01000"
        tovarname:
          type: string
          example: "iPhone"
        price:
          type: number
          example: 10000
        count:
          type: integer
          example: 1

    Client:
      type: object
      properties:
        ID:
          type: integer
          example: 199
        Name:
          type: string
          example: "Михалыч"
        phone:
          type: string
          example: "+799999999"
        Discount:
          type: number
          example: 1.0

paths:
  /ListProducts:
    post:
      summary: Get products list
      security:
        - basicAuth: []
        - tokenAuth: []
      requestBody:
        required: false
        content:
          application/json:
            schema:
              type: object
              properties:
                IDtovar:
                  type: string
                  example: ""
                DataModified:
                  type: string
                  example: "01.01.2024 00:00:00.000"
            example:
              IDtovar: ""
              DataModified: "01.01.2024 00:00:00.000"
      responses:
        '200':
          description: Product list
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: array
                    items:
                      $ref: '#/components/schemas/Product'
              example:
                data:
                  - id_tovar: "01000"
                    name: "Apple iPhone"
                    price: 99999
                    katID: 400
                    brendID: null
                    stranaID: "980"
                    DataModified: "01.01.2024 12:00:00.000"

  /ListOrders:
    post:
      summary: Get orders list
      security:
        - basicAuth: []
        - tokenAuth: []
      requestBody:
        content:
          application/json:
            schema:
              type: object
            example:
              IDzakaz: 0
              Statuses: ["Принят"]
      responses:
        '200':
          description: Orders list
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: array
                    items:
                      $ref: '#/components/schemas/Order'
              example:
                data:
                  - id: 1999
                    name: "Иван"
                    phone: "+799999999"
                    status: "Собран"
                    summaRUB: 10000
                    DataModified: "01.01.2024 12:00:00.000"

  /InsertOrder:
    post:
      summary: Create order
      security:
        - basicAuth: []
        - tokenAuth: []
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
            example:
              order:
                id: "41"
                status: "Заявка"
                name: "Иван"
                phone: "+799999999"
                tochka: "Склад"
                items:
                  - id: "1"
                    id_tovar: "01000"
                    count: 1
                    price: 10000
      responses:
        '200':
          description: Result
          content:
            application/json:
              example:
                order:
                  accepted: true
                  OrderID: "81658"

  /ListClients:
    post:
      summary: Get clients
      security:
        - basicAuth: []
        - tokenAuth: []
      responses:
        '200':
          description: Clients list
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: array
                    items:
                      $ref: '#/components/schemas/Client'
              example:
                data:
                  - ID: 199
                    Name: "Михалыч"
                    phone: "+799999999"
                    Discount: 1.0

security:
  - basicAuth: []
  - tokenAuth: []
