openapi: 3.1.1
info:
  description:
    "APIs voor het bestellen van een order voor ubo. Het is ook mogelijk om individuele order status te zien of een\
    \ overzicht van actief of oude orders te zien"
  title: API-Kanaal Order bestellingen
  version: "4.0"
servers:
  - description: Production API
    url: https://api-secure.kvk.nl
security:
  - ApiKeyAuth: []
  - oAuth2: []
    mutualTLS: []
tags:
  - name: UBO
  - name: Order
  - name: VBU
paths:
  /api/v1/order/uittreksels/ubo:
    parameters: []
    post:
      description: Bestellen van een UBO
      operationId: inleggenOrderUbo
      requestBody:
        content:
          application/json:
            example:
              orderReferentie: Mijn order referentie
              orderRegels:
                - kvkNummer: "22222222"
                  productOpties:
                    uboOpties:
                      priveVolledig: false
            schema:
              $ref: "#/components/schemas/ApiOrderRequest"
        required: true
      responses:
        "201":
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/OrderAanmakenResponse"
          description: Order aanmaken respons
        "400":
          $ref: "#/components/responses/BadRequest"
        "401":
          $ref: "#/components/responses/Unauthorized"
        "403":
          $ref: "#/components/responses/Forbidden"
        "404":
          $ref: "#/components/responses/NotFound"
        "412":
          $ref: "#/components/responses/PreconditionFailed"
        "429":
          $ref: "#/components/responses/TooManyRequests"
        "500":
          $ref: "#/components/responses/InternalServerError"
      summary: UBO
      tags:
        - UBO
  /api/v1/orders/status/{orderNummer}:
    get:
      description: Ophalen van order status
      operationId: ophalenOrderStatus
      responses:
        "200":
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/OrderStatusResponse"
          description: Order status respons
        "400":
          $ref: "#/components/responses/BadRequest"
        "401":
          $ref: "#/components/responses/Unauthorized"
        "403":
          $ref: "#/components/responses/Forbidden"
        "404":
          $ref: "#/components/responses/NotFound"
        "412":
          $ref: "#/components/responses/PreconditionFailed"
        "429":
          $ref: "#/components/responses/TooManyRequests"
        "500":
          $ref: "#/components/responses/InternalServerError"
      summary: Order status
      tags:
        - Order
    parameters:
      - explode: false
        in: path
        name: orderNummer
        required: true
        schema:
          type: string
        style: simple
  /api/v1/vbu/uittreksels/{orderNummer}.pdf:
    get:
      description: Ophalen van UBO uittreksel
      operationId: ophalenUboUittreksel
      responses:
        "200":
          content:
            application/pdf:
              schema:
                type: string
                format: binary
          description: UBO PDF
      summary: Order status
      tags:
        - VBU
    parameters:
      - explode: false
        in: path
        name: orderNummer
        required: true
        schema:
          type: string
        style: simple
components:
  responses:
    BadRequest:
      content:
        application/json:
          schema:
            properties:
              status:
                $ref: "#/components/schemas/ProblemDetail"
            type: object
      description: Bad Request
    NotFound:
      content:
        application/json:
          schema:
            properties:
              status:
                $ref: "#/components/schemas/ProblemDetail"
            type: object
      description: Not Found
    PreconditionFailed:
      content:
        application/json:
          schema:
            properties:
              status:
                $ref: "#/components/schemas/ProblemDetail"
            type: object
      description: Precondition failed
    TooManyRequests:
      content:
        application/json:
          schema:
            properties:
              status:
                $ref: "#/components/schemas/ProblemDetail"
            type: object
      description: Too many requests
    InternalServerError:
      content:
        application/json:
          schema:
            properties:
              status:
                $ref: "#/components/schemas/ProblemDetail"
            type: object
      description: Internal Server Error
    Unauthorized:
      content:
        application/json:
          schema:
            properties:
              status:
                $ref: "#/components/schemas/ProblemDetail"
            type: object
      description: Forbidden
    Forbidden:
      content:
        application/json:
          schema:
            properties:
              status:
                $ref: "#/components/schemas/ProblemDetail"
            type: object
      description: Forbidden
  schemas:
    OrderStatusResponse:
      description: Order status respons
      properties:
        order:
          $ref: "#/components/schemas/OrderStatus"
      type: object
    OrderAanmaken:
      description: Informatie over de order
      properties:
        nummer:
          type: string
        status:
          enum:
            - IN_AFWACHTING
            - GEREED
            - FOUT
          type: string
      type: object
    OrderStatus:
      description: Informatie over de order
      properties:
        nummer:
          type: string
        referentie:
          type: string
        status:
          enum:
            - IN_AFWACHTING
            - GEREED
            - FOUT
          type: string
        downloadUrl:
          type: string
        vervalDatum:
          type: string
        vervallen:
          type: boolean
      type: object
    OrderOverzicht:
      description: Overzicht van een order
      properties:
        nummer:
          type: string
        referentie:
          type: string
        tijdstip:
          type: string
        regels:
          items:
            $ref: "#/components/schemas/OrderRegelOverzicht"
          type: array
        status:
          enum:
            - IN_AFWACHTING
            - GEREED
            - FOUT
          type: string
      type: object
    OrderRegelOverzicht:
      description: Overzicht van een orderregel
      properties:
        volgNr:
          type: integer
        downloadUrl:
          type: string
        vervalDatum:
          format: date-time
          type: string
        vervallen:
          type: boolean
        status:
          enum:
            - IN_AFWACHTING
            - GEREED
            - FOUT
          type: string
      type: object

    ApiOrderRequest:
      description: OrderRequest
      properties:
        orderReferentie:
          description: Custom klant orderreferentie
          pattern: "^[a-zA-Z0-9\\.\\\\/]{3,50}"
          type: string
        orderRegels:
          items:
            $ref: "#/components/schemas/ApiOrderRegel"
          minLength: 1
          type: array
      required:
        - orderRegels
      type: object
    OrderAanmakenResponse:
      properties:
        order:
          $ref: "#/components/schemas/OrderAanmaken"
        status:
          $ref: "#/components/schemas/OrderResponseStatus"
      type: object
    OrderResponse:
      properties:
        order:
          $ref: "#/components/schemas/OrderStatus"
        status:
          $ref: "#/components/schemas/OrderResponseStatus"
      type: object
    ApiOrderRegel:
      description: Een orderregel die minimaal een kvkNummer gevuld moet hebben
      properties:
        kvkNummer:
          pattern: "^[0-9]{8}"
          type: string
        vestigingsnummer:
          pattern: "^[0-9]{12}"
          type: string
        productOpties:
          $ref: "#/components/schemas/ApiProductOpties"
      required:
        - kvkNummer
        - productOpties
      type: object
    ApiProductOpties:
      properties:
        uboOpties:
          $ref: "#/components/schemas/ApiUboOpties"
      type: object
    ApiUboOpties:
      properties:
        priveVolledig:
          type: boolean
      type: object
    OrderResponseStatus:
      properties:
        code:
          nullable: false
          type: string
        omschrijving:
          nullable: false
          type: string
      required:
        - code
        - omschrijving
    ProblemDetail:
      description: |-
        De mogelijke statuscodes die terug kunnen worden gegeven:
          * IPD0000 - Bevraging succesvol afgehandeld.
          * IPD0004 - Het KvK-nummer <kvknummer> is niet valide.
          * IPD0005 - Op basis van het KvK-nummer <kvknummer> kan het product niet worden geleverd.
          * IPD0020 - Er is geen UBO-registerdocument gevonden op basis van KVK-nummer
          * IPD0021 - De afnemer heeft niet het juiste autorisatieniveau om het product te kunnen bestellen.
          * IPD1002 - Blokkade op dossier.
          * IPD9999 - Algemene technische fout.
      properties:
        type:
          enum:
            - '["tag:IPD0000","tag:IPD0004","tag:IPD0005"
              ,"tag:IPD0020","tag:IPD0021","tag:IPD1002","tag:IPD9999"]'
          nullable: false
          type: string
        title:
          nullable: true
          type: string
        status:
          nullable: false
          type: number
        detail:
          nullable: true
          type: string
        instance:
          nullable: true
          type: string
        properties:
          additionalProperties:
            type: object
          nullable: true
          type: object
      type: object
  securitySchemes:
    ApiKeyAuth:
      type: apiKey
      in: header
      name: apikey
    oAuth2:
      type: oauth2
      description: OAuth2 with the clientCredentials grant flow.
      flows:
        clientCredentials:
          authorizationUrl: /auth/oauth/v2/token
          tokenUrl: /auth/oauth/v2/token
    mTLS:
      type: mutualTLS
      description: When using OAuth2 a certificate should be privided to create a connection
