#
Token manager
Služba je zodpovedná za generovanie, overovanie a deaktivovanie tokenov nahrávaných na NFC tagy. Služba rovnako ovláda a interaguje s Token writter-om , ktorý sa stará o samostné nahranie tokenu na NFC tag.
Token je generovaný pomocou uuid
bez znakov -
, napríklad 858c0eb798a8475dbcf67e29ddb4966e
.
Deaktivovaný token je označený ako {"active": false}
.
Aktivovaný a zapísaný token je označený ako {"active": true}
a {"written": true}
.
Token je považovaný ako platný iba ak je aktívny ({"active": true}
).
#
Komunikácia s frontendom
Token manager komunikuje s frontendovou aplikáciou pomocou websocketov. Používateľa informuje o stave zapisovačky, o úspešnom alebo neúspešnom zapísaní tokenu alebo o možnosti nahrávania ďalšieho tokenu. Vo websockete sa posiela udalosť writer_status
, ktorý nadobúda hodnoty off
, idle
, success
, error
.
#
Popis API
#
root__get
Code samples
import requests
headers = {
'Accept': 'application/json'
}
r = requests.get('/gateway/token-manager-api/', headers = headers)
print(r.json())
GET /
Root
Simple hello message.
Example responses
200 Response
{
"status": "string",
"message": "string"
}
Responses
Response Schema
#
activate_state_tokens_writer_activate_post
Code samples
import requests
headers = {
'Accept': 'application/json'
}
r = requests.post('/gateway/token-manager-api/tokens/writer/activate', headers = headers)
print(r.json())
POST /tokens/writer/activate
Activate State
Activate NFC writer machine. After turning on, machine's LED will turn on and be able to write data to NFC tokens.
Example responses
200 Response
{
"status": "string",
"message": "string"
}
Responses
Response Schema
#
deactivate_state_tokens_writer_deactivate_post
Code samples
import requests
headers = {
'Accept': 'application/json'
}
r = requests.post('/gateway/token-manager-api/tokens/writer/deactivate', headers = headers)
print(r.json())
POST /tokens/writer/deactivate
Deactivate State
Deactivate NFC writer machine. Led on machine will turn off.
Example responses
200 Response
{
"status": "string",
"message": "string"
}
Responses
Response Schema
#
delete_unwritten_tokens_writer_delete_post
Code samples
import requests
headers = {
'Content-Type': 'application/json',
'Accept': 'application/json'
}
r = requests.post('/gateway/token-manager-api/tokens/writer/delete', headers = headers)
print(r.json())
POST /tokens/writer/delete
Delete Unwritten
Delete unwritten NFC tokens from database.
Body parameter
{
"event": "string"
}
Parameters
Example responses
200 Response
{
"status": "string",
"message": "string"
}
Responses
Response Schema
#
update_written_tokens_writer_update_post
Code samples
import requests
headers = {
'Content-Type': 'application/json',
'Accept': 'application/json'
}
r = requests.post('/gateway/token-manager-api/tokens/writer/update', headers = headers)
print(r.json())
POST /tokens/writer/update
Update Written
Update NFC token state from unwritten to written.
Body parameter
{
"token": "string"
}
Parameters
Example responses
200 Response
{
"status": "string",
"message": "string"
}
Responses
Response Schema
#
create_token_tokens_create_post
Code samples
import requests
headers = {
'Accept': 'application/json'
}
r = requests.post('/gateway/token-manager-api/tokens/create', headers = headers)
print(r.json())
POST /tokens/create
Create Token
Generates new token and returns it.
Example responses
200 Response
{
"status": "string",
"token": "string"
}
Responses
Response Schema
#
validate_token_tokens_validate_post
Code samples
import requests
headers = {
'Content-Type': 'application/json',
'Accept': 'application/json'
}
r = requests.post('/gateway/token-manager-api/tokens/validate', headers = headers)
print(r.json())
POST /tokens/validate
Validate Token
Validate if provided token is valid. If token is invalid returns empty response with status 403 else status 200.
Body parameter
{
"token": "string"
}
Parameters
Example responses
200 Response
null
Responses
Response Schema
#
deactivate_token_tokens_deactivate_post
Code samples
import requests
headers = {
'Content-Type': 'application/json',
'Accept': 'application/json'
}
r = requests.post('/gateway/token-manager-api/tokens/deactivate', headers = headers)
print(r.json())
POST /tokens/deactivate
Deactivate Token
Deactivate provided token. Change active status to false. If token is invalid returns empty response with status 403 else status 200.
Body parameter
{
"token": "string"
}
Parameters
Example responses
200 Response
null
Responses
Response Schema
#
delete_token_tokens_delete_delete
Code samples
import requests
headers = {
'Content-Type': 'application/json',
'Accept': 'application/json'
}
r = requests.delete('/gateway/token-manager-api/tokens/delete', headers = headers)
print(r.json())
DELETE /tokens/delete
Delete Token
Delete provided token. If token is invalid returns empty response with status 403 else status 200.
Body parameter
{
"token": "string"
}
Parameters
Example responses
200 Response
null
Responses
Response Schema
#
Schemas
#
Body_deactivate_token_tokens_deactivate_post
{
"token": "string"
}
Body_deactivate_token_tokens_deactivate_post
#
Properties
#
Body_delete_token_tokens_delete_delete
{
"token": "string"
}
Body_delete_token_tokens_delete_delete
#
Properties
#
Body_delete_unwritten_tokens_writer_delete_post
{
"event": "string"
}
Body_delete_unwritten_tokens_writer_delete_post
#
Properties
#
Body_update_written_tokens_writer_update_post
{
"token": "string"
}
Body_update_written_tokens_writer_update_post
#
Properties
#
Body_validate_token_tokens_validate_post
{
"token": "string"
}
Body_validate_token_tokens_validate_post
#
Properties
#
HTTPValidationError
{
"detail": [
{
"loc": [
"string"
],
"msg": "string",
"type": "string"
}
]
}
HTTPValidationError
#
Properties
#
ValidationError
{
"loc": [
"string"
],
"msg": "string",
"type": "string"
}
ValidationError