Live demo: https://stake-limiter.herokuapp.com/
Clone the repo
cd into project folder
run docker-compose up -d
run docker-compose run app php artisan migrate:fresh --seed
visit localhost:8080
PHP >= 7.2.5
BCMath PHP Extension
Ctype PHP Extension
Fileinfo PHP extension
JSON PHP Extension
Mbstring PHP Extension
OpenSSL PHP Extension
PDO PHP Extension
Tokenizer PHP Extension
XML PHP Extension
Clone this repo
Create a database which you will use for the project
cd into the project folder
rename .env.example into .env
populate the .env with your db info
run composer install (post install script will migrate the tables and seed the db)
run php artisan key:generate
run npm install
run php artisan serve
URL : /api/device/check-limits
Method : POST
Request examples
{
"id": "ef65ef3e-d212-3137-7f56-ec533cb7759d",
"deviceId": "6c834452-d73f-3e63-9cf6-31372da42078",
"stake": 300.99
}
Data constraints
{
"id": "(uuid)",
"deviceId": "(uuid)",
"stake": "(double)"
}
Code : 200
Content examples
For a device which is below all limits.
{
"status": "OK"
}
For a device which has sum of stakes higher or equal {config hot amount} in the last {config time duration}
{
"status": "HOT"
}
For a device which has sum of stakes higher or equal {config stake limit} in the last {config time duration}
{
"status": "BLOCKED"
}
- If the device sent in the request body is not in the database, it will be created for future tracking.
URL : /api/config/update
Method : POST
Request examples
{
"stakeLimit": 1000,
"timeDuration": 500,
"hotAmountPctg": 80,
"restrExpiry": 1800
}
Data constraints
{
"stakeLimit": "required|numeric|min:1|max:10000000",
"timeDuration": "required|numeric|min:300|max:86400",
"hotAmountPctg": "required|numeric|min:1|max:100",
"restrExpiry": "required|numeric"
}
Code : 200
Content examples
{
"Configuration updated."
}
Code : 422
Content examples
{
"message": "The given data was invalid.",
"errors": {
"stakeLimit": [
"The stake limit must be at least 1."
],
"timeDuration": [
"The time duration must be at least 300."
],
"hotAmountPctg": [
"The hot amount pctg must be at least 1."
],
"restrExpiry": [
"The restr expiry must be a number."
]
}
}
- If the restrExpiry is 0 device will not be unblocked automatically.