diff --git a/app/src/main/java/it/bz/noi/community/data/models/Contact.kt b/app/src/main/java/it/bz/noi/community/data/models/Contact.kt index 3e85679..9d284fe 100644 --- a/app/src/main/java/it/bz/noi/community/data/models/Contact.kt +++ b/app/src/main/java/it/bz/noi/community/data/models/Contact.kt @@ -24,8 +24,10 @@ data class Contact( val email: String?, @SerializedName("_parentcustomerid_value") val accountId: String?, - - val companyName: String? + @SerializedName("companyName") + val companyName: String?, + @SerializedName("app-opt-out") + val appOptOut: Boolean = false, ) : Parcelable data class ContactResponse( diff --git a/app/src/main/java/it/bz/noi/community/data/repository/MainRepository.kt b/app/src/main/java/it/bz/noi/community/data/repository/MainRepository.kt index f6eaf75..a0ed183 100644 --- a/app/src/main/java/it/bz/noi/community/data/repository/MainRepository.kt +++ b/app/src/main/java/it/bz/noi/community/data/repository/MainRepository.kt @@ -7,7 +7,16 @@ package it.bz.noi.community.data.repository import it.bz.noi.community.data.api.ApiHelper import it.bz.noi.community.data.models.* -class MainRepository(private val apiHelper: ApiHelper) { +class MainRepository( + /** + * Remote data source. + */ + private val apiHelper: ApiHelper, + /** + * If enabled, [Contact]s with `appOptOut` set to `true` will be filtered out. + */ + private val isOptOutEnabled: Boolean = false +) { // EVENTS suspend fun getEvents(eventsParams: EventsParams) = apiHelper.getEvents(eventsParams) suspend fun getEventDetails(eventID: String) = apiHelper.getEventDetails(eventID) @@ -23,6 +32,7 @@ class MainRepository(private val apiHelper: ApiHelper) { // CONTACTS suspend fun getAccounts(accessToken: String): List = apiHelper.getAccounts(accessToken).accounts - suspend fun getContacts(accessToken: String): List = apiHelper.getContacts(accessToken).contacts - + suspend fun getContacts(accessToken: String): List = apiHelper.getContacts(accessToken).contacts.let { + if (isOptOutEnabled) it.filter { !it.appOptOut } else it + } }