openapi: 3.0.3
info:
  title: LV - Service API v1.0.8
  description: |-
    This is a draft version of LV Service API v1.0.8 (OpenAPI 3.0)

    Service API provided by LV service:
    - [Luvat ja Valvonta website](https://lv.ahtp.fi)

  termsOfService: https://lv.ahtp.fi/fi/kayttoehdot
  contact:
    email: tuki.lv@ely-keskus.fi
  version: v1.0.8
externalDocs:
  description: Find out more about Swagger
  url: http://swagger.io
paths:
  /commondata/{externalId}/commondata:
    get:
      summary: Common data
      description: Retrive common data related to project part
      operationId: GetProjectPartCommonData
      parameters:
        - name: externalId
          in: path
          description: Project part action's external id
          required: true
          schema:
            type: string
            format: guid
      responses:
        '200':
          description: successful operation
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Commondata'
        '400':
          description: Project part action not found with externalId
        '401':
          description: Unauthorized request
  /commondata/{externalId}/formdata:
    get:
      summary: Form data
      description: Retrieve only formData related to project part action
      operationId: GetProjectPartFormData
      parameters:
        - name: externalId
          in: path
          description: Project part action's external id
          required: true
          schema:
            type: string
            format: guid
      responses:
        '200':
          description: successful operation
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Formdata'
        '400':
          description: Project part action not found with externalId
        '401':
          description: Unauthorized request
  /commondata/{externalId}:
    get:
      summary: Project part data
      description: Retrieve all necessary data related to project part action
      operationId: GetProjectPartData
      parameters:
        - name: externalId
          in: path
          description: Project part action's external id
          required: true
          schema:
            type: string
            format: guid
      responses:
        '200':
          description: successful operation
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ProjectPartData'
        '400':
          description: Project part action not found with externalId
        '401':
          description: Unauthorized request
  /commondata/{externalId}/formconfig:
    get:
      summary: Form config
      description: Retrieve only formConfig related to project part action
      operationId: GetProjectPartFormConfig
      parameters:
        - name: externalId
          in: path
          description: Project part action's external id
          required: true
          schema:
            type: string
            format: guid
      responses:
        '200':
          description: successful operation
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Formconfig'
        '400':
          description: Project part action not found with externalId
        '401':
          description: Unauthorized request
  /commondata/{externalId}/accesslink:
    get:
      summary: Access link
      description: Retrieve project part action access link for authorities
      operationId: GetProjectPartAccessLink
      parameters:
        - name: externalId
          in: path
          description: Project part action's external id
          required: true
          schema:
            type: string
            format: guid
      responses:
        '200':
          description: successful operation
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Accesslink'
        '400':
          description: Project part action not found with externalId
        '401':
          description: Unauthorized request
  /commondata/{externalId}/diarynumber:
    get:
      summary: Project part diary number
      description: Retrieve diary number for project part action
      operationId: GetProjectPartDiaryNumber
      parameters:
        - name: externalId
          in: path
          description: Project part action's external id
          required: true
          schema:
            type: string
            format: guid
      responses:
        '200':
          description: successful operation
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Diarynumber'
        '400':
          description: Project part action not found with externalId
        '401':
          description: Unauthorized request
    put:
      summary: Update diary number for project part
      description: update project part's diary number
      operationId: UpdateProjectPartDiaryNumber
      parameters:
        - name: externalId
          in: path
          description: Project part action's external id
          required: true
          schema:
            type: string
            format: guid      
      requestBody:
        description: Update diary number
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/DiaryNumber'
        required: true
      responses:
        '200':
          description: Successful operation
        '401':
          description: Unauthorized request
        '400':
          description: Project part action not found with externalId       
  /commondata/{externalId}/status:
    get:
      summary: Project part status
      description: Retrieve status for project part action
      operationId: GetProjectPartStatus
      parameters:
        - name: externalId
          in: path
          description: Project part action's external id
          required: true
          schema:
            type: string
            format: guid
      responses:
        '200':
          description: successful operation
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ProjectPartStatus'
        '400':
          description: Project part action not found with externalId
        '401':
          description: Unauthorized request
    put:
      summary: Update status for project part
      description: Update project part's status
      operationId: UpdateProjectPartStatus
      parameters:
        - name: externalId
          in: path
          description: Project part action's external id
          required: true
          schema:
            type: string
            format: guid      
      requestBody:
        description: Change project part status
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/StatusChange'
        required: true
      responses:
        '200':
          description: Successful operation
        '401':
          description: Unauthorized request
        '400':
          description: Project part action not found with externalId      
  /commondata/{externalId}/statuses:
    get:
      summary: Available statuses for project part
      description: Retrieve all available statuses for project part action
      operationId: GetProjectPartStatusess
      parameters:
        - name: externalId
          in: path
          description: Project part action's external id
          required: true
          schema:
            type: string
            format: guid
      responses:
        '200':
          description: successful operation
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Statuses'
        '400':
          description: Project part action not found with externalId
        '401':
          description: Unauthorized request
  /commondata/{externalId}/handlingofficers:
    put:
      summary: Update handling officers for project part
      description: Update project part's handling officers
      operationId: UpdateProjectPartHandlingOfficers
      parameters:
        - name: externalId
          in: path
          description: Project part action's external id
          required: true
          schema:
            type: string
            format: guid      
      requestBody:
        description: Update project part handling officers
        content:
          application/json:
            schema:
              type: array
              items:
                $ref: '#/components/schemas/Officer'
        required: true
      responses:
        '200':
          description: Successful operation
        '401':
          description: Unauthorized request
        '400':
          description: Project part action not found with externalId 
  /commondata/{externalId}/attachment/{fileId}:
    get:
      summary: Project part metadata of attachment file
      description: Get's ProjectPart's single attachment metadata
      operationId: GetProjectPartAttachment
      parameters:
        - name: externalId
          in: path
          description: Project part action's external id
          required: true
          schema:
            type: string
            format: guid
        - name: fileId
          in: path
          description: Unique attachment file id
          required: true
          schema:
            type: integer
      responses:
        '200':
          description: successful operation
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ProjectPartAttachment'
        '400':
          description: File not found with fileId or project part not found with externalId
        '401':
          description: Unauthorized request
  /commondata/{externalId}/attachments:
    get:
      summary: Project part metadata of attachment files
      description: Get's ProjectPart's metadata of attachments
      operationId: GetProjectPartAttachments
      parameters:
        - name: externalId
          in: path
          description: Project part action's external id
          required: true
          schema:
            type: string
            format: guid
      responses:
        '200':
          description: successful operation
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ProjectPartAttachments'
        '400':
          description: Project part not found with externalId
        '401':
          description: Unauthorized request
  /commondata/attachment/{externalId}/file/{fileId}:
    get:
      summary: Project part attachment file by
      description: Get ProjectPart's file attachment by ID
      operationId: GetProjectPartAttachmentFile
      parameters:
        - name: externalId
          in: path
          description: Project part action's external id
          required: true
          schema:
            type: string
            format: guid
        - name: fileId
          in: path
          description: Unique attachment file id
          required: true
          schema:
            type: integer
      responses:
        '200':
          description: successful operation
          content:
            application/octet-stream:
              schema:
                type: string
                format: binary
        '400':
          description: File not found with fileId or Project part not found with externalId
        '401':
          description: Unauthorized request
  /commondata/attachment/{externalId}/files:
    get:
      summary: Project part attachment files as zip
      description: Retrive multiple file attachments as compressed file (.zip)
      operationId: GetProjectPartAttachmentFiles
      parameters:
        - name: externalId
          in: path
          description: Project part action's external id
          required: true
          schema:
            type: string
            format: guid
      responses:
        '200':
          description: successful operation
          content:
            application/octet-stream:
              schema:
                type: string
                format: binary
        '400':
          description: Project part not found with externalId
        '401':
          description: Unauthorized request
components:
  schemas:
    Commondata:
      type: object
      properties:
        name:
          type: string
          format: text
          example: TestAction A
        externalId:
          type: string
          format: guid
          example: XXXXX-XXXXX-XXXXX-XXXXX
        actionId:
          type: integer
          format: int32
          example: 7
        diaryNumber:
          type: string
          format: text
          example: xxx-xxx-xxx
        projectPartSpecification:
          type: object
          properties:
            Name:
              type: string
            Translations:
              type: string
        status:
          $ref: '#/components/schemas/ProjectPartStatus'
        handlingOfficers:
          type: array
          items:
            $ref: '#/components/schemas/Officer'
        advisorOfficers:
          type: array
          items:
            $ref: '#/components/schemas/Officer'
        transaction:
          type: object
          $ref: '#/components/schemas/Transaction'
        userEmailInfo:
          type: object
          $ref: '#/components/schemas/UserEmailInfo'
    Formconfig:
      type: string
      example:
        formConfig: "Project part form config json object"
    Formdata:
      type: object
      properties:
        formData:
          type: string
          example: '{"toiminnanharjoittajaSivu":{"toiminnanharjoittajanPerustiedotOsio":{"toiminnanharjoittajanNimiTietue":"Demo, Nordea","yTunnusTietue":"-"},"yhteystiedotOsio":{"kayntiosoiteEriKuinPostiosoiteGroup":{"selected":"","lahiosoiteTietue":"","postinumeroTietue":"","postitoimipaikkaTietue":""},"lahiosoiteTaiPlTietue":"Testiosoite","postinumeroTietue":"33100","postitoimipaikkaTietue":"Testilä","puhelinnumeroTietue":"0409876543","sahkopostiTietue":"testi.testi@test.com","roolitTietue":[{"rooliIdTietue":4,"rooliTunnisteTietue":"ElintarvikeasioidenYhteyshenkilo","rooliNimiTietue":"Elintarvikeasioiden yhteyshenkilö"}]},"laskutustiedotOsio":{"laskutustiedotGroup":{"selected":"Verkkolasku"}}},"tapahtumanKuvauksetSivu":{"tapahtumanKuvauksetOsio":{"tapahtumanNimiTietue":"Tapahtumajärjestäminen"}},"tapahtumaSivu":{"tapahtumapaikkaAlueOsio":{"kayntiosoiteTietue":null,"kayntiosoitteenPostinumeroTietue":null,"kayntiosoitteenPostitoimipaikkaTietue":null}}}'
        attachmentMetaDatas:
          type: array
          items:
            $ref: '#/components/schemas/AttachmentMetadata'
        infoRequests:
          type: object
          properties:
            infoRequests:
              type: array
              items:
                $ref: '#/components/schemas/InfoRequestItem'
    Accesslink:
      type: string
      example:
        accessLink: "Project part service url for authorities"
    Diarynumber:
      type: string
      example:
        diaryNumber: "xxx-xxx-xxx"
    ProjectPartData:
      type: object
      properties:
        commonData:
          type: object
          $ref: '#/components/schemas/Commondata'
        formData:
          type: string
          example: '{"toiminnanharjoittajaSivu":{"toiminnanharjoittajanPerustiedotOsio":{"toiminnanharjoittajanNimiTietue":"Demo, Nordea","yTunnusTietue":"-"},"yhteystiedotOsio":{"kayntiosoiteEriKuinPostiosoiteGroup":{"selected":"","lahiosoiteTietue":"","postinumeroTietue":"","postitoimipaikkaTietue":""},"lahiosoiteTaiPlTietue":"Testiosoite","postinumeroTietue":"33100","postitoimipaikkaTietue":"Testilä","puhelinnumeroTietue":"0409876543","sahkopostiTietue":"testi.testi@test.com","roolitTietue":[{"rooliIdTietue":4,"rooliTunnisteTietue":"ElintarvikeasioidenYhteyshenkilo","rooliNimiTietue":"Elintarvikeasioiden yhteyshenkilö"}]},"laskutustiedotOsio":{"laskutustiedotGroup":{"selected":"Verkkolasku"}}},"tapahtumanKuvauksetSivu":{"tapahtumanKuvauksetOsio":{"tapahtumanNimiTietue":"Tapahtumajärjestäminen"}},"tapahtumaSivu":{"tapahtumapaikkaAlueOsio":{"kayntiosoiteTietue":null,"kayntiosoitteenPostinumeroTietue":null,"kayntiosoitteenPostitoimipaikkaTietue":null}}}'
        attachmentMetaDatas:
          type: array
          items:
            $ref: '#/components/schemas/AttachmentMetadata'
        infoRequests:
          type: object
          properties:
            infoRequests:
              type: array
              items:
                $ref: '#/components/schemas/InfoRequestItem'
    Statuses:
      type: array
      items:
        $ref: '#/components/schemas/ProjectPartStatus'
    ProjectPartStatus:
      type: object
      required:
        - StatusDate
        - PrimaryStatus
      properties:
        statusDate:
          type: string
          format: datetime
        resolutionDate:
          type: string
          format: datetime
        initiationDate:
          type: string
          format: datetime
        dueDate:
          type: string
          format: datetime
        completeDate:
          type: string
          format: datetime
        primaryStatus:
          $ref: '#/components/schemas/ProjectPartPrimaryStatusType'
        primaryStatusTranslations:
          type: string
          example: "Primary status translation json object"
        secondaryStatus:
          $ref: '#/components/schemas/ProjectPartSecondaryStatusType'
        secondaryStatusTranslations:
          type: string
          example: "Secondary status translation json object"
    Officer:
      type: object
      properties:
        name:
          type: string
          format: text
          example: "Ville Virkamies"
        role:
          type: string
          format: text
          example: "Käsittelijä"
        phone:
          type: string
          format: text
          example: "0001234568"
        handlingOrganization:
          type: string
          format: text
          example: "AVI"
        virtuOrganization:
          type: string
          format: text
          example: "testivirasto.fi"
        virtuId:
          type: string
          format: text
          example: "vvirkamies"
        email:
          type: string
          format: text
          example: "ville.virkamies@testivirasto.fi"
    Transaction:
      type: object
      properties:
        TransactionName:
          type: string
        ObjectOfControlName:
          type: string
        Municipality:
          type: object
          $ref: '#/components/schemas/Municipality'
    Municipality:
      type: object
      properties:
        Name:
          type: string
          example: Helsinki
        Code:
          type: string
          example: 91
    UserEmailInfo:
      type: object
      properties:
        CreatorEmail:
          type: string
        SenderEmail:
          type: string
    ProjectPartAttachment:
      type: object
      properties:
        AttachmentMetadata:
          type: object
          $ref: '#/components/schemas/AttachmentMetadata'
    ProjectPartAttachments:
      type: array
      items:
        $ref: '#/components/schemas/ProjectPartAttachment'
    AttachmentMetadata:
      type: object
      properties:
        Id:
          type: integer
        FileName:
          type: string
        Extension:
          type: string
        MimeType:
          type: string
        Location:
          type: string
        Hash:
          type: string
        LastModifiedTime:
          type: string
          format: datetime
        Description:
          type: string
    InfoRequestItem:
      type: object
      properties:
        Message:
          type: string
        DueDate:
          type: string
          format: datetime
        CreatedDate:
          type: string
          format: datetime
        Response:
          type: string
        ResponseDate:
          type: string
          format: datetime
    ProjectPartPrimaryStatusType:
      description: Project part primary status enum
      type: integer
      enum:
        - None
        - New
        - Draft
        - Sent
        - Received
        - InProgress
        - Accepted
        - AcceptedInEffect
        - Rejected
        - RejectedInEffect
        - Expired
        - Canceled
        - Done
        - Inadmissible
        - Resolved
        - PartiallyGranted
        - ReceivedNoFurtherAction
        - Registered
        - Processed
    ProjectPartSecondaryStatusType:
      description: Project part secondary status enum
      type: integer
      enum:
        - None
        - InfoRequest
        - InfoRequestAnswered
        - Hearing
        - HearingFinished
        - ApplicationReviewRequestForAuthorities
        - ApplicationReviewed
        - RequestForApplicantsResponse
        - ResponseGivenByApplicant
        - TransferExternalServiceTriggerSent
        - TransferExternalServiceInProgress
        - TransferExternalServiceError
        - TransferExternalServiceDone
        - InfoRequestAnswerSent
        - Complete
    DiaryNumber:
      type: object
      properties:
        DiaryNumber:
          type: string
    StatusChange:
      type: object
      required:
        - Status
      properties:
        ResolutionDate:
          type: string
          format: datetime
        InitiationDate:
          type: string
          format: datetime
        DueDate:
          type: string
          format: datetime
        Status:
          type: string
        SecondaryStatus:
          type: string
        URL:
          type: string
        AdditionalInformation:
          type: string
        SenderName: 
          type: string
        CompleteDate:
          type: string
          format: datetime
  requestBodies:
    ProjectPartStatus:
      description: Project part status
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ProjectPartStatus'
  securitySchemes:
    basicAuth:
      type: http
      scheme: basic
