openapi: 3.0.1
info:
  title: E-Procurement
  version: 1.0.0
servers:
  - url: https://hamp.autopass.pro
    description: Live server
    x-environment: live
  - url: https://hamp-dev.autopass.pro
    description: Prelive server
    x-environment: prelive
paths:
  /create-avrequest:
    post:
      operationId: create-av-request
      summary: Create AV Request
      description: Create AV Request.
      requestBody:
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/AVRequestCreation"
        required: true
      responses:
        200:
          description: OK.
          content:
            application/json:
              schema:
                allOf:
                  - $ref: "#/components/schemas/ApiResponse"
                  - type: object
                    properties:
                      entities:
                        type: array
                        items:
                          $ref: "#/components/schemas/AVRequest"
  /create-stockrequest:
    post:
      operationId: create-stock-request
      summary: Create Stock Request
      description: Create Stock Request.
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/StockRequestCreation"
      responses:
        200:
          description: OK.
          content:
            application/json:
              schema:
                allOf:
                  - $ref: "#/components/schemas/ApiResponse"
                  - type: object
                    properties:
                      entities:
                        type: array
                        items:
                          $ref: "#/components/schemas/StockRequest"
  /read-portfolio:
    get:
      operationId: read-portfolio
      summary: Read Portfolio
      description: Read Portfolio.
      parameters:
        - in: query
          name: fromTimeString
          schema:
            type: string
            example: 2021/06/15 05:40:00
        - in: query
          name: untilTimeString
          schema:
            type: string
            example: 2021/06/15 05:51:00
      responses:
        200:
          description: Portfolio successfully loaded
          content:
            application/json:
              schema:
                allOf:
                  - $ref: "#/components/schemas/ApiResponse"
  /repush-purchaseorder:
    post:
      operationId: repush-purchase-order
      summary: Repush a Purchase Order
      description: Repush a Purchase Order.
      requestBody:
        content:
          application/json:
        required: true
      responses:
        200:
          description: OK.
          content:
            application/json:
              schema:
                allOf:
                  - $ref: "#/components/schemas/ApiResponse"
                  - type: object
                    properties:
                      entity:
                        $ref: "#/components/schemas/PurchaseOrder"
  /read-purchaseorder:
    get:
      operationId: read-purchase-order
      summary: Read Purchase Order
      description: Read Purchase Order.
      responses:
        200:
          description: OK.
          content:
            application/json:
              schema:
                allOf:
                  - $ref: "#/components/schemas/ApiResponse"
                  - type: object
                    properties:
                      entity:
                        $ref: "#/components/schemas/PurchaseOrder"
  /create-purchaseorder:
    post:
      operationId: create-purchase-order
      summary: Create Purchase Order
      description: Create Purchase Order.
      requestBody:
        required: true
        content:
          application/json:
            example:
              orderClientReference: "012479893147"
              receiverID: "01587"
              kind: purchaseorder
              agentID: CLI0015
              receiverMail: testeur@gmail.com
              receiverPhone: "0300000000"
              receiverAddress:
                kind: address
                addressLine1: ETS THOMAS
                addressLine2: 13 AV DE LA REPUBLIQUE
                city: MONTFERMEIL
                country: France
                postalCode: "93370"
              items:
                - kind: purchaseorderitem
                  requestedProvider: EXALYO
                  productManufacturerCode: "469"
                  productManufacturerReference: 0 250 201 039
                  isExpressDelivery: true
                  orderedQuantity: 1
      responses:
        202:
          description: Accepted.
          content:
            application/json:
              schema:
                allOf:
                  - $ref: "#/components/schemas/ApiResponse"
                  - type: object
                    properties:
                      entity:
                        $ref: "#/components/schemas/PurchaseOrder"
  /read-purchaseorderitem:
    get:
      operationId: read-purchaseorder-item
      summary: Read Purchase Order Item
      description: Read Purchase Order Item.
      responses:
        "200":
          description: OK.
          content:
            application/json:
              schema:
                allOf:
                  - $ref: "#/components/schemas/ApiResponse"
                  - type: object
                    properties:
                      entity:
                        $ref: "#/components/schemas/PurchaseOrderItem"
components:
  schemas:
    Address:
      type: object
      properties:
        kind:
          type: string
          example: address
        addressLine1:
          type: string
          example: ETS THOMAS
        addressLine2:
          type: string
          example: 13 AV DE LA REPUBLIQUE
        city:
          type: string
          example: MONTFERMEIL
        country:
          type: string
          example: FRANCE
        postalCode:
          type: string
          example: 93370
    ApiResponse:
      type: object
      properties:
        messages:
          type: object
          properties:
            content:
              type: string
              example: This is a success message
            gravity:
              type: number
              example: 1
            gravityString:
              type: string
              example: success
            title:
              type: string
              example: Great success
        status:
          type: number
          example: 200
        version:
          type: string
          example: 3410db12087f3bb9fbb6346a1c263b49178b3fe6
    AVRequest:
      type: object
      properties:
        provider:
          type: string
          example: SYN
        productEANReference:
          type: string
          example: 4016987144497
        quantity:
          type: number
          example: 4
        receiverID:
          type: string
          example: ADD_003
        receiverAddress:
          $ref: "#/components/schemas/Address"
    AVRequestCreation:
      type: object
      properties:
        provider:
          type: string
          example: SYN
        productEANReference:
          type: string
          example: 4016987144497
        quantity:
          type: number
          example: 4
        receiverID:
          type: string
          example: ADD_003
        receiverAddress:
          $ref: "#/components/schemas/Address"
    PurchaseOrder:
      type: object
      properties:
        agentID:
          type: string
          example: CLI0015
        items:
          type: array
          items:
            $ref: "#/components/schemas/PurchaseOrderItem"
        orderClientReference:
          type: string
          example: 012479893147
        receiverAddress:
          $ref: "#/components/schemas/Address"
        receiverID:
          type: string
          example: "01587"
        receiverMail:
          type: string
          example: email@example.com
        receiverPhone:
          type: string
          example: 0304050607
    PurchaseOrderCreation:
      type: object
      properties:
        agentID:
          type: string
          example: CLI0015
        items:
          type: array
          items:
            $ref: "#/components/schemas/PurchaseOrderItem"
        orderClientReference:
          type: string
          example: 012479893147
        receiverAddress:
          $ref: "#/components/schemas/Address"
        receiverID:
          type: string
          example: "01587"
        receiverMail:
          type: string
          example: email@example.com
        receiverPhone:
          type: string
          example: 0304050607
    PurchaseOrderItem:
      type: object
      properties:
        isExpressDelivery:
          type: boolean
          example: true
        orderedQuantity:
          type: integer
          example: 42
        productManufacturerCode:
          type: string
          example: 469
        productManufacturerReference:
          type: string
          example: 0 250 201 039
        requestedProvider:
          type: string
          example: EXALYO
    StockRequest:
      type: object
      properties:
        clientFreeText:
          type: string
          example: This is an example
        productEANReference:
          type: string
          example: 5010874764408
    StockRequestCreation:
      type: object
      properties:
        clientFreeText:
          type: string
          example: This is an example
        productEANReference:
          type: string
          example: 5010874764408
          description: Required if used alone.
        productManufacturerCode:
          type: string
          example: 167
          description: Required if used with productEANReference.
        productManufacturerReference:
          type: string
          example: FDB1050
          description: Required if used with productManufacturerCode.
