openapi: 3.1.0
info:
  title: api-web-message-collector
  contact: {}
  license:
    name: MIT License
    url: https://opensource.org/licenses/MIT
  version: "5.1"
servers:
- url: http://localhost:51239
  description: Generated server url
tags:
- name: messages
  description: Messages
paths:
  /{municipalityId}/messages/{instance}/flow-instances/{flowInstanceId}:
    get:
      tags:
      - messages
      summary: Get a list of messages related to a specific flow instance id
      description: Returns a list of messages found for the specified flow instance
        id
      operationId: getMessagesByFlowInstanceId
      parameters:
      - name: municipalityId
        in: path
        description: Municipality Id
        required: true
        schema:
          type: string
        example: 2281
      - name: instance
        in: path
        description: Instance to fetch messages for
        required: true
        schema:
          type: string
        example: INTERNAL
      - name: flowInstanceId
        in: path
        description: Flow instance id to fetch messages for
        required: true
        schema:
          type: string
        example: 1234567890
      - name: fromDateTime
        in: query
        description: The start date and time for filtering web messages (optional)
        required: false
        schema:
          type: string
          format: date-time
        example: 2024-01-31T12:00:00
      - name: toDateTime
        in: query
        description: The end date and time for filtering web messages (optional).
        required: false
        schema:
          type: string
          format: date-time
        example: 2024-01-31T12:00:00
      responses:
        "400":
          description: Bad request
          content:
            application/problem+json:
              schema:
                oneOf:
                - $ref: "#/components/schemas/Problem"
                - $ref: "#/components/schemas/ConstraintViolationProblem"
        "404":
          description: Not found
          content:
            application/problem+json:
              schema:
                $ref: "#/components/schemas/Problem"
        "500":
          description: Internal Server error
          content:
            application/problem+json:
              schema:
                $ref: "#/components/schemas/Problem"
        "200":
          description: Successful Operation
          content:
            application/json:
              schema:
                type: array
                items:
                  $ref: "#/components/schemas/MessageDTO"
  /{municipalityId}/messages/{instance}/attachments/{attachmentId}:
    get:
      tags:
      - messages
      summary: Get an attachment by id
      description: Returns an attachment as a stream for the specified attachmentId
      operationId: getAttachmentById
      parameters:
      - name: municipalityId
        in: path
        description: Municipality Id
        required: true
        schema:
          type: string
        example: 2281
      - name: instance
        in: path
        description: Instance to fetch messages for
        required: true
        schema:
          type: string
        example: INTERNAL
      - name: attachmentId
        in: path
        description: Id of the requested attachment
        required: true
        schema:
          type: integer
          format: int32
        example: 1234567890
      responses:
        "400":
          description: Bad request
          content:
            application/problem+json:
              schema:
                oneOf:
                - $ref: "#/components/schemas/Problem"
                - $ref: "#/components/schemas/ConstraintViolationProblem"
        "404":
          description: Not found
          content:
            application/problem+json:
              schema:
                $ref: "#/components/schemas/Problem"
        "500":
          description: Internal Server error
          content:
            application/problem+json:
              schema:
                $ref: "#/components/schemas/Problem"
        "200":
          description: Successful Operation
  /{municipalityId}/messages/{familyId}/{Instance}:
    get:
      tags:
      - messages
      summary: Get a list of messages related to a specific familyId
      description: Returns a list of messages found for the specified familyId
      operationId: getMessages
      parameters:
      - name: municipalityId
        in: path
        description: Municipality Id
        required: true
        schema:
          type: string
        example: 2281
      - name: familyId
        in: path
        description: FamilyId to fetch messages for
        required: true
        schema:
          type: string
        example: 123
      - name: Instance
        in: path
        description: Instance to fetch messages for
        required: true
        schema:
          type: string
        example: INTERNAL
      responses:
        "400":
          description: Bad request
          content:
            application/problem+json:
              schema:
                oneOf:
                - $ref: "#/components/schemas/Problem"
                - $ref: "#/components/schemas/ConstraintViolationProblem"
        "404":
          description: Not found
          content:
            application/problem+json:
              schema:
                $ref: "#/components/schemas/Problem"
        "500":
          description: Internal Server error
          content:
            application/problem+json:
              schema:
                $ref: "#/components/schemas/Problem"
        "200":
          description: Successful Operation
          content:
            application/json:
              schema:
                type: array
                items:
                  $ref: "#/components/schemas/MessageDTO"
  /{municipalityId}/messages/attachments/{attachmentId}:
    get:
      tags:
      - messages
      summary: Get a messageAttachment
      description: Returns a messageAttachment as a stream for the specified attachmentId
      operationId: getAttachment
      parameters:
      - name: municipalityId
        in: path
        description: Municipality Id
        required: true
        schema:
          type: string
        example: 2281
      - name: attachmentId
        in: path
        description: MessageId to fetch attachment for
        required: true
        schema:
          type: integer
          format: int32
        example: 123
      responses:
        "400":
          description: Bad request
          content:
            application/problem+json:
              schema:
                oneOf:
                - $ref: "#/components/schemas/Problem"
                - $ref: "#/components/schemas/ConstraintViolationProblem"
        "404":
          description: Not found
          content:
            application/problem+json:
              schema:
                $ref: "#/components/schemas/Problem"
        "500":
          description: Internal Server error
          content:
            application/problem+json:
              schema:
                $ref: "#/components/schemas/Problem"
        "200":
          description: Successful Operation
    delete:
      tags:
      - messages
      summary: Delete a messageAttachment
      description: Deletes a messageAttachment with the specified id
      operationId: deleteAttachment
      parameters:
      - name: municipalityId
        in: path
        description: Municipality Id
        required: true
        schema:
          type: string
        example: 2281
      - name: attachmentId
        in: path
        description: Id of the attachment to delete
        required: true
        schema:
          type: integer
          format: int32
        example: 123
      responses:
        "400":
          description: Bad request
          content:
            application/problem+json:
              schema:
                oneOf:
                - $ref: "#/components/schemas/Problem"
                - $ref: "#/components/schemas/ConstraintViolationProblem"
        "404":
          description: Not found
          content:
            application/problem+json:
              schema:
                $ref: "#/components/schemas/Problem"
        "500":
          description: Internal Server error
          content:
            application/problem+json:
              schema:
                $ref: "#/components/schemas/Problem"
        "204":
          description: No Content
  /api-docs:
    get:
      tags:
      - API
      summary: OpenAPI
      operationId: getApiDocs
      responses:
        "200":
          description: OK
          content:
            application/yaml:
              schema:
                type: string
      x-auth-type: None
      x-throttling-tier: Unlimited
      x-wso2-mutual-ssl: Optional
  /{municipalityId}/messages:
    delete:
      tags:
      - messages
      summary: Delete a list of messages
      description: Deletes a list of messages with the ids provided
      operationId: deleteMessages
      parameters:
      - name: municipalityId
        in: path
        description: Municipality Id
        required: true
        schema:
          type: string
        example: 2281
      requestBody:
        content:
          application/json:
            schema:
              type: array
              items:
                type: integer
                format: int32
        required: true
      responses:
        "400":
          description: Bad request
          content:
            application/problem+json:
              schema:
                oneOf:
                - $ref: "#/components/schemas/Problem"
                - $ref: "#/components/schemas/ConstraintViolationProblem"
        "404":
          description: Not found
          content:
            application/problem+json:
              schema:
                $ref: "#/components/schemas/Problem"
        "500":
          description: Internal Server error
          content:
            application/problem+json:
              schema:
                $ref: "#/components/schemas/Problem"
        "204":
          description: No Content
components:
  schemas:
    Problem:
      type: object
      properties:
        title:
          type: string
        detail:
          type: string
        instance:
          type: string
          format: uri
        type:
          type: string
          format: uri
        status:
          type: integer
          format: int32
    ConstraintViolationProblem:
      type: object
      properties:
        type:
          type: string
          format: uri
        status:
          type: integer
          format: int32
        violations:
          type: array
          items:
            $ref: "#/components/schemas/Violation"
        title:
          type: string
        detail:
          type: string
        causeAsProblem:
          $ref: "#/components/schemas/ThrowableProblem"
        instance:
          type: string
          format: uri
    ThrowableProblem:
      type: object
      properties:
        type:
          type: string
          format: uri
        title:
          type: string
        status:
          type: integer
          format: int32
        detail:
          type: string
        instance:
          type: string
          format: uri
        causeAsProblem: {}
    Violation:
      type: object
      properties:
        field:
          type: string
        message:
          type: string
    MessageAttachment:
      type: object
      properties:
        attachmentId:
          type: integer
          format: int32
          description: The Id for the attachment
          examples:
          - 1
        name:
          type: string
          description: The name of the file
          examples:
          - file.txt
        extension:
          type: string
          description: The extension of the file
          examples:
          - txt
        mimeType:
          type: string
          description: The mime type of the file
          examples:
          - text/plain
    MessageDTO:
      type: object
      properties:
        id:
          type: integer
          format: int32
          description: The webMessageCollector Id for the message
          examples:
          - 1
        direction:
          type: string
          description: If the message is inbound or outbound from the perspective
            of case-data/e-service.
          enum:
          - INBOUND
          - OUTBOUND
          examples:
          - INBOUND
        municipalityId:
          type: string
          description: The municipality id
          examples:
          - "2281"
        familyId:
          type: string
          description: What E-service the message was found in
          examples:
          - "501"
        externalCaseId:
          type: string
          description: 'The external caseID '
          examples:
          - caa230c6-abb4-4592-ad9a-34e263c2787b
        message:
          type: string
          description: 'The message '
          examples:
          - Hello World
        messageId:
          type: string
          description: The unique messageId from openE for the message
          examples:
          - "12"
        sent:
          type: string
          description: 'Time and date the message was sent '
          examples:
          - 2023-02-23 17:26:23
        username:
          type: string
          description: Username for the poster
          examples:
          - te01st
        firstName:
          type: string
          description: 'Firstname of the poster '
          examples:
          - Test
        lastName:
          type: string
          description: Lastname of the poster
          examples:
          - Testsson
        email:
          type: string
          description: Email for the poster
          examples:
          - test@sundsvall.se
        userId:
          type: string
          description: The userId for the poster
          examples:
          - "123"
        attachments:
          type: array
          items:
            $ref: "#/components/schemas/MessageAttachment"
            description: List of attachments for the message
            examples:
            - "attachment1, attachment2"
        instance:
          type: string
          description: The instance of the message
          examples:
          - external
  securitySchemes: {}
