Skip to content

Commit

Permalink
Fix: #253 - Consent status toggle issue resolved
Browse files Browse the repository at this point in the history
  • Loading branch information
lijogeorgep authored and josmilan committed Apr 22, 2024
1 parent 70e7a7c commit 33df4a9
Showing 1 changed file with 15 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package com.github.privacyDashboard.communication.repositories

import com.github.privacyDashboard.communication.BBConsentAPIServices
import com.github.privacyDashboard.models.*
import com.github.privacyDashboard.models.v2.consent.ConsentStatusRequestV2
import com.github.privacyDashboard.models.v2.dataAgreement.DataAgreementsResponseV2
import com.github.privacyDashboard.models.v2.dataAgreement.DataAgreementV2
import com.github.privacyDashboard.models.v2.dataAgreement.dataAgreementRecords.DataAgreementRecordsResponseV2
Expand Down Expand Up @@ -66,6 +67,20 @@ class GetDataAgreementsApiRepository(private val apiService: BBConsentAPIService
try {
dataAgreementRecordsV2 =
dataAgreementRecords?.last { dataAgreementRecordsV2 -> dataAgreementRecordsV2.dataAgreementId == it.id }
if (!(it.lawfulBasis == "consent" || it.lawfulBasis == "legitimate_interest")){
if(dataAgreementRecordsV2!=null){
if (dataAgreementRecordsV2?.optIn == false){
val body = ConsentStatusRequestV2()
body.optIn = true
val updateDataAgreementStatusApiRepository =
UpdateDataAgreementStatusApiRepository(apiService)
val updateDataAgreementResponse=updateDataAgreementStatusApiRepository.updateDataAgreementStatus(userId,it.id,body)
if (updateDataAgreementResponse.isSuccess) {
dataAgreementRecordsV2=updateDataAgreementResponse.getOrNull()?.dataAgreementRecord
}
}
}
}
} catch (e: Exception) {
if (!(it.lawfulBasis == "consent" || it.lawfulBasis == "legitimate_interest")) {
val createDataAgreementResponse =
Expand Down

0 comments on commit 33df4a9

Please sign in to comment.