status = false (sold) and update both Firestore and PostgreSQL with each scan.
Functions overview
| Function | Action |
|---|---|
tickets_access_control_in | Record an attendee entering the venue |
tickets_access_control_out | Record an attendee exiting the venue |
tickets_access_control_cold | Batch sync offline entry/exit events |
tickets_access_control_in
Records an attendee’s entry. Handles three scenarios: first-time entry, re-entry after exit, and rejection if the ticket was already used for entry without a corresponding exit.
Endpoint
Request body
The ticket ID to scan for entry. Must match a sold ticket (
status = false).Example
What it does
The function checksaccess_status and access_entry to determine the correct action:
access_status | access_entry | Outcome |
|---|---|---|
false | false | First entry. Sets access_status = true, access_entry = true, appends "accessed" to ledger. |
true | false | Re-entry after exit. Sets access_entry = true. |
true | true | Already inside. Rejects the scan. |
Response
Outcome description.
200 on success, 400 on rejection.Only tickets with
status = false (sold) can be scanned. Unsold tickets (status = true) are rejected as invalid.tickets_access_control_out
Records an attendee’s exit from the venue. Sets access_entry = false and appends a "came-out" ledger entry.
Endpoint
Request body
The ticket ID to scan for exit. Must match a sold ticket (
status = false) that has previously entered.Example
What it does
The function checksaccess_status and access_entry before allowing exit:
access_status | access_entry | Outcome |
|---|---|---|
true | true | Records exit. Sets access_entry = false, appends "came-out" to ledger. |
false | false | Ticket never entered. Rejects the scan. |
Response
Exit recorded (200):tickets_access_control_cold
Processes a batch of entry and exit events collected while a scanning device was offline. Each event in the batch is applied in order, and the results are written to both Firestore and PostgreSQL in a single batch commit.
Endpoint
Request body
Array of access events to process. Each item represents a single scan recorded while offline.
Example
What it does
- Iterates over each item in
tickets_cold. - Fetches the ticket from PostgreSQL. Skips if not found or already processed (deduplication using a
procesadosset). - Determines the last action per
ticket_idbased ontipo:"in"→"accessed","out"→"came-out". - Appends the action to the ticket’s
ledger. - Commits all Firestore updates in a single batch.
- Runs a single bulk
UPDATEagainst PostgreSQL.