parameters:
  - $ref: '../../parameters/submissionId.yaml'
  - $ref: '../../parameters/attachmentId.yaml'

get:
  operationId: get-submission-attachment
  summary: Anlage abrufen
  description: >
    Ruft eine Anlage einer Einreichung im JOSE-Format ab. Genaueres ist in der
    [Dokumentation](https://docs.fitko.de/fit-connect/getting-started/receiving/download-submission) beschrieben
  tags:
    - Einreichungsempfang
  security:
    - OAuth2:
        - 'subscribe:destination:<id>'
  responses:
    '200':
      description: OK
      content:
        application/jose:
          schema:
            $ref: '../../schemas/attachment.yaml'
          examples:
            Beispiel:
              $ref: '../../examples/encrypted-message.yaml'
    '400':
      description: Bad Request
      content:
        application/problem+json:
          schema:
            $ref: ../../schemas/error.yaml
    '401':
      description: Unauthorized
      content:
        application/problem+json:
          schema:
            $ref: ../../schemas/error.yaml
    '403':
      description: Forbidden
      content:
        application/problem+json:
          schema:
            $ref: ../../schemas/error.yaml
    '404':
      description: Submission or attachment not found
      content:
        application/problem+json:
          schema:
            $ref: ../../schemas/error.yaml

put:
  operationId: add-submission-attachment
  summary: Anlage hinzufügen
  description: >
    Hochladen der in `announcedAttachments` angekündigten Anlage im JOSE-Format unter der mitgeteilten UUID. Genaueres
    ist in der [Dokumentation](https://docs.fitko.de/fit-connect/getting-started/sending/attachments) beschrieben.
  tags:
    - Einreichungsübermittlung
  security:
    - OAuth2:
        - 'send:region:DE<region-id>+send:service:<service-uri>'
        - 'send:region:DE<region-id>'
  requestBody:
    required: true
    content:
      application/jose:
        schema:
          $ref: '../../schemas/create-attachment.yaml'
        examples:
          Beispiel:
            $ref: '../../examples/encrypted-message.yaml'
  responses:
    '204':
      description: Anlage erfolgreich hinzugefügt/überschrieben
    '400':
      description: Bad Request
      content:
        application/problem+json:
          schema:
            $ref: ../../schemas/error.yaml
    '401':
      description: Unauthorized
      content:
        application/problem+json:
          schema:
            $ref: ../../schemas/error.yaml
    '403':
      description: Forbidden
      content:
        application/problem+json:
          schema:
            $ref: ../../schemas/error.yaml
    '413': # TODO: Check
      description: Request Entity Too Large
      content:
        application/problem+json:
          schema:
            $ref: ../../schemas/error.yaml
    '415':
      description: Unsupported Media Type (wrong content type sent)
      content:
        application/problem+json:
          schema:
            $ref: ../../schemas/error.yaml
    '422':
      description: Attachment not announced. Must upload attachments under their announced UUIDs.
      content:
        application/problem+json:
          schema:
            $ref: ../../schemas/error.yaml