openapi: 3.0.3
info:
  title: "Up Integration - API Publica de Estoque"
  version: 1.0.0
  description: "API para consulta de estoque por parceiros externos (seguradoras, oficinas, etc)."
servers:
  -
    url: "http://localhost"
tags:
  -
    name: Estoque
    description: Consultas de estoque por token
paths:
  "/api/v1/stock":
    get:
      tags:
        - Estoque
      summary: Lista itens de estoque
      security:
        -
          bearerAuth:

      parameters:
        -
          name: sku
          in: query
          required: false
          schema:
            type: string
        -
          name: ean
          in: query
          required: false
          schema:
            type: string
        -
          name: updated_since
          in: query
          required: false
          schema:
            type: string
            format: "date-time"
        -
          name: page
          in: query
          required: false
          schema:
            type: integer
            minimum: 1
        -
          name: per_page
          in: query
          required: false
          schema:
            type: integer
            minimum: 1
            maximum: 200
      responses:
        200:
          description: Lista de itens
          content:
            "application/json":
              schema:
                type: object
                properties:
                  data:
                    type: array
                    items:
                      "$ref": "#/components/schemas/StockItem"
                  meta:
                    type: object
                    properties:
                      current_page:
                        type: integer
                      per_page:
                        type: integer
                      total:
                        type: integer
                      last_page:
                        type: integer
        401:
          description: Nao autorizado
        422:
          description: Parametro invalido
        429:
          description: Rate limit excedido
  "/api/v1/stock/{sku}":
    get:
      tags:
        - Estoque
      summary: Busca item por SKU
      security:
        -
          bearerAuth:

      parameters:
        -
          name: sku
          in: path
          required: true
          schema:
            type: string
      responses:
        200:
          description: Item encontrado
          content:
            "application/json":
              schema:
                type: object
                properties:
                  data:
                    "$ref": "#/components/schemas/StockItem"
        401:
          description: Nao autorizado
        404:
          description: Item nao encontrado
        429:
          description: Rate limit excedido
components:
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      bearerFormat: Token
  schemas:
    StockItem:
      type: object
      properties:
        source_product_id:
          type: integer
          example: 12345
        sku:
          type: string
          nullable: true
          example: B123
        ean:
          type: string
          nullable: true
          example: 7909501098
        name:
          type: string
          nullable: true
          example: ABSORVEDOR
        brand:
          type: string
          nullable: true
          example: RF
        price:
          type: number
          format: float
          nullable: true
          example: 165.12
        quantity:
          type: integer
          nullable: true
          example: 5
        status:
          type: string
          nullable: true
          example: publish
        product_updated_at:
          type: string
          format: "date-time"
          nullable: true
        snapshot_updated_at:
          type: string
          format: "date-time"
          nullable: true
