Skip to content

Commit

Permalink
Add #616 Add consentRecord and revision objects to the response of up…
Browse files Browse the repository at this point in the history
…date signature endpoint
  • Loading branch information
albinpa authored and georgepadayatti committed Jan 17, 2024
1 parent 50b3b4d commit c5a0165
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions internal/handler/v2/service/service_update_signature_object.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,9 @@ type updateSignatureforDataAgreementRecordReq struct {
}

type updateSignatureforDataAgreementRecordResp struct {
Signature signature.Signature `json:"signature"`
DataAgreementRecord daRecord.DataAgreementRecord `json:"consentRecord"`
Revision revision.Revision `json:"revision"`
Signature signature.Signature `json:"signature"`
}

func ServiceUpdateSignatureObject(w http.ResponseWriter, r *http.Request) {
Expand Down Expand Up @@ -119,7 +121,7 @@ func ServiceUpdateSignatureObject(w http.ResponseWriter, r *http.Request) {
toBeUpdatedDaRecord.State = config.Signed

// Save data agreement to db
_, err = darRepo.Update(toBeUpdatedDaRecord)
savedDaRecord, err := darRepo.Update(toBeUpdatedDaRecord)
if err != nil {
m := "Failed to update data agreement record"
common.HandleErrorV2(w, http.StatusInternalServerError, m, err)
Expand All @@ -137,15 +139,17 @@ func ServiceUpdateSignatureObject(w http.ResponseWriter, r *http.Request) {
newRevision.SerializedHash = savedSignature.VerificationPayloadHash

// Save the revision to db
_, err = revision.Add(newRevision)
savedRevision, err := revision.Add(newRevision)
if err != nil {
m := fmt.Sprintf("Failed to create new revision: %v", newRevision.Id)
common.HandleErrorV2(w, http.StatusInternalServerError, m, err)
return
}

resp := updateSignatureforDataAgreementRecordResp{
Signature: savedSignature,
DataAgreementRecord: savedDaRecord,
Revision: savedRevision,
Signature: savedSignature,
}

response, _ := json.Marshal(resp)
Expand Down

0 comments on commit c5a0165

Please sign in to comment.