Skip to content

Commit

Permalink
Add: #209 - Function to fetch the data agreement
Browse files Browse the repository at this point in the history
  • Loading branch information
josmilan authored and georgepadayatti committed Nov 13, 2023
1 parent 2277879 commit f352263
Showing 1 changed file with 34 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import android.content.Context
import android.content.Intent
import com.github.privacyDashboard.communication.BBConsentAPIManager
import com.github.privacyDashboard.communication.BBConsentAPIServices
import com.github.privacyDashboard.communication.repositories.GetDataAgreementApiRepository
import com.github.privacyDashboard.communication.repositories.UpdateDataAgreementStatusApiRepository
import com.github.privacyDashboard.models.v2.consent.ConsentStatusRequestV2
import com.github.privacyDashboard.modules.home.BBConsentDashboardActivity
Expand Down Expand Up @@ -204,4 +205,37 @@ object PrivacyDashboard {
}

}

suspend fun getDataAgreement(
dataAgreementId: String,
baseUrl: String,
accessToken: String? = null,
apiKey: String? = null,
userId: String? = null,
): String? {

val apiService: BBConsentAPIServices = BBConsentAPIManager.getApi(
apiKey = apiKey,
accessToken = accessToken,
baseUrl = (if (baseUrl.last().toString() == "/")
baseUrl
else
"$baseUrl/")
)?.service!!

val dataAgreementApiRepository =
GetDataAgreementApiRepository(apiService)

val result = dataAgreementApiRepository.getDataAgreement(
userId = userId,
dataAgreementId = dataAgreementId
)

return if (result.isSuccess) {
Gson().toJson(result.getOrNull()?.dataAgreement)
} else {
null
}

}
}

0 comments on commit f352263

Please sign in to comment.