# Update Product Stock

## OpenAPI Specification

```yaml
openapi: 3.0.1
info:
  title: ''
  description: ''
  version: 1.0.0
paths:
  /v1/products/stock:
    put:
      summary: Update Product Stock
      deprecated: false
      description: |-
        อัพเดทจำนวนสินค้าในระบบ
        **สามารถอัพเดท product ที่ inactive ได้

        รายละเอียด error ที่สามารถพบได้

        - ไม่พบ product code นี้ในระบบ (product code not found)
        - กรุณากรอก product code (require product code)
      tags:
        - Venio/Product
      parameters:
        - name: Content-Type
          in: header
          description: ''
          required: false
          example: application/json
          schema:
            type: string
        - name: Ocp-Apim-Subscription-Key
          in: header
          description: ''
          required: false
          example: <Your Subscription-Key>
          schema:
            type: string
      requestBody:
        content:
          application/json:
            schema:
              type: array
              items:
                type: object
                properties:
                  productCode:
                    type: string
                    x-apidog-mock: PD001
                    description: รหัสของ Product
                  warehouses:
                    type: object
                    properties:
                      warehouseCode:
                        type: string
                        x-apidog-mock: WH001
                        description: รหัสของ Warehouse
                      qty:
                        type: number
                        x-apidog-mock: '50'
                        description: qty ของ Product แยกตาม Warehouse
                      lowStockAlert:
                        type: number
                        x-apidog-mock: '5'
                        description: แจ้งเตือนเมื่อ qty เหลือ
                    x-apidog-orders:
                      - warehouseCode
                      - qty
                      - lowStockAlert
                    required:
                      - warehouseCode
                      - qty
                      - lowStockAlert
                    x--orders:
                      - warehouseCode
                      - qty
                      - lowStockAlert
                    x--ignore-properties: []
                required:
                  - productCode
                  - warehouses
                x-apidog-orders:
                  - productCode
                  - warehouses
                x--orders:
                  - productCode
                  - warehouses
                x--ignore-properties: []
            example:
              - productCode: PD001
                warehouses:
                  - warehouseCode: WH001
                    qty: 50
                    lowStockAlert: 5
                  - warehouseCode: WH002
                    qty: 30
                    lowStockAlert: 3
      responses:
        '200':
          description: ''
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: array
                    items:
                      type: object
                      properties:
                        productCode:
                          type: string
                          description: product code ในระบบ venio
                        isSuccess:
                          type: boolean
                          description: สถานะการอัพเดทจำนวนสินค้าของ product code
                        error:
                          type: object
                          properties:
                            description:
                              type: string
                              description: รายละเอียดข้อมูลที่ผิดพลาดของ product code
                          required:
                            - description
                          x-apidog-orders:
                            - description
                          description: ข้อมูลที่ผิดพลาดเมื่อ isSuccess = false
                          x--orders:
                            - description
                          x--ignore-properties: []
                        warehouses:
                          type: object
                          properties:
                            warehouseCode:
                              type: string
                              description: รหัสคลังสินค้า
                            qty:
                              type: string
                              description: qty ของ Product แยกตาม Warehouse
                            allocatedQty:
                              type: string
                              description: จำนวนสินค้าที่ติดจอง
                            availableQty:
                              type: string
                              description: จำนวนสินค้าที่พร้อมขาย
                            lowStockAlert:
                              type: string
                              description: แจ้งเตือนเมื่อ qty เหลือ
                            isSuccess:
                              type: boolean
                              description: สถานะการอัพเดทข้อมูล
                          x-apidog-orders:
                            - warehouseCode
                            - qty
                            - allocatedQty
                            - availableQty
                            - lowStockAlert
                            - isSuccess
                          required:
                            - warehouseCode
                            - qty
                            - allocatedQty
                            - availableQty
                            - lowStockAlert
                            - isSuccess
                          description: ข้อมูลสินค้าแยกตาม warehouse
                          x--orders:
                            - warehouseCode
                            - qty
                            - allocatedQty
                            - availableQty
                            - lowStockAlert
                            - isSuccess
                          x--ignore-properties: []
                      required:
                        - productCode
                        - isSuccess
                        - error
                        - warehouses
                      x-apidog-orders:
                        - productCode
                        - warehouses
                        - isSuccess
                        - error
                      x--orders:
                        - productCode
                        - isSuccess
                        - error
                        - warehouses
                      x--ignore-properties: []
                  statusCode:
                    type: integer
                    description: สถานะการทำงานของระบบ
                  httpStatusCode:
                    type: integer
                required:
                  - data
                  - statusCode
                  - httpStatusCode
                x-apidog-orders:
                  - data
                  - statusCode
                  - httpStatusCode
                x--orders:
                  - data
                  - statusCode
                  - httpStatusCode
                x--ignore-properties: []
              examples:
                '1':
                  summary: Success
                  value:
                    data:
                      - productCode: PD001
                        warehouses:
                          - warehouseCode: WH001
                            qty: 50
                            availableQty: 49
                            allocatedQty: 1
                            lowStockAlert: 5
                          - warehouseCode: WH002
                            qty: 30
                            availableQty: 49
                            allocatedQty: 1
                            lowStockAlert: 3
                    statusCode: 1000
                    httpStatusCode: 200
                '2':
                  summary: Success
                  value:
                    hasError: true
                    errorMessage: Empty Payload
                    statusCode: 1102
                    httpStatusCode: 400
          headers: {}
          x-apidog-name: Success
        '400':
          description: ''
          content:
            application/json:
              schema:
                type: object
                properties:
                  hasError:
                    type: boolean
                  errorMessage:
                    type: string
                    description: รายละเอียดข้อมูลที่ผิดพลาด
                  statusCode:
                    type: integer
                    description: สถานะการทำงานของระบบ
                  httpStatusCode:
                    type: integer
                required:
                  - hasError
                  - errorMessage
                  - statusCode
                  - httpStatusCode
                x-apidog-orders:
                  - hasError
                  - errorMessage
                  - statusCode
                  - httpStatusCode
                x--orders:
                  - hasError
                  - errorMessage
                  - statusCode
                  - httpStatusCode
                x--ignore-properties: []
          headers: {}
          x-apidog-name: Bad Request
        x-200:User authentication required V2.:
          description: ''
          content:
            application/json:
              schema:
                title: ''
                type: object
                properties:
                  data:
                    $ref: '#/components/schemas/Required%20authorization'
                  status:
                    $ref: '#/components/schemas/Response%20Error%20Msg%20'
                required:
                  - data
                  - status
                x-apidog-orders:
                  - data
                  - status
                x--orders:
                  - data
                  - status
                x--ignore-properties: []
              example:
                data:
                  subCode: E9103
                  description: Authorization credentials required
                  metadata: {}
                status:
                  code: '4001'
                  description: Business error with 1 errors
          headers: {}
          x-apidog-name: User authentication required V2.
      security:
        - bearer: []
      x-apidog-folder: Venio/Product
      x-apidog-status: developing
      x-run-in-apidog: https://app.apidog.com/web/project/351895/apis/api-9077337-run
components:
  schemas:
    'Response Error Msg ':
      type: object
      properties:
        code:
          type: string
          x--mock: '4001'
        description:
          type: string
          x--mock: Business error with 1 errors
      required:
        - code
        - description
      x-apidog-orders:
        - code
        - description
      x--orders:
        - code
        - description
      x--ignore-properties: []
      x-apidog-folder: ''
    Required authorization:
      type: object
      properties:
        subCode:
          type: string
          x--mock: E9103
        description:
          type: string
          x--mock: Authorization credentials required
        metadata:
          type: object
          properties: {}
          x-apidog-orders: []
          x--orders: []
          x--ignore-properties: []
      required:
        - subCode
        - description
        - metadata
      x-apidog-orders:
        - subCode
        - description
        - metadata
      x--orders:
        - subCode
        - description
        - metadata
      x--ignore-properties: []
      x-apidog-folder: ''
  securitySchemes:
    bearerAuth:
      type: jwt
      scheme: bearer
      bearerFormat: JWT
      description: ใส่ JWT Token ในรูปแบบ Bearer {token}
    bearer:
      type: http
      scheme: bearer
servers:
  - url: https://api.gofive.co.th
    description: Production
security:
  - bearerAuth: []
    x-apidog:
      schemeGroups:
        - id: uyL_cJmK7q60QJZRTi5ot
          schemeIds:
            - bearerAuth
      required: true
      use:
        id: uyL_cJmK7q60QJZRTi5ot
      scopes:
        uyL_cJmK7q60QJZRTi5ot:
          bearerAuth: []

```
