Project to explore Temporal API with Encore.dev framework.
RESTFUL service to trigger temporal workflows w.r.t to Bills. Ability to start workflow to increase invoice, and await confirmation signal.
To run:
- Install Encore.dev
- Install Temporal locally
- On a terminal, run
make temporal
. - On another, run
make dev
to run encore.
make test
curl --location --request POST 'http://127.0.0.1:4000/bill/456'
Response:
{
"ID": "456",
"status": "OPEN",
"transactions": []
}
curl --location --request PUT 'http://127.0.0.1:4000/bill/456/' \
--header 'Content-Type: application/json' \
--data '{
"timestamp": 10000,
"itemName": "abc",
"amount": {
"number": 100,
"currency": "USD"
}
}'
Response
{
"BillID": "456",
"WorkflowID": "bill-456-XmrdfVQAtZXJ43BPtd45D"
}
The BillID
and the WorkflowID
will be used to trigger the confirmation endpoint.
curl --location 'http://127.0.0.1:4000/confirm/bill/456/bill-456-XmrdfVQAtZXJ43BPtd45D'
Response
{
"message": "invoiced confirmed"
}
Specify currency via query param, e.g. currency=GEL
. Otherwise, currency defaults to USD
.
curl --location 'http://127.0.0.1:4000/bill/456?currency=GEL'
Response:
{
"ID": "456",
"status": "CLOSED",
"transactions": [
{
"timestamp": 10000,
"itemName": "abc",
"amount": {
"number": "271.00",
"currency": "GEL"
}
}
]
}
curl --location --request PUT 'http://127.0.0.1:4000/close/bill/456/'
Response:
{
"items": [
"abc"
],
"total": {
"number": "100",
"currency": "USD"
}
}