In this step, the insuree reports the lost item to the broker with all the claim information. This function also records the current system process time at theĀ processAt field. currentts.Format(2006-01-02 15:04:05) is a Go custom format; it will convert the current time into YYYY-MM-dd hh:mm:ss format, as shown in the following example:
func (c *ClaimContract) ReportLost(stub shim.ChaincodeStubInterface, args []string) pb.Response {
claimId := args[0]
desc := args[1]
insureeId := args[2]
brokerId := args[3]
currentts := time.Now()
processAt := currentts.Format("2006-01-02 15:04:05")
//initialized claim
claimData := Claim{
Id: claimId,
Desc: desc,
Status: "ReportLost",
InsureeId: insureeId,
BrokerId: brokerId,
InsurerId: "",
Comment: "",
ProcessAt: processAt}
claimBytes, _ := json.Marshal(claimData)
stub.PutState(claimId, claimBytes)
return shim.Success(claimBytes)
}