-
Notifications
You must be signed in to change notification settings - Fork 1
DemoScenariesEng_GettingStarted_PrivEth
This scenario is executed in the Private Ethereum (PrivEth) cluster.
The script demonstrates the distribution of the deal by nodes and switching the deal status.
A pre-installed smart contract with the FirstDeal deal type is used (without a transition map).
- A deal with
DocNumber, DocDate, DocSummaattributes is created on thePrivEth-1node - Switching the deal status to
Status1on thePrivEth-1node - Make sure that the deal arrives at the
PrivEth-1andPrivEth-2nodes, and that there is no deal at thePrivEth-3node - On the
PrivEth-2node, the deal status is switched toStatus2, thePaymentDateattribute is added and theDocSummaattribute is changed - Ensure that changes in the deal are made to
PrivEth-1andPrivEth-2nodes. - On the
PrivEth-1node, the status of the deal is switched toClosed - Ensure that changes in the deal are made to
PrivEth-1andPrivEth-2nodes, and that there is still no deal atPrivEth-3node
ATTENTION! In the examples of calls, the ID of the trial deal is substituted - You should substitute the ID obtained when creating a deal at step 1.
ATTENTION! In queries in the CHANNEL header, you must use the personal identifier you received during registration. This will not interfere with simultaneous work of several users, and will facilitate the work of the Technical Support Service if you have any questions. Demo personal identifier is used in request examples.
- Getting the deal identifier
- Checking for the absence of a deal at other nodes (this step is purely a demo step, in order to make sure that the deal is nowhere "in advance" and its replication will occur only after creation).
- Deal creation itself
GET method call /api/uid is used. The method returns GUID, which can be used once to create a deal.
| Example call: | Example answer |
|---|---|
curl -X GET "http://democlient1.kekker.com/api/uid" -H "accept: text/plain" -H "Authorization: Basic S2Vra2VyVXNlcjp6RGZqbTMz" -H "channel: Demo" |
"840a0671-4afa-4f87-9f3f-12c252b30ca0" |
GET method call /api/deals/{UID} is used. Where {UID} is the deal identifier, for example, obtained at the previous step
| Example call (the difference is in the node URL) | Example answer |
|---|---|
curl -X GET "http://democlient1.kekker.com/api/deals/840a0671-4afa-4f87-9f3f-12c252b30ca0" -H "accept: text/plain" -H "Authorization: Basic S2Vra2VyVXNlcjp6RGZqbTMz" -H "channel: Demo" |
{"ErrorMessage":"Deal not found"} |
curl -X GET "http://democlient2.kekker.com/api/deals/840a0671-4afa-4f87-9f3f-12c252b30ca0" -H "accept: text/plain" -H "Authorization: Basic S2Vra2VyVXNlcjp6RGZqbTMz" -H "channel: Demo" |
|
curl -X GET "http://democlient3.kekker.com/api/deals/840a0671-4afa-4f87-9f3f-12c252b30ca0" -H "accept: text/plain" -H "Authorization: Basic S2Vra2VyVXNlcjp6RGZqbTMz" -H "channel: Demo" |
POST method call /api/deals/ is used. The json-specification of the deal is specified as the request data, in our case:
{
"dealUid": "[UID]",
"kind": "FirstDeal",
"parties": [ { "key": "CLIENT1", "role": "Role1" },
{ "key": "ClIENT2", "role": "Role2" }
],
"parameters": [ { "key": "DocNumber", "value": "1" },
{ "key": "DocDate", "value": "11.02.2020" },
{ "key": "DocSumma", "value": "10000" }
],
"parentDealUid": null
}| Example call: | Example answer |
|---|---|
curl -X POST "http://democlient1.kekker.com/api/deals" -H "accept: text/plain" -H "Content-Type: application/json-patch+json" -H "Authorization: Basic S2Vra2VyVXNlcjp6RGZqbTMz" -H "channel: Demo" -d "{ \"dealUid\": \"840a0671-4afa-4f87-9f3f-12c252b30ca0\", \"kind\": \"FirstDeal\", \"parties\": [ { \"key\": \"CLIENT1\", \"role\": \"Role1\" } ,{ \"key\": \"CLIENT2\", \"role\": \"Role2\" } ], \"parameters\": [ { \"key\": \"DocNumber\", \"value\": \"1\" },{ \"key\": \"DocDate\", \"value\": \"11.02.2020\" },{ \"key\": \"DocSumma\", \"value\": \"10000\" } ], \"parentDealUid\": null}" |
Empty if no errors |
POST method call /api/deals/setstatus is used. The json-specification of the deal is specified as the request data, in our case:
{
"dealUid": "[UID]",
"status": "Status1__",
"remark": "Status changed to Status1 by CLIENT1",
"parameters": []
}
| Example call: | Example answer |
|---|---|
curl -X POST "http://democlient1.kekker.com/api/deals/setstatus" -H "accept: text/plain" -H "Authorization: Basic S2Vra2VyVXNlcjp6RGZqbTMz" -H "Content-Type: application/json-patch+json" -H "channel: Demo" -d "{ \"dealUid\":\"840a0671-4afa-4f87-9f3f-12c252b30ca0\", \"status\":\"Status1__\", \"remark\":\"Status changed to Status1 by CLIENT1\", \"parameters\": []}" |
Empty if no errors |
3. Make sure that the deal arrives at the PrivEth-1 and PrivEth-2 nodes, and that there is no deal at the PrivEth-3 node
GET method call /api/deals/{UID} is used. Where {UID} is the deal identifier
It is better to take a pause of 2-3 minutes after step [2] before making requests.
| Example call (the difference is in the node URL) | Example answer (special interest on the fields "kind", "status" and "parameters" collection ) |
|---|---|
curl -X GET "http://democlient1.kekker.com/api/deals/840a0671-4afa-4f87-9f3f-12c252b30ca0" -H "accept: text/plain" -H "Authorization: Basic S2Vra2VyVXNlcjp6RGZqbTMz" -H "channel: Demo" |
On the PrivEth-1 and PrivEth-2 nodes the answer is {"uid":"840a0671-4afa-4f87-9f3f-12c252b30ca0","kind":"FirstDeal","status":"Status1__","remark":"Status changed to Status1 by CLIENT1","parameters":[{"key":"DocNumber","value":"1"},{"key":"DocDate","value":"11.02.2020"},{"key":"DocSumma","value":"10000"}],"parties":[{"key":"CLIENT1","role":"Role1"},{"key":"CLIENT2","role":"Role2"}],"files":[],"history":[{"status":"Status1__","party":{"key":"CLIENT1","role":"Role1"},"remark":"Status changed to Status1 by CLIENT1","version":2}],"statusMap":[]}
|
curl -X GET "http://democlient2.kekker.com/api/deals/840a0671-4afa-4f87-9f3f-12c252b30ca0" -H "accept: text/plain" -H "Authorization: Basic S2Vra2VyVXNlcjp6RGZqbTMz" -H "channel: Demo" |
On the PrivEth-3 node the answer should be {"ErrorMessage":"Deal not found"} |
curl -X GET "http://democlient3.kekker.com/api/deals/840a0671-4afa-4f87-9f3f-12c252b30ca0" -H "accept: text/plain" -H "Authorization: Basic S2Vra2VyVXNlcjp6RGZqbTMz" -H "channel: Demo" |
4. On the PrivEth-2 node, the deal status is switched to Status2, the PaymentDate attribute is added and the DocSumma attribute is changed
POST method call /api/deals/setstatus is used. The json-specification of the new deal status is specified as the request data, in our case:
{
"dealUid": "[UID]",
"status": "Status2__",
"remark": "Status changed to Status2 by CLIENT2",
"parameters": [ { "key": "DocSumma", "value": "20022" },
{ "key": "PaymentDate", "value": "15.03.2020" }
],
}
| Example call: | Example answer |
|---|---|
curl -X POST "http://democlient2.kekker.com/api/deals/setstatus" -H "accept: text/plain" -H "Authorization: Basic S2Vra2VyVXNlcjp6RGZqbTMz" -H "Content-Type: application/json-patch+json" -H "channel: Demo" -d "{ \"dealUid\":\"840a0671-4afa-4f87-9f3f-12c252b30ca0\", \"status\":\"Status2__\", \"remark\":\"Status changed to Status2 by CLIENT2\", \"parameters\": [{\"key\":\"DocSumma\",\"value\":"20022"}, {\"key\":\"PaymentDate\",\"value\":\"15.03.2020\"}]}" |
Empty if no errors |
GET method call /api/deals/{UID} is used. Where {UID} is the deal identifier
It is better to take a pause of 1-2 minutes after step [4] before making requests.
| Example call (the difference is in the node URL) | Example answer (special interest on the fields "status", "history" and "parameters" collections ) |
|---|---|
curl -X GET "http://democlient1.kekker.com/api/deals/840a0671-4afa-4f87-9f3f-12c252b30ca0" -H "accept: text/plain" -H "Authorization: Basic S2Vra2VyVXNlcjp6RGZqbTMz" -H "channel: Demo" |
{"uid":"840a0671-4afa-4f87-9f3f-12c252b30ca0","kind":"FirstDeal","status":"Status2__","remark":"Status changed to Status2 by CLIENT2","parameters":[{"key":"DocNumber","value":"1"},{"key":"DocDate","value":"11.02.2020"},{"key":"DocSumma","value":"20022"},{"key":"PaymentDate","value":"15.03.2020"}],"parties":[{"key":"CLIENT1","role":"Role1"},{"key":"CLIENT2","role":"Role2"}],"files":[],"history":[{"status":"Status1__","party":{"key":"CLIENT1","role":"Role1"},"remark":"Status changed to Status1 by CLIENT1","version":2},{"status":"Status2__","party":{"key":"CLIENT2","role":"Role2"},"remark":"Status changed to Status2 by CLIENT2","version":3}],"statusMap":[]} |
curl -X GET "http://democlient2.kekker.com/api/deals/840a0671-4afa-4f87-9f3f-12c252b30ca0" -H "accept: text/plain" -H "Authorization: Basic S2Vra2VyVXNlcjp6RGZqbTMz" -H "channel: Demo" |
POST method call /api/deals/setstatus is used. The json-specification of the new deal status is specified as the request data, in our case:
{
"dealUid": "[UID]",
"status": "Closed___",
"remark": "Deal closed by CLIENT1",
"parameters": []
}
| Example call: | Example answer |
|---|---|
curl -X POST "http://democlient1.kekker.com/api/deals/setstatus" -H "accept: text/plain" -H "Authorization: Basic S2Vra2VyVXNlcjp6RGZqbTMz" -H "Content-Type: application/json-patch+json" -H "channel: Demo" -d "{ \"dealUid\":\"840a0671-4afa-4f87-9f3f-12c252b30ca0\", \"status\":\"Closed___\", \"remark\":\"Deal closed by CLIENT1\", \"parameters\": []}" |
Empty if no errors |
7. Ensure that changes in the deal are made to PrivEth-1 and PrivEth-2 nodes, and that there is still no deal at PrivEth-3 node
GET method call /api/deals/{UID} is used. Where {UID} is the deal identifier
It is better to take a pause of 1-2 minutes after step [6] before making requests.
| Example call (the difference is in the node URL) | Example answer (special interest on the fields "status" and "history" collection ) |
|---|---|
curl -X GET "http://democlient1.kekker.com/api/deals/840a0671-4afa-4f87-9f3f-12c252b30ca0" -H "accept: text/plain" -H "Authorization: Basic S2Vra2VyVXNlcjp6RGZqbTMz" -H "channel: Demo" |
On the PrivEth-1 and PrivEth-2 nodes the answer is {"uid":"840a0671-4afa-4f87-9f3f-12c252b30ca0","kind":"FirstDeal","status":"Closed___","remark":"Deal closed by CLIENT1","parameters":[{"key":"DocNumber","value":"1"},{"key":"DocDate","value":"11.02.2020"},{"key":"DocSumma","value":"20022"},{"key":"PaymentDate","value":"15.03.2020"}],"parties":[{"key":"CLIENT1","role":"Role1"},{"key":"CLIENT2","role":"Role2"}],"files":[],"history":[{"status":"Status1__","party":{"key":"CLIENT1","role":"Role1"},"remark":"Status changed to Status1 by CLIENT1","version":2},{"status":"Status2__","party":{"key":"CLIENT2","role":"Role2"},"remark":"Status changed to Status2 by CLIENT2","version":3},{"status":"Closed___","party":{"key":"CLIENT1","role":"Role1"},"remark":"Deal closed by CLIENT1","version":4}],"statusMap":[]}
|
curl -X GET "http://democlient2.kekker.com/api/deals/840a0671-4afa-4f87-9f3f-12c252b30ca0" -H "accept: text/plain" -H "Authorization: Basic S2Vra2VyVXNlcjp6RGZqbTMz" -H "channel: Demo" |
On the PrivEth-3 node the answer should be {"ErrorMessage":"Deal not found"} |
curl -X GET "http://democlient3.kekker.com/api/deals/840a0671-4afa-4f87-9f3f-12c252b30ca0" -H "accept: text/plain" -H "Authorization: Basic S2Vra2VyVXNlcjp6RGZqbTMz" -H "channel: Demo" |