openapi: 3.1.0
info:
  title: Time Settings API
  version: '1.0'
  description: |
    Welcome on the documentation for the Time Settings API.
  contact:
    name: API Support
    url: 'https://www.luccasoftware.com'
    email: no-reply@luccasoftware.com
  license:
    name: Apache 2.0
    url: 'https://www.apache.org/licenses/LICENSE-2.0'
servers:
  - url: "https://{host}"
    description: |-
      Your Lucca account URL.
    variables:
      host:
        default: example.ilucca.net
        description: |-
          The URL of your dedicated Lucca account: `{account}.{env}.{region}`.
          
          Account reflects your company name. Env indicates the environment. Region depends on your server location.

          **Please, use your test or sandbox environments (and not your production env.) for testing purposes.**

          Environments:
          - `ilucca`: production environment for customers.
          - `ilucca-test`: test environment for customers.
          - `ilucca-demo`: demo environment for prospects.

          Regions:
          - `.ch` for Swiss located accounts.
          - `.net` for the others.

          Regarding sandboxes, the pattern differs: `https://{account}-{sandboxName}.sandbox.{server}.luccasoftware.com`, where:
          - `{sandboxName}` is automatically generated upon creation.
          - `{server}` may be "eu1", "eu2" or "ch1".
tags:
  - name: UserDates
    description: Aggregates work schedule events.
  - name: WorkCycleExceptions
    description: Override an employee's theoretical working hours.
  - name: Working Time Arrangements
    description: Employees recurring working hours.
  - name: Collective Schedules
    description: Describes the working hours pattern of a working-time-arrangement.
  - name: employee-assignments
    description: Assignations of employees to working time arrangements.
  - name: ShiftOverrides
    description: One-time overrides of an employee's regular work schedule.
paths:
  /api/v3/workcycleExceptions:
    parameters:
      - $ref: "#/components/parameters/Authorization"
    get:
      operationId: list-workcycle-exceptions
      x-mint:
        href: /api-reference/legacy/schedule/workcycle-exceptions/list-workcycle-exceptions
      summary: List WorkCycleExceptions.
      tags:
        - WorkCycleExceptions
      description: |
        Retrieve a paginated list of WorkCycleExceptions that satisfy the 
        given query filters.
      parameters:
        - name: fields
          in: query
          description: |
            List the properties you want included in the response.
            Example: `?fields=id,ownerId,isAm,startsAt,duration,unit,createdAt,modifiedAt,deletedAt,collection.count`

            The `collection.count` field indicates the total number of items across all pages.
          style: form
          explode: false
          schema:
            type: array
            items:
              type: string
              enum:
                - id
                - name
                - url
                - ownerId
                - owner.id
                - owner.name
                - owner.url
                - owner.firstName
                - owner.lastName
                - isAm
                - unit
                - startsAt
                - endsAt
                - durationInMinutes
                - duration
                - authorId
                - createdAt
                - modifierId
                - modifiedAt
                - deletedById
                - deletedAt
                - collection.count
            default:
              - id
              - name
              - url
            example:
              - id
              - ownerId
              - isAm
              - startsAt
              - duration
              - unit
              - createdAt
              - modifiedAt
              - deletedAt
        - name: id
          in: query
          description: |
            Retrieve WorkCycleExceptions that match one of the given IDs (comma separated list).
          style: form
          explode: false
          schema:
            type: array
            uniqueItems: true
            items:
              type: integer
              format: int32
              minimum: 1
        - name: ownerId
          in: query
          description: |
            Only retrieve WorkCycleExceptions that apply to one of the given
            employees, identified by their ID (comma separated list of int).
          style: form
          explode: false
          schema:
            type: array
            uniqueItems: true
            items:
              type: integer
              format: int32
              minimum: 1
        - name: isAm
          in: query
          description: |
            Filter on the `isAm` property.
            - `true`: the workcycleException applies to the first half-day.
            - `false`: the workcycleException applies to the second half-day.
            Omit this query parameter in order to retrieve all workcycleExceptions,
            whether they apply to the first or the second half-day.
          schema:
            type: boolean
        - name: startsAt
          in: query
          description: |
            Only retrieve items that match the given date condition.
            - `?startsAt=between,{date1},{date2}`: items that intersect the {date1}-
              {date2} period.
            - `?startsAt=since,{date}`: items that occur after (non-strict) the given
              {date}.
            - `?startsAt=until,{date}`: items that occur before (non-strict) the given
              {date}.
          schema:
            type: string
            examples:
              - 'between,2023-01-01,2023-12-31'
              - 'since,2023-01-01'
              - 'until,2023-12-31'
        - name: deletedAt
          in: query
          description: |
            - `null` (default): do no include deleted WorkCycleExceptions.
            - `notequal,null`: only retrieve deleted WorkCycleExceptions.
            - no param: retrieve both deleted and non-deleted WorkCycleExceptions.
          schema:
            type: string
            enum:
              - 'notequal,null'
              - 'null'
        - name: unit
          in: query
          description: |
            Only retrieve WorkCycleExceptions whose unit match one of the
            given.
          schema:
            $ref: '#/components/schemas/EventUnit.v3'
        - name: paging
          in: query
          description: |
            Syntax: `{index},{pageSize}`
            Index is the position of the first item to retrieve.
            PageSize is the number of items per page.
            **Note**: Page size cannot exceed 1,000.
            For example, to retrieve the first 100 items:
            `?paging=0,100`, then to retrieve the 100 next:
            `?paging:100,100`
          schema:
            type: string
        - name: orderBy
          in: query
          style: form
          explode: false
          description: |
            Sort items by ascending or descending property value.
            Syntax is: `{propertyName},{direction}` where `direction` can
            either be `asc` (ascending) or `desc` (descending).
          schema:
            type: array
            items:
              type: string
              enum:
                - 'id,asc'
                - 'id,desc'
                - 'startsAt,asc'
                - 'startsAt,desc'
            default:
              - 'id,asc'
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: object
                    properties:
                      count:
                        type: integer
                        format: int32
                        minimum: 0
                      items:
                        type: array
                        minItems: 0
                        items:
                          $ref: '#/components/schemas/WorkCycleException'
        '400':
          $ref: '#/components/responses/ResponseProblem'
        '401':
          $ref: '#/components/responses/ResponseProblem'
        '404':
          $ref: '#/components/responses/ResponseProblem'
        '500':
          $ref: '#/components/responses/ResponseProblem'
    post:
      operationId: create-workcycle-exception
      x-mint:
        href: /api-reference/legacy/schedule/workcycle-exceptions/create-workcycle-exception
      tags:
        - WorkCycleExceptions
      summary: Create (or update) a WorkCycleException.
      description: |
        <Warning>
        An employee can only have a single `WorkCycleException` on any given
        half-day (indicated by the `startsAt` date and the `isAm` boolean).
        As a result, creating a new `WorkCycleException` via a POST request 
        may result in the update of the existing one.
        </Warning>
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/WorkCycleException'
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    $ref: '#/components/schemas/WorkCycleException'
        '400':
          $ref: '#/components/responses/ResponseProblem'
        '401':
          $ref: '#/components/responses/ResponseProblem'
        '404':
          $ref: '#/components/responses/ResponseProblem'
        '500':
          $ref: '#/components/responses/ResponseProblem'
  /api/v3/workcycleExceptions/{id}:
    parameters:
      - $ref: "#/components/parameters/Authorization"
      - name: id
        in: path
        required: true
        description: ID of the workcycleException
        schema:
          type: integer
          format: int32
          minimum: 1
    get:
      operationId: get-workcycle-exception
      x-mint:
        href: /api-reference/legacy/schedule/workcycle-exceptions/get-workcycle-exception
      summary: Retrieve a WorkCycleException.
      description: |
        Retrieve a single WorkCycleException by its ID.
      tags:
        - WorkCycleExceptions
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    $ref: '#/components/schemas/WorkCycleException'
        '400':
          $ref: '#/components/responses/ResponseProblem'
        '401':
          $ref: '#/components/responses/ResponseProblem'
        '404':
          $ref: '#/components/responses/ResponseProblem'
        '500':
          $ref: '#/components/responses/ResponseProblem'
    delete:
      operationId: delete-workcycle-exception
      x-mint:
        href: /api-reference/legacy/schedule/workcycle-exceptions/delete-workcycle-exception
      summary: Delete a WorkCycleException.
      description: |
        <Note>The `WorkCycleException`, once deleted, stays available in the API.</Note>

        Deleting a `WorkCycleException` means marking it as deleted by setting its `deletedAt` property to the deletion date. This allows us to keep track of deletions and to provide the possibility to filter out deleted `WorkCycleExceptions` from list responses.
        In order to filter out the deleted `WorkCycleException`, you may use the `deletedAt`
        query parameter:
        ```http
        GET /api/v3/workcycleexceptions?deletedAt=null HTTPS/1.1
        Host: example.ilucca.net
        Authorization: lucca application=XXXX
        ```
      tags:
        - WorkCycleExceptions
      responses:
        '200':
          description: OK
        '400':
          $ref: '#/components/responses/ResponseProblem'
        '401':
          $ref: '#/components/responses/ResponseProblem'
        '404':
          $ref: '#/components/responses/ResponseProblem'
        '500':
          $ref: '#/components/responses/ResponseProblem'
  /schedule/api/shift-overrides:
    parameters:
      - $ref: "#/components/parameters/Authorization"
    get:
      operationId: get-shift-overrides
      x-mint:
        href: /api-reference/legacy/schedule/shift-overrides/list-shift-overrides
      summary: List ShiftOverrides.
      tags:
        - ShiftOverrides
      description: |
        Retrieve a paginated list of ShiftOverrides that satisfy the given query filters.

        A ShiftOverride represents a one-time modification to an employee's regular work schedule
        for a specific period. It overrides the employee's normal working pattern (defined by their
        work cycle) for the specified time range.
      parameters:
        - name: id
          in: query
          description: |
            Retrieve ShiftOverrides that match one of the given IDs (comma separated list).
          style: form
          explode: false
          schema:
            type: array
            uniqueItems: true
            items:
              type: integer
              format: int32
              minimum: 0
        - name: employee.id
          in: query
          description: |
            Only retrieve ShiftOverrides that apply to one of the given
            employees, identified by their ID (comma separated list of int).
          style: form
          explode: false
          schema:
            type: array
            uniqueItems: true
            items:
              type: integer
              format: int32
              minimum: 0
        - name: startsAt.between
          in: query
          description: |
            Include only values that fall within the specified range for `startsAt`.
            Open-ended ranges can be defined with `..` characters.
          schema:
            type: string
            examples:
              - '2023-01-01--2023-01-31'
              - '..--2023-01-01'
              - '2023-01-01--..'
        - name: endsAt.between
          in: query
          description: |
            Include only values that fall within the specified range for `endsAt`.
            Open-ended ranges can be defined with `..` characters.
          schema:
            type: string
            examples:
              - '2023-01-01--2023-01-31'
              - '..--2023-01-01'
              - '2023-01-01--..'
        - $ref: "#/components/parameters/limit"
        - $ref: "#/components/parameters/page"
        - name: sort
          in: query
          description: |
            Sort items by ascending or descending property value.
            Prefix with `-` for descending order.
          schema:
            type: string
            default: '+StartsAt'
            examples:
              - 'id'
              - '-id'
              - 'startsAt'
              - '-startsAt'
        - $ref: "#/components/parameters/fields.root"
        - name: include
          in: query
          description: Include extra properties with payload.
          style: form
          explode: false
          schema:
            type: array
            items:
              type: string
              enum:
                - embedded
                - links
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                type: object
                properties:
                  items:
                    type: array
                    items:
                      $ref: '#/components/schemas/ShiftOverride'
                  next:
                    type: ["null", "string"]
                    description: Continuation token for the next page.
                  prev:
                    type: ["null", "string"]
                    description: Continuation token for the previous page.
                  count:
                    type: ["null", "integer"]
                    format: int32
                    minimum: 0
                    description: Total count of items (when requested via `fields.root=count`).
        '400':
          $ref: '#/components/responses/ResponseProblem'
        '401':
          $ref: '#/components/responses/ResponseProblem'
        '500':
          $ref: '#/components/responses/ResponseProblem'
    put:
      operationId: put-shift-overrides
      x-mint:
        href: /api-reference/legacy/schedule/shift-overrides/replace-shift-overrides
      summary: Replace ShiftOverrides for an employee.
      tags:
        - ShiftOverrides
      description: |
        Replace all ShiftOverrides for a given employee within the specified date range.

        <Note>This endpoint uses a PUT semantic: all existing ShiftOverrides for the employee within
        the `startsAt.between` range will be removed and replaced by the ones provided in the
        request body. If none exist, then the provided ShiftOverrides will simply be created.</Note>

        <Warning>Both `employee.id` and `startsAt.between` query parameters are required.</Warning>
      parameters:
        - name: employee.id
          in: query
          required: true
          description: The ID of the employee whose ShiftOverrides should be replaced.
          schema:
            type: integer
            format: int32
            minimum: 0
        - name: startsAt.between
          in: query
          required: true
          description: |
            The date range within which existing ShiftOverrides will be replaced.
            Open-ended ranges can be defined with `..` characters.
          schema:
            type: string
            examples:
              - '2023-01-01--2023-01-31'
              - '..--2023-01-01'
              - '2023-01-01--..'
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: array
              items:
                $ref: '#/components/schemas/ShiftOverrideCandidate'
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                type: object
                properties:
                  items:
                    type: array
                    items:
                      $ref: '#/components/schemas/ShiftOverride'
        '400':
          $ref: '#/components/responses/ResponseProblem'
        '401':
          $ref: '#/components/responses/ResponseProblem'
        '500':
          $ref: '#/components/responses/ResponseProblem'
  /api/v3/userdates:
    parameters:
      - $ref: "#/components/parameters/Authorization"
    get:
      operationId: get-api-v3-userdates
      x-mint:
        href: /api-reference/legacy/schedule/userdates/list-userdates
      summary: List UserDates.
      description: |-
        Retrieve a list of UserDates.

        ### Performance
        In order to keep satisfactory response times and performance, please filter the request on a limited set of OwnerId[] and reduce the period  `date=between,{start},{end}`.

        As a rule of thumb, do not request for more than ~10 owners over a whole month.

        ### Format
        The `date` query parameter should match the form `?date=between,{start},{includedEnd}`.
      tags:
        - UserDates
      parameters:
        - name: ownerId
          in: query
          description: User's identifiers.
          required: true
          schema:
            type: array
            items:
              type: integer
              minimum: 1
        - name: date
          in: query
          description: 'The period over which working hours should be returned for given Users. Format: ''between,{start},{includedEnd}''.'
          required: true
          schema:
            type: string
            example: 'between,2021-01-01,2021-02-01'
        - name: fields
          in: query
          description: |
            List of all fields to be returned by the server.
            Example: `?fields=ownerId,date,dtt,drt,draj,
            items[startsAt,duration,type,timeline`
          schema:
            type: array
            items:
              type: string
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: object
                    properties:
                      items:
                        type: array
                        items:
                          $ref: '#/components/schemas/UserDate'
        '400':
          $ref: '#/components/responses/ResponseProblem'
        '401':
          $ref: '#/components/responses/ResponseProblem'
        '404':
          $ref: '#/components/responses/ResponseProblem'
        '500':
          $ref: '#/components/responses/ResponseProblem'
  /schedule/api/working-time-arrangements:
    parameters:
      - $ref: "#/components/parameters/Authorization"
    get:
      summary: List Working Time Arrangements.
      x-mint:
        href: /api-reference/legacy/schedule/working-time-arrangements/list-working-time-arrangements
      operationId: get-schedule-api-working-time-arrangements
      tags:
        - Working Time Arrangements
      description: |-
        <Warning>
        You may not benefit from this feature. Working-time-arrangements are the
        replacement for the workcycles. If this feature has not been deployed on
        your environment, please contact our support.
        </Warning>

        List of Working Time Arrangements.
      parameters:
        - name: search
          in: query
          description: Find a working time arrangement based on its name.
          schema:
            type: string
        - name: isPartTime
          in: query
          description: 'When true, only returns part-time working time arrangements.'
          schema:
            type: boolean
        - name: unit
          in: query
          description: Filter working time arrangements on their unit.
          schema:
            $ref: '#/components/schemas/EventUnit'
        - name: statuses
          in: query
          description: |
            Filter Working Time Arrangements on their status (comma separated list),
            eg `?statuses=active,inactive`. Repeating the parameter also works.
            If omitted, Working Time Arrangements of every status are retrieved.
          style: form
          explode: false
          schema:
            type: array
            uniqueItems: true
            items:
              $ref: '#/components/schemas/WorkingTimeArrangementStatus'
        - name: sort
          in: query
          description: Sort items by property.
          schema:
            type: string
            enum:
              - id
              - -id
        - $ref: '#/components/parameters/page'
        - $ref: '#/components/parameters/limit'
        - $ref: '#/components/parameters/fields.root'
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                type: object
                properties:
                  items:
                    type: array
                    items:
                      $ref: '#/components/schemas/WorkingTimeArrangement'
        '400':
          description: Bad Request
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ProblemDetail'
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ProblemDetail'
        '500':
          description: Internal Server Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ProblemDetail'
    post:
      summary: Create a new Working Time Arrangement.
      operationId: post-working-time-arrangement
      tags:
        - Working Time Arrangements
      description: |-
        <Warning>
        **This is a beta feature.** 
        You may not benefit from this feature. Working-time-arrangements are the
        replacement for the workcycles. If this feature has not been deployed on
        your environment, please contact our support.
        </Warning>

        Create a new Working Time Arrangement.
      x-mint:
        href: /api-reference/legacy/schedule/working-time-arrangements/post-working-time-arrangement
      responses:
        '201':
          description: Created
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/WorkingTimeArrangement'
        '400':
          description: Bad Request
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ProblemDetail'
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ProblemDetail'
        '403':
          description: Forbidden
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ProblemDetail'
        '500':
          description: Internal Server Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ProblemDetail'
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/WorkingTimeArrangement'
        description: ''
  /schedule/api/working-time-arrangements/{workingTimeArrangementId}:
    parameters:
      - $ref: "#/components/parameters/Authorization"
      - $ref: '#/components/parameters/workingTimeArrangementId_path'
    get:
      summary: Get a Working Time Arrangement by id.
      x-mint:
        href: /api-reference/legacy/schedule/working-time-arrangements/get-working-time-arrangement
      operationId: get-schedule-api-working-time-arrangements-workingTimeArrangementId
      tags:
        - Working Time Arrangements
      description: |-
        <Warning>
        **This is a beta feature.** 
        You may not benefit from this feature. Working-time-arrangements are the
        replacement for the workcycles. If this feature has not been deployed on
        your environment, please contact our support.
        </Warning>

        Get a Working Time Arrangement by id
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/WorkingTimeArrangement'
        '400':
          description: Bad Request
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ProblemDetail'
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ProblemDetail'
        '404':
          description: Not Found
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ProblemDetail'
        '500':
          description: Internal Server Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ProblemDetail'
    put:
      summary: Update a Working Time Arrangement by id.
      operationId: put-working-time-arrangement
      tags:
        - Working Time Arrangements
      description: |-
        <Warning>
        **This is a beta feature.** 
        You may not benefit from this feature. Working-time-arrangements are the
        replacement for the workcycles. If this feature has not been deployed on
        your environment, please contact our support.
        </Warning>

        Update a Working Time Arrangement by id
      x-mint:
        href: /api-reference/legacy/schedule/working-time-arrangements/put-working-time-arrangement
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/WorkingTimeArrangement'
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/WorkingTimeArrangement'
        '400':
          description: Bad Request
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ProblemDetail'
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ProblemDetail'
        '403':
          description: Forbidden
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ProblemDetail'
        '404':
          description: Not Found
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ProblemDetail'
        '500':
          description: Internal Server Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ProblemDetail'
    delete:
      summary: Delete a Working Time Arrangement by id.
      operationId: delete-working-time-arrangement
      tags:
        - Working Time Arrangements
      description: |-
        <Warning>
        **This is a beta feature.** 
        You may not benefit from this feature. Working-time-arrangements are the
        replacement for the workcycles. If this feature has not been deployed on
        your environment, please contact our support.
        </Warning>

        Once deleted, a Working Time Arrangement can no longer be retrieved through the API.

        A Working Time Arrangement can only be deleted if there are no Work Contract (or Amendment) referencing it. Otherwise, it may be archived.
      x-mint:
        href: /api-reference/legacy/schedule/working-time-arrangements/delete-working-time-arrangement
      responses:
        '204':
          description: No Content
        '400':
          description: Bad Request
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ProblemDetail'
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ProblemDetail'
        '403':
          description: Forbidden
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ProblemDetail'
        '500':
          description: Internal Server Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ProblemDetail'
  /schedule/api/working-time-arrangements/{workingTimeArrangementId}/archival:
    parameters:
      - $ref: "#/components/parameters/Authorization"
      - $ref: '#/components/parameters/workingTimeArrangementId_path'
    put:
      summary: Archive a Working Time Arrangement by id.
      operationId: put-working-time-arrangement-archival
      tags:
        - Working Time Arrangements
      description: |-
        <Warning>
        **This is a beta feature.** 
        You may not benefit from this feature. Working-time-arrangements are the
        replacement for the workcycles. If this feature has not been deployed on
        your environment, please contact our support.
        </Warning>

        Archive a Working Time Arrangement by id
      x-mint:
        href: /api-reference/legacy/schedule/working-time-arrangements/put-working-time-arrangement-archival
      responses:
        '200':
          description: OK
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ProblemDetail'
        '403':
          description: Forbidden
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ProblemDetail'
        '404':
          description: Not Found
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ProblemDetail'
        '500':
          description: Internal Server Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ProblemDetail'
    delete:
      summary: Unarchive a Working Time Arrangement by id.
      operationId: delete-working-time-arrangement-archival
      tags:
        - Working Time Arrangements
      description: |-
        <Warning>
        **This is a beta feature.** 
        You may not benefit from this feature. Working-time-arrangements are the
        replacement for the workcycles. If this feature has not been deployed on
        your environment, please contact our support.
        </Warning>

        Unarchive a Working Time Arrangement by id
      x-mint:
        href: /api-reference/legacy/schedule/working-time-arrangements/delete-working-time-arrangement-archival
      responses:
        '200':
          description: OK
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ProblemDetail'
        '403':
          description: Forbidden
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ProblemDetail'
        '500':
          description: Internal Server Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ProblemDetail'
  /schedule/api/working-time-arrangements/{workingTimeArrangementId}/collective-schedules:
    parameters:
      - $ref: "#/components/parameters/Authorization"
      - $ref: '#/components/parameters/workingTimeArrangementId_path'
    get:
      summary: List Collective Schedules from a Working Time Arrangement
      x-mint:
        href: /api-reference/legacy/schedule/working-time-arrangements/list-collective-schedules
      operationId: get-schedule-api-working-time-arrangements-workingTimeArrangementId-collective-schedules
      tags:
        - Collective Schedules
      description: |-
        <Warning>
        **This is a beta feature.** 
        You may not benefit from this feature. Working-time-arrangements are the
        replacement for the workcycles. If this feature has not been deployed on
        your environment, please contact our support.
        </Warning>

        Get the list of Collective Schedules from a Working Time Arrangement by id
      parameters:
        - $ref: '#/components/parameters/workingTimeArrangementId_path'
        - $ref: '#/components/parameters/limit'
        - $ref: '#/components/parameters/page'
        - $ref: '#/components/parameters/fields.root'
        - name: sort
          description: Sort items by a property.
          in: query
          schema:
            type: string
            enum:
              - '-startsOn'
            default: '-startsOn'
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                type: object
                properties:
                  items:
                    type: array
                    items:
                      $ref: '#/components/schemas/CollectiveSchedule'
        '400':
          description: Bad Request
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ProblemDetail'
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ProblemDetail'
        '404':
          description: Not Found
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ProblemDetail'
        '500':
          description: Internal Server Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ProblemDetail'
    post:
      summary: Create a new Collective Schedule for a Working Time Arrangement.
      operationId: post-collective-schedules
      tags:
        - Collective Schedules
      description: |-
        <Warning>
        **This is a beta feature.** 
        You may not benefit from this feature. Working-time-arrangements are the
        replacement for the workcycles. If this feature has not been deployed on
        your environment, please contact our support.
        </Warning>        

        Create a new CollectiveSchedule for a Working Time Arrangement
      x-mint:
        href: /api-reference/legacy/schedule/working-time-arrangements/post-collective-schedule
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/CollectiveSchedule'
      responses:
        '201':
          description: Created
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/CollectiveSchedule'
        '400':
          description: Bad Request
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ProblemDetail'
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ProblemDetail'
        '403':
          description: Forbidden
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ProblemDetail'
        '404':
          description: Not Found
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ProblemDetail'
        '500':
          description: Internal Server Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ProblemDetail'
  /schedule/api/working-time-arrangements/{workingTimeArrangementId}/collective-schedules/{collectiveScheduleId}:
    parameters:
      - $ref: "#/components/parameters/Authorization"
      - $ref: '#/components/parameters/workingTimeArrangementId_path'
      - name: collectiveScheduleId
        in: path
        required: true
        description: The unique identifier of the Collective Schedule for this Working Time Arrangement.
        schema:
          type: integer
    get:
      summary: Get a Collective Schedule from a Working Time Arrangement by id.
      x-mint:
        href: /api-reference/legacy/schedule/working-time-arrangements/get-collective-schedule
      operationId: get-collective-schedule
      tags:
        - Collective Schedules
      description: |-
        <Warning>
        **This is a beta feature.** 
        You may not benefit from this feature. Working-time-arrangements are the
        replacement for the workcycles. If this feature has not been deployed on
        your environment, please contact our support.
        </Warning>

        Get a Collective Schedule of a Working Time Arrangement by id
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/CollectiveSchedule'
        '400':
          description: Bad Request
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ProblemDetail'
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ProblemDetail'
        '404':
          description: Not Found
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ProblemDetail'
        '500':
          description: Internal Server Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ProblemDetail'
    put:
      summary: Update a Collective Schedule of a Working Time Arrangement.
      operationId: put-collective-schedule
      tags:
        - Collective Schedules
      description: |-
        <Warning>
        **This is a beta feature.** 
        You may not benefit from this feature. Working-time-arrangements are the
        replacement for the workcycles. If this feature has not been deployed on
        your environment, please contact our support.
        </Warning>

        Update a Collective Schedule of a Working Time Arrangement
      x-mint:
        href: /api-reference/legacy/schedule/working-time-arrangements/put-collective-schedule
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/CollectiveSchedule'
        '400':
          description: Bad Request
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ProblemDetail'
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ProblemDetail'
        '403':
          description: Forbidden
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ProblemDetail'
        '404':
          description: Not Found
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ProblemDetail'
        '500':
          description: Internal Server Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ProblemDetail'
    delete:
      summary: Delete a Collective Schedule of a Working Time Arrangement by id.
      operationId: delete-collective-schedule
      tags:
        - Collective Schedules
      description: |-
        <Warning>
        **This is a beta feature.** 
        You may not benefit from this feature. Working-time-arrangements are the
        replacement for the workcycles. If this feature has not been deployed on
        your environment, please contact our support.
        </Warning>

        You may delete a collective schedule if the working time arrangement has successive collective schedules. 
        However be aware that any change in the schedules of a user impacts the calculation of absences and time.
        Thus delete actions should be undertaken while editing a new working time arrangement. Use carefully otherwise.
      x-mint:
        href: /api-reference/legacy/schedule/working-time-arrangements/delete-collective-schedule
      responses:
        '204':
          description: No Content
        '400':
          description: Bad Request
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ProblemDetail'
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ProblemDetail'
        '403':
          description: Forbidden
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ProblemDetail'
        '500':
          description: Internal Server Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ProblemDetail'
  /schedule/api/working-time-arrangements/{workingTimeArrangementId}/duplicate:
    parameters:
      - $ref: "#/components/parameters/Authorization"
      - $ref: '#/components/parameters/workingTimeArrangementId_path'
    post:
      summary: Duplicate an existing Working Time Arrangement.
      operationId: duplicate-working-time-arrangement
      description: |-
        <Warning>
        **This is a beta feature.** 
        You may not benefit from this feature. Working-time-arrangements are the
        replacement for the workcycles. If this feature has not been deployed on
        your environment, please contact our support.
        </Warning>

        Duplicate an existing Working Time Arrangement
      tags:
        - Working Time Arrangements
      x-mint:
        href: /api-reference/legacy/schedule/working-time-arrangements/duplicate-working-time-arrangement
      responses:
        '201':
          description: Created
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/WorkingTimeArrangement'
        '400':
          description: Bad Request
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ProblemDetail'
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ProblemDetail'
        '403':
          description: Forbidden
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ProblemDetail'
        '500':
          description: Internal Server Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ProblemDetail'
  /schedule/api/employee-assignments:
    parameters:
      - $ref: "#/components/parameters/Authorization"
    get:
      summary: List Employee Assignments
      x-mint:
        href: /api-reference/legacy/schedule/employee-assignments/list-employee-assignments
      operationId: get-schedule-api-employee-assignments
      tags:
        - employee-assignments
      description: |-
        <Warning>
        You may not benefit from this feature. Working-time-arrangements are the
        replacement for the workcycles. If this feature has not been deployed on
        your environment, please contact our support.
        </Warning>

        Returns a paginated list of employee-assignments. An employee-assignment represents the assignment of a working-time-arrangement to an employee over a given period `startsOn` - `endsOn`.
      parameters:
        - $ref: '#/components/parameters/page'
        - $ref: '#/components/parameters/limit'
        - $ref: '#/components/parameters/fields.root'

        - name: workingTimeArrangement.id
          in: query
          description: >
            Only return results that match one of the given working time arrangement ID.
          allowEmptyValue: true
          schema:
            type: array
            items:
              title: Int32
              type: integer
              format: int32
              minimum: 0

        - name: -workingTimeArrangement.id
          in: query
          description: >
            Only return results that DO NOT match one of the given working time arrangement ID (exclude).
          allowEmptyValue: true
          schema:
            type: array
            items:
              title: Int32
              type: integer
              format: int32
              minimum: 0

        - name: employee.id
          in: query
          description: >
            Only return results that match one of the given employee ID.
          allowEmptyValue: true
          schema:
            type: array
            items:
              title: Int32
              type: integer
              format: int32
              minimum: 0

        - name: -employee.id
          in: query
          description: >
            Only return results that DO NOT match one of the given employee ID.
          allowEmptyValue: true
          schema:
            type: array
            items:
              title: Int32
              type: integer
              format: int32
              minimum: 0

        - name: employee.applicableEstablishment.id
          in: query
          description: >
            Only return results for employees who belong to one of the given business-establishment ID.
          allowEmptyValue: true
          schema:
            type: array
            items:
              title: Int32
              type: integer
              format: int32
              minimum: 0

        - name: -employee.applicableEstablishment.id
          in: query
          description: >
            Only return results for employees who DO NOT belong to one of the given business-establishment ID (exclude).
          allowEmptyValue: true
          schema:
            type: array
            items:
              title: Int32
              type: integer
              format: int32
              minimum: 0

        - name: employee.applicableDepartment.id
          in: query
          description: >
            Only return results for employees who belong to one of the given department ID.
          allowEmptyValue: true
          schema:
            type: array
            items:
              title: Int32
              type: integer
              format: int32
              minimum: 0

        - name: -employee.applicableDepartment.id
          in: query
          description: >
            Only return results for employees who DO NOT belong to one of the given department ID (exclude).
          allowEmptyValue: true
          schema:
            type: array
            items:
              title: Int32
              type: integer
              format: int32
              minimum: 0

        - name: startsBefore
          in: query
          description: Assignment start date must be strictly less than given date.
          schema:
            type: string
            format: date

        - name: startsAfter
          in: query
          description: Assignment start date strictly greater than given date.
          schema:
            type: string
            format: date

        - name: endsBefore
          in: query
          description: Assignment end date must be strictly less than given date.
          schema:
            type: string
            format: date

        - name: endsAfter
          in: query
          description: Assignment end date strictly greater than given date.
          schema:
            type: string
            format: date

        - name: sort
          description: Sort items by a property.
          in: query
          schema:
            type: string
            enum:
              - 'startsOn'
            default: 'startsOn'
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                type: object
                properties:
                  items:
                    type: array
                    items:
                      $ref: "#/components/schemas/WtaEmployeeAssignment"
        '400':
          description: Bad Request
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ProblemDetail'
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ProblemDetail'
        '403':
          description: Forbidden
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ProblemDetail'
        '500':
          description: Internal Server Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ProblemDetail'
    post:
      summary: Assign a Working Time Arrangement to an Employee
      x-mint:
        href: /api-reference/legacy/schedule/employee-assignments/assign-working-time-arrangement-to-employee
      tags:
        - employee-assignments
      operationId: post-assign-working-time-arrangements
      description: |-
        <Warning>
        You may not benefit from this feature. Working-time-arrangements are the
        replacement for the workcycles. If this feature has not been deployed on
        your environment, please contact our support.
        </Warning>

        Assigns a new working time arrangement to a single employee, effective from the specified start date (assignmentStart).
        
        This operation will:
        1. End the current assignment with an end date set to the eve of `assignmentStart`.
        2. Create a work-contract amendment for the employee at `assignmentStart`, that gives them the new working time arrangement.
      requestBody:
        content:
          application/json:
            schema:
              title: EmployeeAssignmentCandidate
              allOf:
                - $ref: "#/components/schemas/EmployeeAssignmentCandidate"
      responses:
        "200":
          description: OK
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/WtaEmployeeAssignment"
        '400':
          description: Bad Request
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ProblemDetail'
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ProblemDetail'
        '403':
          description: Forbidden
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ProblemDetail'
        '500':
          description: Internal Server Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ProblemDetail'
components:
  schemas:
    ShiftOverride:
      title: ShiftOverride
      type: object
      description: |
        Represents a one-time override of an employee's regular work schedule for a specific period.
      required:
        - id
        - employee
        - position
        - startsAt
        - endsAt
        - duration
        - workCycleUnit
        - nature
        - isLocked
        - createdAt
        - lastUpdatedAt
      properties:
        id:
          type: integer
          format: int32
          minimum: 0
          description: Unique identifier of the ShiftOverride.
        employee:
          type: object
          description: The employee this override applies to.
          properties:
            id:
              type: integer
              format: int32
              minimum: 0
        position:
          $ref: '#/components/schemas/DayPosition'
        startsAt:
          type: string
          format: date-time
          description: Start date-time of the override.
        endsAt:
          type: string
          format: date-time
          description: End date-time of the override.
        duration:
          $ref: '#/components/schemas/ShiftOverrideDuration'
        workCycleUnit:
          $ref: '#/components/schemas/ShiftOverrideEventUnit'
        nature:
          $ref: '#/components/schemas/ShiftOverrideNature'
        comment:
          type: ["null", "string"]
          description: Optional comment associated with the override.
        isLocked:
          type: boolean
          description: Whether the override is locked (cannot be modified).
        createdAt:
          type: string
          format: date-time
          description: Date-time when the override was created.
        createdBy:
          type: ["null", "object"]
          description: The user who created the override.
          properties:
            id:
              type: integer
              format: int32
              minimum: 0
        lastUpdatedAt:
          type: string
          format: date-time
          description: Date-time when the override was last updated.
        lastUpdatedBy:
          type: ["null", "object"]
          description: The user who last updated the override.
          properties:
            id:
              type: integer
              format: int32
              minimum: 0
    ShiftOverrideCandidate:
      title: ShiftOverrideCandidate
      type: object
      description: |
        Data required to create a ShiftOverride.
      required:
        - employeeId
        - position
        - startsAt
        - duration
        - nature
      properties:
        employeeId:
          type: integer
          format: int32
          minimum: 0
          description: The ID of the employee this override applies to.
        position:
          $ref: '#/components/schemas/DayPosition'
        startsAt:
          type: string
          format: date-time
          description: Start date-time of the override.
        duration:
          $ref: '#/components/schemas/ShiftOverrideDuration'
        nature:
          $ref: '#/components/schemas/ShiftOverrideNature'
        comment:
          type: ["null", "string"]
          description: Optional comment associated with the override.
    ShiftOverrideDuration:
      title: Duration
      type: object
      description: The duration of the override.
      required:
        - unit
        - value
        - iso
      properties:
        unit:
          type: string
          enum:
            - days
            - hours
          description: The unit in which the duration value is expressed.
        value:
          type: number
          format: decimal
          minimum: 0
          description: The numeric duration value.
          readOnly: true
        iso:
          type: string
          description: ISO 8601 duration representation.
    ShiftOverrideEventUnit:
      title: EventUnit
      type: string
      description: |
        The unit of the work cycle for this override.
        - `day`: duration expressed in days.
        - `hour`: duration expressed in hours.
        - `time`: duration expressed in hours with a specific start time.
      enum:
        - day
        - hour
        - time
    ShiftOverrideNature:
      title: ShiftOverrideNature
      type: string
      description: |
        The nature of the shift override.
        - `worked`: the employee is working.
        - `off`: the employee is off.
        - `partTime`: part-time day.
        - `weeklyRest`: weekly rest day.
      enum:
        - worked
        - off
        - partTime
        - weeklyRest
    EventUnit.v3:
      title: EventUnit
      type: integer
      format: int32
      description: |
        A (work) event can be defined in one of 3 units.
        The unit must conform to the one defined by the 
        applicable work-cycle of the given employee for the
        given date.
        - `0`: "days", the event duration is defined as a 
          fraction of a (work) day.
        - `1`: "hours", the event duration is defined as a
          number of hours.
        - `2`: "time", the event duration is defined as a 
          number of hours, at the time component of the 
          `startsAt` property indicates the starting time.
      enum:
        - 0
        - 1
        - 2
    IUserDate:
      title: IUserDate
      type: object
      properties:
        source:
          type: integer
          enum: [1, 2, 3, 5, 6]
          description: |-
            - 1: WorkCycle
            - 2: Public Holidays
            - 3: WorkCycle Exception
            - 5: Leave (from Lucca Absences)
            - 6: Entry (from Lucca Timesheet)
        dtt:
          type: string
          format: time
          example: '07:00:00'
          description: Theoretical working time. The work duration the User should comply with on this day. It is the result of the workcycle, minus the potential public holidays, delta potential workcycle exception overrides.
        drt:
          type: string
          format: time
          example: '04:15:00'
          description: Actual working time. The actual time the User spent working on this day. Results from the time-entries entered in Lucca Timesheet. If no time-entry has been entered, then defaults to the DTT value.
        draj:
          type: string
          format: time
          example: '03:30:00'
          description: Leave duration.
        isHoliday:
          type: boolean
          description: Is this day a holiday in the User's holidays calendar?
        isWeeklyRest:
          type: boolean
          description: 'Is this the weekly rest day (most often, Sundays) in the User''s workcycle?'
        items:
          type: array
          description: All events for this day and User.
          items:
            $ref: '#/components/schemas/UserDateItem'
    UserDateItem:
      title: UserDateItem
      type: object
      properties:
        type:
          type: string
          enum:
            - ptt
            - prt
            - praj
          description: |-
            Type of event:
            - `ptt`: Theoretical working hours, eg "What the User should be working".
            - `prt`: Actual working hours, eg "What the User actually did". If nothing was entered in Lucca Timesheet nor Lucca Absences, then ptt are duplicated as prt.
            - `praj`: Leave of absences.
        startsAt:
          type: string
          format: date-time
          description: Start of the event.
        duration:
          type: string
          format: time
          description: Duration of the event.
        timeline:
          type: string
          enum:
            - WorkCycle
            - PublicHoliday
            - Exception
            - Leave
            - Entry
          description: The source from which this event was pushed.
    WorkCycleException:
      title: The WorkCycleException resource
      x-tags:
        - WorkCycleExceptions
      description: |
        **Represents an override to the employee's WorkCycle.**

        **A workcycle is a setup object that indicates the working hours of one or 
        several employees with a recurring pattern (weekly, monthly, etc...).**

        Workcycles are the basis from where employee's expected working hours are
        calculated. On top of it, holidays are first added,then workcycleExceptions.

        WorkCycleExceptions are overrides to the workcycles.
        The semantics of a workcycleException is equivalent to "exceptionally,
        this employee is going to work a different number of hours on this given
        half-day". A workcycleException may set the work duration to zero, thus 
        indicating that the employee is not expected to work on this day.

        <Note>An employee may only have a **single** 
        `WorkCycleException` on any given half-day (indicated by the `startsAt`
        date and the `isAm` boolean).</Note>

        <Note>When using Lucca Timesheet, submitting a timesheet actually "locks"
        the theoretical working hours of the employee. This means that creating or deleting
        workcycleExceptions on a day that belongs to a submitted timesheet will automatically
        unapprove said timesheet.</Note>

        A `WorkCycleException` must be defined in one "unit" (days, hours or time).
        This unit must be conform to the one of the intersecting WorkCycle for the
        employee and the date.

        Examples:

        **"User #12, managed in "days" (`unit: 0`), will finally work on the afternoon of the 01/01/2023"**
        ```
        {"startsAt": "2023-01-01T12:00", "isAm": false, "duration": "12:00:00", "unit": 0}
        ```

        **"User #13, managed in "hours" (`unit: 1`), will finally work 3h30 on the morning of the 01/01/2023"**
        ```
        {"startsAt": "2023-01-01T00:00:00", "isAm": true, "duration": "03:30:00", "unit": 1}
        ```

        **"User #14, managed in "time" unit (`unit: 2`), will finally work between 09:00 and 12:30 on the morning of the 01/01/2023"**
        ```
        {"startsAt": "2023-01-01T09:00:00", "isAm": true, "duration": "03:30:00", "unit": 2}
        ```
      type: object
      required:
        - id
        - ownerId
        - isAm
        - unit
        - startsAt
        - duration
      properties:
        id:
          type: integer
          format: int32
          minimum: 1
          description: Identifier of this WorkCycleException.
          readOnly: true
        name:
          type: string
          readOnly: true
        url:
          type: string
          format: uri
          readOnly: true
        ownerId:
          type: integer
          format: int32
          minimum: 1
          description: |
            Identifier of the employee.
        owner:
          type: object
          readOnly: true
          properties:
            id:
              type: integer
              format: int32
              minimum: 1
            name:
              type: string
              description: Full name of the employee.
            url:
              type: string
              format: uri
              description: URL to the employee representation.
            firstName:
              type: string
              description: First name of the employee.
            lastName:
              type: string
              description: Last name of the employee.
        isAm:
          type: boolean
          description: |
            A work day is divided into two half-days. 
            Indicates whether the exception overrides the
            planned working hours of the first or the second
            half-day.
            - `true`: The exception overrides the first
              half-day (i.e. "morning").
            - `false`: The exception overrides the second
              half-day (i.e. "afternoon").
        unit:
          $ref: '#/components/schemas/EventUnit'
        startsAt:
          type: string
          format: date-time
        endsAt:
          type: string
          format: date-time
          readOnly: true
        durationInMinutes:
          type: integer
          format: int32
          minimum: 0
          readOnly: true
        duration:
          type: string
          format: time
        authorId:
          type: integer
          format: int32
          minimum: 0
          description: |
            The ID of the user who created this object.
            Equal to zero when created by an API key.
          readOnly: true
        createdAt:
          type: string
          format: date-time
          description: The timestamp of the moment this object was created.
          readOnly: true
        modifierId:
          type: integer
          format: int32
          minimum: 0
          description: |
            The ID of the user who last modified this object.
            Equal to zero when created by an API key.
          readOnly: true
        modifiedAt:
          type: string
          format: date-time
          description: The timestamp of the moment this object was last modified.
          readOnly: true
        deletedById:
          type: integer
          format: int32
          minimum: 0
          description: |
            The ID of the user who deleted this object.
            Equal to zero when created by an API key.
          readOnly: true
        deletedAt:
          type: string
          format: date-time
          description: The timestamp of the moment this object was deleted.
          readOnly: true
    UserDate:
      title: The UserDate resource
      x-tags:
        - UserDates
      description: |
        Userdates are a resource that aggregate all events related
        to the working schedule of an employee. There are two types 
        of events: (1) those related to the theoretical working hours
        of the employee (workcycle, holidays, workcycleExceptions) and (2)
        those related to the actual working hours of the employee (leaves,
        time-entries).

        A Userdate aggregates:
        - theoretical hours indicated by the employee's workcycle.
        - overrides to the workcycle indicated by the holidays calendar
          given to the employee.
        - overrides to the workcycle indicated by workcycleExceptions.
        - actual hours from Lucca Timesheet.
        - leaves taken in Lucca Absences.

        #### About durations
        The interpretation of durations depends on the time unit applicable to the User.

        For instance, '12:00:00' means:
          - A half-day (or 0.5 d) in `days` unit.
          - 12 hours in `hours` or `time` units.
          
        The applicable unit is set on the User's WorkCycle.
      allOf:
        - $ref: '#/components/schemas/IUserDate'
        - type: object
          properties:
            am:
              $ref: '#/components/schemas/IUserDate'
              description: Description of the first half of the day.
            pm:
              $ref: '#/components/schemas/IUserDate'
              description: Description of the second half of this day.
    WorkingTimeArrangementStatus:
      title: Working Time Arrangement Status (enum)
      x-tags:
        - Working Time Arrangements
      type: string
      description: |
        The status of a Working Time Arrangement.
        - `active`: not archived, and currently assigned to at least one employee.
        - `inactive`: not archived, but not currently assigned to any employee.
        - `archived`: should no longer be given to employees.
      enum:
        - active
        - inactive
        - archived
    WorkingTimeArrangement:
      title: The Working Time Arrangement resource
      x-tags:
        - Working Time Arrangements
      description: |
        A working time arrangement is an object aimed at drawing employees populations regarding time management rules.

        It is attached to employees through their work contract and essentially dictates:
          - their contractual working time, ie how many hours / days they are paid for each week / year.
          - a full time equivalent based on the the ratio between this contractual work duration and a "full time work duration".
          - a succession of Collective Schedules that describe their usual working hours.
          - the applicable regulation in Lucca Timesheet.
      type: object
      properties:
        id:
          type: integer
          format: int32
          minimum: 0
          description: The unique identifier of this Working Time Arrangement.
        name:
          type: string
          minLength: 3
          maxLength: 1000
          description: The unique name for this Working Time Arrangement.
        description:
          type: [string, 'null']
          minLength: 0
          maxLength: 5000
          description: An optional description.
        unit:
          $ref: '#/components/schemas/EventUnit'
        referencePeriod:
          oneOf:
            - $ref: '#/components/schemas/ReferenceWeek'
            - $ref: '#/components/schemas/ReferenceYear'
            - type: 'null'
          description: The period the Contract Working Time Duration applies over.
        contractWorkingTimeDuration:
          $ref: '#/components/schemas/Duration'
          description: How many hours / days these employees are paid for every Reference Period?
        referenceWorkingTimeDuration:
          $ref: '#/components/schemas/Duration'
          description: The number of hours / days for a full-time employee over the same Reference Period.
        fullTimeEquivalent:
          type: number
          format: decimal
          multipleOf: 0.0001
          minimum: 0
          maximum: 1
          description: |
            By default, equal to the ratio between the Contract Working Time Duration and the Reference Working Time Duration.
        fullDayAbsence:
          $ref: '#/components/schemas/FullDayAbsence'
          description: 'The fixed duration assigned to absences for one or more accounts or categories.'
        publicHolidaysCalendar:
          allOf:
            - $ref: '#/components/schemas/PublicHolidayCalendar'
            - description: Unique identifier of the Public Holidays Calendar applicable to these employees.
        isPartTime:
          type: boolean
          description: True whenever the Full Time Equivalent is below 1 (eg <100%).
          readOnly: true
        isArchived:
          type: boolean
          description: True whenever this Working Time Arrangement should no longer be given to employees.
          readOnly: true
        isScheduleValid:
          type: boolean
          description: 'False if there is not at least one Collective Schedule. In this case, the Working Time Arrangement can''t be given to any employee through his Work Contract.'
          readOnly: true
        currentAssignmentsCount:
          type: integer
          format: int32
          readOnly: true
        timesheetRegulation:
          $ref: '#/components/schemas/TimesheetRegulation'
          description: 'The applicable Lucca Timesheet regulation, which contains all rules regarding time tracking management in this application.'
        currentSchedulePatternSummary:
          $ref: '#/components/schemas/SchedulePatternSummary'
          description: 'A summary of the expected working hours, given the currently ongoing Schedule Pattern.'
        authorizedCommands:
          type: array
          description: The actions the current authenticated User can make on this Working Time Arrangement. Depends on his permissions.
          items:
            type: string
            enum:
              - create
              - update
              - delete
              - archive
              - unarchive
      required:
        - id
        - name
        - description
        - unit
        - fullTimeEquivalent
        - publicHolidaysCalendar
        - isPartTime
        - isArchived
        - isScheduleValid
        - authorizedCommands
    CollectiveSchedule:
      title: The Collective Schedule resource (named workCycle on the interface)
      description: >
        A Collective Schedule describes the employees' expected working hours over
        a week.


        It comes in two shapes:
          - "Single Week": Working hours are identical every week.
          - "Odd / Even Weeks": Working hours depend on the oddness of the week.
      type: object
      properties:
        id:
          type: integer
          format: int32
          minimum: 0
          readOnly: true
          description: The unique identifier of this Collective Schedule.
        workingTimeArrangementId:
          type: integer
          format: int32
          minimum: 0
          readOnly: true
          description: >-
            The unique identifier of the Working Time Arrangement this Collective
            Schedule belongs to.
        startsOn:
          type: [string, 'null']
          format: date
          description: >-
            The date (included) from which this Collective Schedule is applicable.
            Must be left null for the very first Collective Schedule of a Working
            Time Arrangement.
        endsOn:
          type: [string, 'null']
          format: date
          readOnly: true
          description: >
            The date (included) from which this Collective Schedule is no longer
            applicable. Is null for the last Collective Schedule of a Working Time
            Arrangement.

            Can not be modified as its equal to the day before the next applicable
            Collective Schedule for this Working Time Arrangement.
        pattern:
          oneOf:
            - $ref: '#/components/schemas/SingleWeekPattern'
            - $ref: '#/components/schemas/OddEvenWeeksPattern'
          description: The Pattern this Collective Schedule implements. Depends on the Shape.
        splitsHalfDays:
          type: boolean
          description: >-
            Should half-days be discriminated? In other words, should shifts belong
            to half days rather than just the day itself?
      required:
        - id
        - workingTimeArrangementId
        - pattern
        - splitsHalfDays
      x-tags:
        - Collective Schedules
    SingleWeekPattern:
      title: Single week SchedulePattern
      x-internal: true
      x-tags:
        - Schedule Patterns
      allOf:
        - $ref: '#/components/schemas/SchedulePattern'
        - type: object
          properties:
            monday:
              $ref: '#/components/schemas/SchedulePatternDay'
            tuesday:
              $ref: '#/components/schemas/SchedulePatternDay'
            wednesday:
              $ref: '#/components/schemas/SchedulePatternDay'
            thursday:
              $ref: '#/components/schemas/SchedulePatternDay'
            friday:
              $ref: '#/components/schemas/SchedulePatternDay'
            saturday:
              $ref: '#/components/schemas/SchedulePatternDay'
            sunday:
              $ref: '#/components/schemas/SchedulePatternDay'
    OddEvenWeeksPattern:
      title: Odd-even weeks Schedule Pattern
      x-internal: true
      x-tags:
        - Schedule Patterns
      allOf:
        - $ref: '#/components/schemas/SchedulePattern'
        - type: object
          properties:
            oddWeek:
              $ref: '#/components/schemas/SingleWeekPattern'
            evenWeek:
              $ref: '#/components/schemas/SingleWeekPattern'
    SchedulePattern:
      title: Schedule Pattern
      type: object
      properties:
        shape:
          $ref: '#/components/schemas/SchedulePatternShape'
      discriminator:
        propertyName: shape
        mapping:
          singleWeek: '#/components/schemas/SingleWeekPattern'
          oddEvenWeeks: '#/components/schemas/OddEvenWeeksPattern'
      required:
        - shape
    SchedulePatternDay:
      title: Schedule Pattern Day
      type: object
      properties:
        id:
          type: integer
          format: int32
          minimum: 0
        dayOffType:
          $ref: '#/components/schemas/DayOffType'
          description: >
            Gives the reason why this day should not be worked, as it largely impacts
            the leave management system:
              - 'partTime': this is the day off of a part-time employee.
              - 'weeklyRest': often used to mark Sundays.
              - 'off': often used to mark Saturdays.
        shifts:
          type: array
          items:
            $ref: '#/components/schemas/SchedulePatternShift'
        workDuration:
          $ref: '#/components/schemas/Duration'
          description: The total duration of work expected on this day.
      required:
        - id
        - shifts
    SchedulePatternShift:
      title: Shift of a Schedule Pattern
      type: object
      properties:
        position:
          $ref: '#/components/schemas/DayPosition'
          description: Depends on the Splits Half Days property of the Collective Schedule.
        startsAt:
          type: [string, 'null']
          format: time
          description: >-
            Not null when the Working Time Arrangement Unit is "time". Must be left
            null otherwise.
        duration:
          $ref: '#/components/schemas/Duration'
          description: The duration in hours or days (depending on the Unit) of this work Shift.
      required:
        - duration
        - position
    EventUnit:
      title: Event Unit (enum)
      x-internal: true
      x-tags:
        - Core
      type: string
      enum:
        - day
        - hour
        - time
      description: |-
        An event can be set in:
        - Day: "I worked for a half day last Monday".
        - Hour: "I worked for 2 hours last Monday".
        - Time: "I worked between 10:00 AM and 12:00 AM last Monday".
    TimesheetRegulation:
      title: Lucca Timesheet regulation
      x-tags:
        - Applications
      type: object
      properties:
        id:
          type: integer
          format: int32
          minimum: 0
        name:
          type: string
          minLength: 1
          readOnly: true
      required:
        - id
        - name
    Duration:
      title: Duration
      x-internal: true
      x-tags:
        - Core
      type: object
      properties:
        value:
          type: number
          format: decimal
          multipleOf: 0.0001
          minimum: 0
          readOnly: true
        iso:
          type: string
          format: duration
        unit:
          $ref: '#/components/schemas/DurationUnit'
    DurationUnit:
      title: Duration Unit
      type: string
      enum:
        - days
        - hours
      readOnly: true
    SchedulePatternSummary:
      title: Summary of a Schedule Pattern
      type: object
      properties:
        shape:
          $ref: '#/components/schemas/SchedulePatternShape'
        days:
          type: array
          items:
            type: object
            properties:
              dayOffType:
                $ref: '#/components/schemas/DayOffType'
              workPosition:
                $ref: '#/components/schemas/DayPosition'
              workDuration:
                type: [number, 'null']
                format: decimal
                minimum: 0
              workDurationUnit:
                $ref: '#/components/schemas/DurationUnit'
      required:
        - days
        - shape
    DayOffType:
      title: DayOffType (enum)
      x-internal: true
      type: string
      enum:
        - 'off'
        - partTime
        - weeklyRest
      description: |-
        When a user requests a leave during a period, the type of day off defines whether the off days of the period must be counted according to the settings of the absence (unit and part time policy).
    DayPosition:
      title: DayPosition
      type: string
      enum:
        - firstHalf
        - secondHalf
        - fullDay
    SchedulePatternShape:
      title: Shape of a Schedule Pattern
      type: string
      enum:
        - singleWeek
        - oddEvenWeeks
    ReferenceWeek:
      title: Week
      x-internal: true
      x-tags:
        - Working Time Arrangements
      allOf:
        - $ref: '#/components/schemas/ReferencePeriod'
        - type: object
          properties:
            firstDayOfWeek:
              $ref: '#/components/schemas/DayOfWeek'
      required:
        - firstDayOfWeek
        - frequencyType
    ReferenceYear:
      title: Year
      x-internal: true
      x-tags:
        - Working Time Arrangements
      allOf:
        - $ref: '#/components/schemas/ReferencePeriod'
        - type: object
          properties:
            firstMonth:
              $ref: '#/components/schemas/Month'
      required:
        - firstMonth
        - frequencyType
    ReferencePeriod:
      title: Reference Period
      x-internal: true
      x-tags:
        - Working Time Arrangements
      type: object
      properties:
        frequencyType:
          $ref: '#/components/schemas/FrequencyType'
      discriminator:
        propertyName: frequencyType
        mapping:
          week: '#/components/schemas/ReferenceWeek'
          year: '#/components/schemas/ReferenceYear'
      required:
        - frequencyType
    Month:
      title: Month
      type: string
      enum:
        - january
        - february
        - march
        - april
        - may
        - june
        - july
        - august
        - september
        - october
        - november
        - december
    FrequencyType:
      title: Frequency Type
      type: string
      enum:
        - week
        - year
    DayOfWeek:
      title: dayOfWeek
      type: string
      enum:
        - monday
        - tuesday
        - wednesday
        - thursday
        - friday
        - saturday
        - sunday
    ProblemDetail:
      title: ProblemDetail
      type: object
      properties:
        type:
          type: string
          format: uri
          description: Type of problem encountered.
        title:
          type: string
          description: Human-readable description of the type of problem encountered.
        detail:
          type: string
          description: Human-readable description of the problem encountered.
    PublicHolidayCalendar:
      title: 'PublicHolidayCalendar,'
      required:
        - id
      type: object
      properties:
        id:
          type: integer
          format: int32
          minimum: 0
          description: The unique identifier of this holiday calendar.
        name:
          type: [string, 'null']
          readOnly: true
    FullDayAbsence:
      title: FullDayAbsence
      type: object
      required:
        - absenceAccountIds
        - absenceCategoryIds
        - duration
      properties:
        duration:
          title: Duration
          allOf:
            - $ref: "#/components/schemas/Duration"
          description: 'The fixed duration assigned to an absence.'
        absenceAccountIds:
          type: array
          uniqueItems: true
          items:
            title: Int32
            type: integer
            format: int32
            minimum: 0
          description: 'The identifiers of the absence accounts this full day absence applies to.'
        absenceCategoryIds:
          type: array
          uniqueItems: true
          items:
            title: Int32
            type: integer
            format: int32
            minimum: 0
          description: 'The identifiers of the absence categories this full day absence applies to.'
    WtaEmployeeAssignment:
      title: WtaEmployeeAssignment
      type: object
      required:
        - employee
        - startsOn
        - workContractId
      properties:
        id:
          type: integer
          format: int32
          minimum: 0
        workContractId:
          type: integer
          format: int32
          minimum: 0
        workingTimeArrangement:
          title: WorkingTimeArrangementLite
          allOf:
            - $ref: "#/components/schemas/WorkingTimeArrangementLite"
        startsOn:
          type: string
          format: date
        endsOn:
          type: ["null", "string"]
          format: date
        employee:
          title: WtaEmpoyee
          allOf:
            - $ref: "#/components/schemas/WtaEmployee"
    WorkingTimeArrangementLite:
      title: WorkingTimeArrangementLite
      type: object
      required:
        - id
        - name
        - unit
      properties:
        id:
          type: integer
          format: int32
          minimum: 0
          readOnly: true
        name:
          type: string
        unit:
          $ref: "#/components/schemas/EventUnit"
    WtaEmployee:
      title: WtaEmployee
      type: object
      required:
        - department
        - displayName
        - employeeNumber
        - establishmentId
        - establishmentName
        - firstName
        - id
        - jobQualificationName
        - lastName
      properties:
        id:
          type: integer
          format: int32
          minimum: 0
        firstName:
          type: string
        lastName:
          type: string
        displayName:
          type: string
          readOnly: true
        jobQualificationName:
          type: string
        employeeNumber:
          type: string
        establishmentId:
          type: integer
          format: int32
          minimum: 0
        establishmentName:
          type: string
        department:
          $ref: "#/components/schemas/WtaDepartment" 
    WtaDepartment:
      title: Department
      type: object
      required:
        - id
        - name
      properties:
        id:
          type: integer
          format: int32
          minimum: 0
        name:
          type: string
    EmployeeAssignmentCandidate:
      title: EmployeeAssignmentCandidate
      type: object
      required:
        - workingTimeArrangementId
        - startsOn
        - employeeId
      properties:
        employeeId:
          type: integer
          format: int32
          minimum: 0
        workingTimeArrangementId:
          type: integer
          format: int32
          minimum: 0
        startsOn:
          type: string
          format: date
  responses:
    ResponseProblem:
      description: Problem
      content:
        application/json:
          schema:
            type: object
            properties:
              Status:
                type: integer
                description: HTTP status code.
                example: 401
              Message:
                type: string
                description: Human readable error message.
                example: Unauthorized
  parameters:
    page:
      name: page
      in: query
      description: Next page token
      required: false
      schema:
        type: string
        examples:
          - 'next_token&fields.root=next'
          - '2'
    limit:
      name: limit
      in: query
      description: Number of items per page
      required: false
      schema:
        type: integer
        minimum: 0
        maximum: 100
        default: 10
    fields.root:
      name: fields.root
      in: query
      description: Include collection properties.
      required: false
      schema:
        type: string
        enum:
          - count
    workingTimeArrangementId_path:
      name: workingTimeArrangementId
      description: The unique identifier of the Working Time Arrangement.
      in: path
      required: true
      schema:
        type: integer
        format: int32
        minimum: 0
    Authorization:
      name: Authorization
      required: true
      description: |-
        API key. Value must be formatted like so: `lucca application={api_key}`.
      in: header
      schema:
        type: string
