From 403de11041468848f51463aade956aa374db852f Mon Sep 17 00:00:00 2001 From: Albin Antony Date: Tue, 24 Oct 2023 11:19:14 +0530 Subject: [PATCH] Fix #340 Update organisation admin api request and response body --- resources/config | 2 +- .../onboard_update_organisation_admin.go | 24 +++++++++---------- 2 files changed, 13 insertions(+), 13 deletions(-) diff --git a/resources/config b/resources/config index ccedc32..c3a4f09 160000 --- a/resources/config +++ b/resources/config @@ -1 +1 @@ -Subproject commit ccedc329ebc0c3d904ea96b697880173b51aaa56 +Subproject commit c3a4f09ef85e32fc95cc4735ab168a5a009e7284 diff --git a/src/v2/handler/onboard/onboard_update_organisation_admin.go b/src/v2/handler/onboard/onboard_update_organisation_admin.go index 60bac59..109b9db 100644 --- a/src/v2/handler/onboard/onboard_update_organisation_admin.go +++ b/src/v2/handler/onboard/onboard_update_organisation_admin.go @@ -16,21 +16,21 @@ import ( "github.com/bb-consent/api/src/v2/iam" ) -type updateOrgAdminReq struct { +type orgAdmin struct { Id string `json:"id"` Email string `json:"email"` Name string `json:"name" valid:"required"` AvatarImageId string `json:"avatarImageId"` AvatarImageUrl string `json:"avatarImageUrl"` + LastVisited string `json:"lastVisited"` +} + +type updateOrgAdminReq struct { + OrganisationAdmin orgAdmin `json:"organisationAdmin"` } type updateOrgAdminResp struct { - Id string `json:"id"` - Email string `json:"email"` - Name string `json:"name"` - AvatarImageId string `json:"avatarImageId"` - AvatarImageUrl string `json:"avatarImageUrl"` - LastVisited string `json:"lastVisited"` + OrganisationAdmin orgAdmin `json:"organisationAdmin"` } // OnboardUpdateOrganisationAdmin @@ -66,10 +66,10 @@ func OnboardUpdateOrganisationAdmin(w http.ResponseWriter, r *http.Request) { return } - if strings.TrimSpace(upReq.Name) != "" { - u.Name = upReq.Name + if strings.TrimSpace(upReq.OrganisationAdmin.Name) != "" { + u.Name = upReq.OrganisationAdmin.Name - err = iam.UpdateIamUser(upReq.Name, u.IamID) + err = iam.UpdateIamUser(upReq.OrganisationAdmin.Name, u.IamID) if err != nil { m := fmt.Sprintf("Failed to update IAM user by id:%v", u.ID) common.HandleError(w, http.StatusInternalServerError, m, err) @@ -85,7 +85,7 @@ func OnboardUpdateOrganisationAdmin(w http.ResponseWriter, r *http.Request) { return } - resp := updateOrgAdminResp{ + orgAdmin := orgAdmin{ Id: u.ID.Hex(), Email: u.Email, Name: u.Name, @@ -94,7 +94,7 @@ func OnboardUpdateOrganisationAdmin(w http.ResponseWriter, r *http.Request) { LastVisited: u.LastVisit, } - response, _ := json.Marshal(resp) + response, _ := json.Marshal(updateOrgAdminResp{OrganisationAdmin: orgAdmin}) w.Header().Set(config.ContentTypeHeader, config.ContentTypeJSON) w.WriteHeader(http.StatusOK) w.Write(response)