Run the following command to generate a composer server API:
composer-rest-server
Enter admin@insurance-claim-network from the business network card, as shown in the following screenshot:
This will a generate the REST API and expose it as http://serverIP:3000 and http:// serverIP:3000/explorer.
Open the explore URL. You will see the generated REST endpoints, as follows:
Let's try a number of methods to demonstrate how these endpoints interact with the fabric network.
Select the init Post method from endpoints, provide the post JSON data, and click the Try it out! button. The example of JSON data is shown as follows:
{
"$class": "com.packt.quickstart.claim.Init",
"insureeId": "user-001",
"firstName": "John",
"lastName": "Smith",
"ssn": "9999",
"policyNumber": "string"
}
Here is a screenshot that shows the result after clicking the Try it out! button:
The API will call the Init chaincode in the fabric network and return the response to the browser.
Select a company using a post method to create an insuree. Enter this JSON request as follows:
{
"$class": "com.packt.quickstart.claim.Init",
"insureeId": "user-001",
"firstName": "John",
"lastName": "Smith",
"ssn": "9999",
"policyNumber": "string"
}
You should see a successful response, similar to the one shown in the following screenshot:
Select the ReportLost Post method from endpoints, provide the post JSON data, and click Try it out!:
{
"$class": "com.packt.quickstart.claim.ReportLost",
"claimId": "claim_001",
"desc": "I was in Destiny shopping center and lost my IPhone 8",
"insureeId": "user_001",
"brokerId": "broker_001"
}
You should see a success response back from the blockchain.
To verify that the claim was successfully created in the network, you can select the claim get method and click Try it out! You should be able to get the claim result, as follows:
Other insurance claims endpoint APIs will be quite similar to the ones we have explored.