Small library that can understand json
calls one per line and throw an answer after processing the lines
npm i
npm run dev
npm start
- Multiple lines can be send at once
- The program runs on
console
- After all json are send you start processing typing
end
max-limit
max-limit
not setpayment-id
already existedinsufficient-limit
Set max limit. Always set the last one and reset the limit
{"payment-rules": {"max-limit": 100}}
{"payment-rules": {"max-limit": 200}}
Payment session already initialized
{"payment-rules": {"max-limit": 100}}
{"payment-session": {"payment-id": 89087653}}
{"payment-session": {"payment-id": 89087653}}
Payment rules not initialized
{"payment-session": {"payment-id": 89087653}}
Insufficient limit
{"payment-rules": {"max-limit": 100}}
{"payment-session": {"payment-id": 89087654, "cc": "visa", "amount": 120, "time": "2022-02-13T10:00:00.000Z"}}
More than three (3) transactions in two minutes
{"payment-rules": {"max-limit": 100}}
{"payment-session": {"payment-id": 89087654, "cc": "visa", "time": "2022-02-13T10:00:00.000Z"}}
{"payment-session": {"payment-id": 89087655, "cc": "visa", "time": "2022-02-13T10:01:00.000Z"}}
{"payment-session": {"payment-id": 89087656, "cc": "visa", "time": "2022-02-13T10:01:00.000Z"}}
{"payment-session": {"payment-id":89087652,"cc":"visa","amount":30,"time":"2022-02-13T10:00:00.000Z","available-limit":70,"violations":[]}}
- There is no error handling in the app for json parsing. We assume the inputs are correct. Be aware of that
- All errors that have a rule are considered violations and are returned in the output