openapi: 3.0.0
x-stoplight:
  id: 0j8t7lwa1fzq6
info:
  title: Workers
  version: 1.0.0
  summary: API for manage the workers of Nalanda
  description: >-
    The workers services in the Nalanda API are designed to manage individual worker records within your system. This
    API allows you to create, retrieve, and update worker information, making it easier to track and manage personnel
    across various projects.


    By using this services, you can maintain accurate and up-to-date records for each worker, which is essential for
    ensuring compliance with labor laws, payroll management, and overall project oversight.



    **Core Functionalities**


    - Creating new worker entries when onboarding personnel.


    - Retrieving existing worker records to view or process data.


    - Updating worker details, such as contact information, employment status, or job roles.



    This endpoint is fundamental for any system that needs to manage a workforce and track the participation of
    individual workers across different assignments or projects.
servers:
  - url: https://api.nalandaglobal.com/api
    description: Prod
paths:
  /companies/{tax_id}/workers:
    parameters:
      - schema:
          type: string
        name: tax_id
        description: Company tax id
        in: path
        required: true
    get:
      summary: Find all workers by company tax id
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                type: object
                properties:
                  content:
                    type: array
                    x-stoplight:
                      id: eiba2to9mr4ew
                    items:
                      $ref: '#/components/schemas/Worker'
                      x-stoplight:
                        id: tajk0v7l2x71g
                  page:
                    $ref: ./Page.json
                    x-stoplight:
                      id: xx009h8goap0r
        '400':
          $ref: '#/components/responses/400-Bad_Request'
        '401':
          $ref: '#/components/responses/401-Unauthorized'
        '403':
          $ref: '#/components/responses/403-Forbidden'
        '404':
          $ref: '#/components/responses/404-Not_Found'
        '406':
          $ref: '#/components/responses/406-Not_Acceptable'
      operationId: get-companies-tax_id-workers
      x-stoplight:
        id: snmzsmxyl29cm
      x-supported-platforms:
        - national
        - international
      description: |-
        <!-- BEGIN supported-platforms -->
        <!-- theme: none -->
        >#### Supported Platforms: NATIONAL / INTERNATIONAL
        <!-- END supported-platforms -->

        Search workers in a company by the given tax id. 
        This service returns information only for the company searched, not for its subcontractors.
        It is available to filter by id card or by the name and surname of the worker.

        An example of request could be:
        https://api.nalandaglobal.com/api/companies/A12345678/workers?page=0&size=20&full_name=ilike:worker
      security:
        - bearerAuth: []
      parameters:
        - $ref: '#/components/parameters/accept'
        - $ref: '#/components/parameters/page'
        - $ref: '#/components/parameters/size'
        - $ref: '#/components/parameters/sort'
        - schema:
            type: string
          in: query
          name: full_name
          description: Name and last name of the worker
        - schema:
            type: string
          in: query
          name: id_card
          description: Worker id card
      tags:
        - Search
      requestBody:
        content: {}
        description: ''
    post:
      summary: Create worker
      operationId: post-companies-tax_id-workers
      responses:
        '201':
          description: Created
        '400':
          $ref: '#/components/responses/400-Bad_Request'
        '401':
          $ref: '#/components/responses/401-Unauthorized'
        '403':
          $ref: '#/components/responses/403-Forbidden'
        '404':
          $ref: '#/components/responses/404-Not_Found'
        '406':
          $ref: '#/components/responses/406-Not_Acceptable'
        '409':
          $ref: '#/components/responses/409-Conflict'
      x-stoplight:
        id: yruqtsfv4m70k
      x-supported-platforms:
        - national
        - international
      description: |-
        <!-- BEGIN supported-platforms -->
        <!-- theme: none -->
        >#### Supported Platforms: NATIONAL / INTERNATIONAL
        <!-- END supported-platforms -->

        Create Worker for the company tax id
      security:
        - bearerAuth: []
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/Worker'
  /companies/{tax_id}/workers/{id_card}:
    parameters:
      - schema:
          type: string
        name: tax_id
        description: company tax id
        in: path
        required: true
      - schema:
          type: string
        name: id_card
        description: Worker id card
        in: path
        required: true
    get:
      summary: Get worker
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Worker'
        '401':
          $ref: '#/components/responses/401-Unauthorized'
        '403':
          $ref: '#/components/responses/403-Forbidden'
        '404':
          $ref: '#/components/responses/404-Not_Found'
        '406':
          $ref: '#/components/responses/406-Not_Acceptable'
      operationId: get-companies-tax_id-workers-id_card
      x-stoplight:
        id: 7vo1t4lck8zj7
      x-supported-platforms:
        - national
        - international
      description: |-
        <!-- BEGIN supported-platforms -->
        <!-- theme: none -->
        >#### Supported Platforms: NATIONAL / INTERNATIONAL
        <!-- END supported-platforms -->

        Get Worker for the company tax id and worker id card
      security:
        - bearerAuth: []
      parameters:
        - $ref: '#/components/parameters/accept'
    patch:
      summary: Partially update worker
      operationId: patch-companies-tax_id-workers-id_card
      responses:
        '200':
          description: OK
        '400':
          $ref: '#/components/responses/400-Bad_Request'
        '401':
          $ref: '#/components/responses/401-Unauthorized'
        '403':
          $ref: '#/components/responses/403-Forbidden'
        '404':
          $ref: '#/components/responses/404-Not_Found'
        '406':
          $ref: '#/components/responses/406-Not_Acceptable'
      x-stoplight:
        id: j3ta454eesub0
      x-supported-platforms:
        - national
        - international
      description: |-
        <!-- BEGIN supported-platforms -->
        <!-- theme: none -->
        >#### Supported Platforms: NATIONAL / INTERNATIONAL
        <!-- END supported-platforms -->

        Partially update worker for the company tax id and the worker id card
      security:
        - bearerAuth: []
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/WorkerPatch'
  /workers:
    parameters: []
    get:
      summary: Find all workers
      operationId: search-workers
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                type: object
                additionalProperties: false
                properties:
                  content:
                    x-stoplight:
                      id: yraxiox8zh8ld
                    type: array
                    items:
                      $ref: '#/components/schemas/Worker'
                      x-stoplight:
                        id: sn7hagigbnyke
                  page:
                    $ref: ./Page.json
                    x-stoplight:
                      id: vps6s0v3fekkj
        '401':
          $ref: '#/components/responses/401-Unauthorized'
        '403':
          $ref: '#/components/responses/403-Forbidden'
        '404':
          $ref: '#/components/responses/404-Not_Found'
        '406':
          $ref: '#/components/responses/406-Not_Acceptable'
      parameters:
        - $ref: '#/components/parameters/accept'
        - $ref: '#/components/parameters/page'
        - $ref: '#/components/parameters/size'
        - $ref: '#/components/parameters/sort'
      description: |-
        <!-- BEGIN supported-platforms -->
        <!-- theme: none -->
        >#### Supported Platforms: NATIONAL / INTERNATIONAL
        <!-- END supported-platforms -->

        Search workers for the company of the log in user
      tags:
        - Search
      x-supported-platforms:
        - national
        - international
components:
  schemas:
    Worker:
      title: Worker
      x-stoplight:
        id: grc3yakbwg1gb
      type: object
      description: Worker schema
      required:
        - id_card
        - 'name '
        - last_name
        - type
      properties:
        id_card:
          type: string
          x-stoplight:
            id: 4a4w2ocsbg4sg
          example: 30921661R
          description: The card id of the worker
        'name ':
          type: string
          x-stoplight:
            id: 9jqn0ele0cens
          example: Pepito
          description: Name of the worker
        last_name:
          type: string
          x-stoplight:
            id: tzef5hvf7otpg
          example: Garcia
          description: Last name of the worker
        phone:
          type: string
          x-stoplight:
            id: xgv5xkt0sthl1
          example: 999555888
          description: Phone number of the worker
          readOnly: true
        category:
          type: string
          x-stoplight:
            id: r31fuqx8ih2kf
          description: Category of the worker
          example: '08: OFICIALES DE 1ª Y 2ª'
        social_security_number:
          type: string
          x-stoplight:
            id: id32vjfvv2w1q
          description: Social Security number of the worker
          example: '330111944753'
        gender:
          x-stoplight:
            id: kbspdo49e7u79
          example: male
          description: Gender of the worker
          enum:
            - male
            - female
            - other
        photo:
          type: string
          x-stoplight:
            id: kmzy963tilo8o
          example: /media/img/anonymousUser.jpg
          description: "Photo uri of the worker\r\n"
          readOnly: true
        type:
          x-stoplight:
            id: 5282iv3l1hxxy
          enum:
            - employed
            - self employed
          description: Type of the worker
          writeOnly: true
        internal_code:
          type: string
          x-stoplight:
            id: 5249oivnkhi9m
          example: '000001'
          description: Internal Nalanda code
        birth_date:
          type: string
          x-stoplight:
            id: uzs1lewkhudgf
          description: Birth date of the worker
          example: '1990-01-01'
          format: date
          default: '1990-01-01'
        communities_tax_id:
          type: array
          x-stoplight:
            id: 8uckx9zxussv2
          default:
            - A82692617
            - A82692617
          example:
            - A82692617
            - A82692617
          description: Communities in which the worker is allowed to work
          items:
            x-stoplight:
              id: 5ecrmy9r3oo5d
            type: string
        active:
          type: boolean
          x-stoplight:
            id: ht7ii4w1ohu5i
          description: "Whether the worker is active or not\r\n\r\n"
          readOnly: true
    SkilledWorker:
      title: SkilledWorker
      x-stoplight:
        id: 37igc88r0xa8d
      type: object
      description: Skilled Worker Data Response
      required:
        - id_card
        - 'name '
        - last_name
        - company_name
        - internal_code
      properties:
        id_card:
          type: string
          example: 30921661R
          description: The card id of the worker
        'name ':
          type: string
          example: Pepito
          description: Name of the worker
        last_name:
          type: string
          example: Garcia
          description: Last name of the worker
        phone:
          type: string
          example: 999555888
          description: Phone number of the worker
          readOnly: true
        company_name:
          type: string
          example: Company name
          x-stoplight:
            id: s95dwrvkdi8r2
          description: Company name of the worker
        internal_code:
          type: string
          example: '000001'
          description: Internal Nalanda code
        trades:
          type: array
          default:
            - trade1
            - trade2
          example:
            - trade1
            - trade2
          description: List of trades that can be performed by a worker
          items:
            type: string
            x-stoplight:
              id: tc12p6v4utj2r
    WorkerPatch:
      title: WorkerPatch
      x-stoplight:
        id: 75s0y34q6a021
      type: object
      description: Fields that will be modify
      properties:
        birth_date:
          type: string
          x-stoplight:
            id: i0lfssfpp6iek
          description: Birth date of the worker
          example: '1990-01-01'
          format: date
          default: '1990-01-01'
        category:
          type: string
          description: Category of the worker
          example: '08: OFICIALES DE 1ª Y 2ª'
        gender:
          description: Gender of the worker
          example: male
          enum:
            - male
            - female
            - other
        internal_code:
          type: string
          example: '000001'
          description: Internal Nalanda code
        social_security_number:
          type: string
          x-stoplight:
            id: ofuiimtx8dqao
          description: Social Security number of the worker
          example: '330111944753'
        communities_tax_id:
          type: array
          x-stoplight:
            id: c75ujfxsf4odv
          default:
            - A82692617
            - A82692617
          example:
            - A82692617
            - A82692617
          description: Communities in which the worker is allowed to work
          items:
            x-stoplight:
              id: o66003nkitawn
            type: string
        active:
          type: boolean
          x-stoplight:
            id: ca2bh5fz4anjq
          description: Whether the worker is active or not
    WorkerAccedemos:
      title: WorkerAccedemos
      x-stoplight:
        id: hxjh7lfkf5cpn
      type: object
      description: Worker Accedemos Data Response
      properties:
        rfid:
          type: string
          x-stoplight:
            id: 3jtv2926xmppy
          description: RFID of worker accedemos
          default: AABEN5P
          example: AABEN5P
        nfc:
          type: string
          x-stoplight:
            id: 18zrkxlu6dc44
          description: NFC of worker accedemos
          default: AABEN5P
          example: AABEN5P
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
  parameters:
    id:
      name: id
      in: path
      required: true
      schema:
        type: string
      description: identifier of the resource
    accept:
      name: Accept
      in: header
      required: false
      schema:
        type: string
      description: application/vnd.nalanda.api-v1.0+json
    page:
      name: page
      in: query
      required: false
      schema:
        type: number
      description: Number of the current page
    size:
      name: size
      in: query
      required: false
      schema:
        type: number
      description: Size for every page
    sort:
      name: sort
      in: query
      required: false
      schema:
        type: string
      description: Sort by field
  responses:
    401-Unauthorized:
      description: 401 Unauthorized
      content: {}
    404-Not_Found:
      description: 404 Not Found
      content: {}
    406-Not_Acceptable:
      description: 406 Not Acceptable
      content: {}
    403-Forbidden:
      description: 403 Forbidden
      content: {}
    409-Conflict:
      description: 409 Existing Resource
      content: {}
    400-Bad_Request:
      description: Example response
      content:
        application/json:
          schema:
            type: object
            x-examples:
              Example 1:
                status: 400
                global_error: El genero no tiene un formato valido
                field_errors: null
            properties:
              status:
                type: integer
              global_error:
                type: string
                example: El genero no tiene un formato valido
              field_errors:
                type:
                  - array
                  - 'null'
                items:
                  x-stoplight:
                    id: qbvq1oqhy24hx
                  type: string
        application/xml:
          schema:
            type: object
            properties: {}
        multipart/form-data:
          schema:
            type: object
            properties: {}
tags:
  - name: Open
    description: Open requests
  - name: Search
    description: Search requests
security:
  - bearerAuth: []
