Files
lincodex/api/core/routes/candidate_invitation_view.yml
T

48 lines
2.8 KiB
YAML

post:
operationId: ViewMyInvitation
summary: Record that the current candidate opened the terms of an invitation.
description: |-
Requires the session cookie of a candidate account, the CSRF token of that session in X-CSRF-Token, and an allowed Origin. The candidate comes from the session. The request has no body.
The view transition of PRD FR12 (TASK-200) is an explicit command, so reading the invitation with GetMyInvitation stays free of side effects. The client sends it when the candidate opens the terms screen. For a `delivered` invitation the server moves it to `viewed`, sets `viewed_at`, advances `version`, and keeps the deadline. In any other state, including `viewed`, `accepted`, and the terminal states, it changes nothing and answers 200 with the current invitation. A view never reopens, extends, or answers an invitation, and the organization sees only the state `viewed` and `viewed_at`.
The command is idempotent by its effect: the first view wins and every repeat returns the current invitation. It therefore needs no Idempotency-Key and no `expected_version`: a view must never fail because the invitation changed after the client read it, for example after a salary raise. A view at the deadline or later first applies the due expiry and answers 200 with `expired`.
The general rate limit can answer 429 with Retry-After before any check.
Access: a missing, unknown, expired, or revoked session answers 401 unauthenticated; a missing or wrong CSRF token or a disallowed Origin answers 403 csrf_check_failed; an employer account answers 403 forbidden; a draft, an invitation addressed to another candidate, and an unknown identifier all answer 404 not_found. An `invitation_id` that is not a UUID answers 400 validation_failed with the path pointer.
security:
- sessionCookie: []
sessionCsrf: []
tags:
- invitation
parameters:
- $ref: ../components/parameters.yml#/MyInvitationId
responses:
"200":
description: >-
The invitation, now `viewed` when it was `delivered`, otherwise in
its current state.
headers:
Cache-Control:
$ref: ../components/headers.yml#/CacheControlNoStore
content:
application/json:
schema:
$ref: ../components/schemas.yml#/CandidateInvitation
examples:
viewed:
$ref: ../components/examples.yml#/CandidateInvitationViewed
"400":
$ref: ../components/responses.yml#/ValidationFailed
"401":
$ref: ../components/responses.yml#/Unauthenticated
"403":
$ref: ../components/responses.yml#/CsrfCheckFailedOrForbidden
"404":
$ref: ../components/responses.yml#/NotFound
"429":
$ref: ../components/responses.yml#/TooManyRequests
default:
$ref: ../components/responses.yml#/Problem