openapi: 3.0.3
info:
  title: Kolla elföretaget
  description: |
    REST API för att hämta information om olika typer av aktiviteter relaterade till elföretag.
  version: 1.0.0
  contact:
    name: Soleil IT
    url: https://soleil.se
  license:
    name: Proprietary
servers:
  - url: https://kolla-elforetaget-api.elsakerhetsverket.se
    description: Produktionsmiljö
  - url: https://kolla-elforetaget-api.elsakerhetsverket.se:9001
    description: Testmiljö

paths:
  /ActivityTypes:
    get:
      summary: Get a list of activity types
      description: Returns a list of activity types with their details.
      security:
        - ApiKeyAuth: []
      responses:
        '200':
          description: A list of activity types.
          content:
            application/json: 
              schema:
                $ref: '#/components/schemas/ActivityTypesResponse'

  /Search:
    post:
      summary: Search for companies based on activity types
      description: |
        Accepts a search string and returns a list of companies that match the criteria.
      security:
        - ApiKeyAuth: []
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              properties:
                searchString:
                  type: string
                  description: Search string to filter companies.
      responses:
        '200':
          description: A list of companies matching the search criteria.
          content:
            application/json:
              schema:
                type: array
                items:
                  $ref: '#/components/schemas/SearchResponse'

components:
  securitySchemes:
    ApiKeyAuth:
      type: apiKey
      in: header
      name: X-API-KEY

  schemas:
    ActivityTypesResponse:
      type: object
      properties:
        activityTypes:
          type: array
          items:
            type: object
            properties:
              id:
                type: integer
                description: Unique identifier for the service.
              name:
                $ref: '#/components/schemas/LanguageString'
              description:
                $ref: '#/components/schemas/LanguageString'
              categoryMappings:
                type: array
                items:
                  type: object
                  properties:
                    id:
                      type: integer
                      description: Unique identifier for the category.
                    name:
                      $ref: '#/components/schemas/LanguageString'
                    Groups:
                      type: array
                      items:
                        type: object
                        properties:
                          id:
                            type: integer
                            description: Unique identifier for the group.
                          description:
                            $ref: '#/components/schemas/LanguageString'

    SearchResponse:
      type: object
      properties:
        id:
          type: integer
          description: Unique identifier for the search response.
        identityNoForeign:
          type: string
          nullable: true
          description: Foreign identity number.
        identityNoSwedish:
          type: string
          nullable: true
          description: Swedish identity number.
        isCableInstallationOnly:
          type: boolean
          description: Indicates if the company is only involved in cable installation.
        name:
          type: string
          description: Name of the company.
        organizationNumber:
          type: string
          description: Organization number of the company.
        vat:
          type: string
          nullable: true
          description: VAT number of the company.
        headOfficeAddress:
          $ref: '#/components/schemas/ContactInformation'
        country:
          type: object
          properties:
            name:
                $ref: '#/components/schemas/LanguageArray'
        corporateForm:
          type: object
          properties:
            id:
              type: integer
              description: Unique identifier for the corporate form.
            name:
              $ref: '#/components/schemas/LanguageArray'
        addresses:
          type: array
          items:
            $ref: '#/components/schemas/ContactInformation'

        activityTypes:
          type: array
          items:
            type: object
            properties:
              id:
                type: integer
                description: Unique identifier for the activity type.
              name:
                type: array
                items:
                  $ref: '#/components/schemas/LanguageString'
              sortOrder:
                type: integer
                description: Sort order of the activity type.
              acceptedAuthorizations:
                type: array
                items:
                  type: object
                  properties:
                    id:
                      type: integer
                      description: Unique identifier for the authorization.
                    authNr:
                      type: string
                      nullable: true
                      description: Authorization number.
                    descp:
                      type: string
                      description: Description of the authorization.
                    title:
                      type: string
                      description: Title of the authorization.
              category:
                type: object
                properties:
                  description:
                    $ref: '#/components/schemas/LanguageArray'
                  id:
                    type: integer
                    description: Unique identifier for the category.
                  name:
                    $ref: '#/components/schemas/LanguageArray'
              description:
                $ref: '#/components/schemas/LanguageArray'

    ContactInformation:
      type: object
      properties:
        city:
          type: string
          description: City of the address.
        email:
          type: string
          nullable: true
          description: Email address of the address.
        phone:
          type: string
          nullable: true
          description: Phone number of the address.
        streetAddress:
          type: string
          nullable: true
          description: Street address of the address.
        website:
          type: string
          nullable: true
          description: Website of the company.
        zipcode:
          type: string
          description: Zip code of the company.

    LanguageString:
      type: object
      properties:
        sv:
          type: string
          description: Swedish language string.
        en:
          type: string
          description: English language string.
    
    LanguageArray:
      type: array
      items:
        type: object
        properties:
           languageCode:
             type: string
             enum: [sv, en]
             description: Language code (e.g., "sv" for Swedish, "en" for English).
           value:
             type: string
             description: The string value in the specified language.
      example:
        [
          {
            "languageCode": "sv",
            "value": "Bandrift"
          },
          {
            "languageCode": "en",
            "value": "Railway operation"
          }
        ]
