io.contentchef.callback.common.Channel.kt Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of contentchef-jvm-callback-common Show documentation
Show all versions of contentchef-jvm-callback-common Show documentation
ContentChef's JVM callback common SDK stuff - https://www.contentchef.io
package io.contentchef.callback.common
import io.contentchef.common.data.ContentChefItemResponse
import io.contentchef.common.data.ContentChefSearchResponse
import io.contentchef.common.request.RequestData
import org.json.JSONObject
/**
* A channel is a collector of contents which can be used to retrieve them from ContentChef's backend
* [C] is the Class Type which identifies parameters used for content services
* [S] is the Class Type which identifies parameters used for search services
*/
interface Channel {
/**
* Retrieves a content by the parameters specified in [contentRequestData]
* Calls [onSuccess] on a successful operation, otherwise calls [onError]
*/
fun getContent(
contentRequestData: C,
onSuccess: (responseContent: ContentChefItemResponse) -> Unit,
onError: (throwable: Throwable) -> Unit
)
/**
* Retrieves a content by the parameters specified in [contentRequestData]
* Calls [onSuccess] on a successful operation, otherwise calls [onError]
* The [mapper] is used to transform the [JSONObject] into [K]. If an error happens during the transformation [onError] will be called
*/
fun getContent(
contentRequestData: C,
onSuccess: (responseContent: ContentChefItemResponse) -> Unit,
onError: (throwable: Throwable) -> Unit,
mapper: (JSONObject) -> K
)
/**
* Retrieves a list of content based on the chosen search criteria as specified in [searchRequestData]
* Calls [onSuccess] on a successful operation, otherwise calls [onError]
*/
fun search(
searchRequestData: S,
onSuccess: (responseContent: ContentChefSearchResponse) -> Unit,
onError: (throwable: Throwable) -> Unit
)
/**
* Retrieves a list of content based on the chosen search criteria as specified in [searchRequestData]
* Calls [onSuccess] on a successful operation, otherwise calls [onError]
* The [mapper] is used to transform the [JSONObject] into [K]. If an error happens during the transformation [onError] will be called
*/
fun search(
searchRequestData: S,
onSuccess: (responseContent: ContentChefSearchResponse) -> Unit,
onError: (throwable: Throwable) -> Unit,
mapper: (JSONObject) -> K
)
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy