Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add generated catalog models #17

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,10 @@ sdkModules.forEach {
tasks.dokkaHtmlMultiModule.configure {
moduleVersion = "bom-${project(":bom").property("version")}"
includes.setFrom("README.md")
pluginsMapConfiguration.set(mapOf("org.jetbrains.dokka.base.DokkaBase" to
"""{"footerMessage": "© ${LocalDate.now().year} TIDAL"}"""
))
pluginsMapConfiguration.set(
mapOf(
"org.jetbrains.dokka.base.DokkaBase" to
"""{"footerMessage": "© ${LocalDate.now().year} TIDAL"}""",
),
)
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import androidx.compose.material.Surface
import androidx.compose.material.Text
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import com.tidal.sdk.catalog.Catalog

class MainActivity : ComponentActivity() {

Expand All @@ -22,7 +21,7 @@ class MainActivity : ComponentActivity() {
modifier = Modifier.fillMaxSize(),
color = MaterialTheme.colors.background,
) {
Greeting(Catalog().helloCatalog())
Greeting("Catalog")
}
}
}
Expand Down
6 changes: 5 additions & 1 deletion catalog/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,11 @@ android {
}

dependencies {

implementation(libs.moshi.kotlin)
implementation(libs.moshi.kotlin)
implementation(libs.moshi.adapters)
implementation(libs.okhttp.okhttp)
testImplementation(libs.kotlintest.runner.junit5)
api(libs.tidal.sdk.common)

testApi(libs.test.androidx.junit)
Expand Down

This file was deleted.

19 changes: 0 additions & 19 deletions catalog/src/main/kotlin/com/tidal/sdk/catalog/Catalog.kt

This file was deleted.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -0,0 +1,210 @@
/**
*
* Please note:
* This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
* Do not edit this file manually.
*
*/

@file:Suppress(
"ArrayInDataClass",
"EnumEntryName",
"RemoveRedundantQualifierName",
"UnusedImport"
)

package com.tidal.sdk.catalog.apis

import com.tidal.sdk.catalog.infrastructure.ApiClient
import com.tidal.sdk.catalog.infrastructure.ApiResponse
import com.tidal.sdk.catalog.infrastructure.ClientError
import com.tidal.sdk.catalog.infrastructure.ClientException
import com.tidal.sdk.catalog.infrastructure.MultiValueMap
import com.tidal.sdk.catalog.infrastructure.RequestConfig
import com.tidal.sdk.catalog.infrastructure.RequestMethod
import com.tidal.sdk.catalog.infrastructure.ResponseType
import com.tidal.sdk.catalog.infrastructure.ServerError
import com.tidal.sdk.catalog.infrastructure.ServerException
import com.tidal.sdk.catalog.infrastructure.Success
import com.tidal.sdk.catalog.infrastructure.toMultiValue
import com.tidal.sdk.catalog.models.ProviderDataDocument
import com.tidal.sdk.catalog.models.ProvidersDataDocument
import okhttp3.HttpUrl
import okhttp3.OkHttpClient
import java.io.IOException

class ProviderJSONAPIApi(basePath: kotlin.String = defaultBasePath, client: OkHttpClient = ApiClient.defaultClient) : ApiClient(basePath, client) {
companion object {
@JvmStatic
val defaultBasePath: String by lazy {
System.getProperties().getProperty(ApiClient.BASE_URL_KEY, "https://openapi.stage.tidal.com/v2")
}
}

/**
* Get single provider
* Retrieve provider details by TIDAL provider id.
* @param id TIDAL provider id
* @param include Allows the client to customize which related resources should be returned (optional)
* @return ProviderDataDocument
* @throws IllegalStateException If the request is not correctly configured
* @throws IOException Rethrows the OkHttp execute method exception
* @throws UnsupportedOperationException If the API returns an informational or redirection response
* @throws ClientException If the API returns a client error response
* @throws ServerException If the API returns a server error response
*/
@Suppress("UNCHECKED_CAST")
@Throws(IllegalStateException::class, IOException::class, UnsupportedOperationException::class, ClientException::class, ServerException::class)
fun getProvider(id: kotlin.String, include: kotlin.collections.List<kotlin.String>? = null) : ProviderDataDocument {
val localVarResponse = getProviderWithHttpInfo(id = id, include = include)

return when (localVarResponse.responseType) {
ResponseType.Success -> (localVarResponse as Success<*>).data as ProviderDataDocument
ResponseType.Informational -> throw UnsupportedOperationException("Client does not support Informational responses.")
ResponseType.Redirection -> throw UnsupportedOperationException("Client does not support Redirection responses.")
ResponseType.ClientError -> {
val localVarError = localVarResponse as ClientError<*>
throw ClientException("Client error : ${localVarError.statusCode} ${localVarError.message.orEmpty()}", localVarError.statusCode, localVarResponse)
}
ResponseType.ServerError -> {
val localVarError = localVarResponse as ServerError<*>
throw ServerException("Server error : ${localVarError.statusCode} ${localVarError.message.orEmpty()} ${localVarError.body}", localVarError.statusCode, localVarResponse)
}
}
}

/**
* Get single provider
* Retrieve provider details by TIDAL provider id.
* @param id TIDAL provider id
* @param include Allows the client to customize which related resources should be returned (optional)
* @return ApiResponse<ProviderDataDocument?>
* @throws IllegalStateException If the request is not correctly configured
* @throws IOException Rethrows the OkHttp execute method exception
*/
@Suppress("UNCHECKED_CAST")
@Throws(IllegalStateException::class, IOException::class)
fun getProviderWithHttpInfo(id: kotlin.String, include: kotlin.collections.List<kotlin.String>?) : ApiResponse<ProviderDataDocument?> {
val localVariableConfig = getProviderRequestConfig(id = id, include = include)

return request<Unit, ProviderDataDocument>(
localVariableConfig
)
}

/**
* To obtain the request config of the operation getProvider
*
* @param id TIDAL provider id
* @param include Allows the client to customize which related resources should be returned (optional)
* @return RequestConfig
*/
fun getProviderRequestConfig(id: kotlin.String, include: kotlin.collections.List<kotlin.String>?) : RequestConfig<Unit> {
val localVariableBody = null
val localVariableQuery: MultiValueMap = mutableMapOf<kotlin.String, kotlin.collections.List<kotlin.String>>()
.apply {
if (include != null) {
put("include", toMultiValue(include.toList(), "multi"))
}
}
val localVariableHeaders: MutableMap<String, String> = mutableMapOf()
localVariableHeaders["Content-Type"] = "application/vnd.api+json"
localVariableHeaders["Accept"] = "application/vnd.api+json"

return RequestConfig(
method = RequestMethod.GET,
path = "/providers/{id}".replace("{"+"id"+"}", encodeURIComponent(id.toString())),
query = localVariableQuery,
headers = localVariableHeaders,
requiresAuthentication = true,
body = localVariableBody
)
}

/**
* Get multiple providers
* Retrieve multiple provider details.
* @param include Allows the client to customize which related resources should be returned (optional)
* @param filterId Allows to filter the collection of resources based on id attribute value (optional)
* @return ProvidersDataDocument
* @throws IllegalStateException If the request is not correctly configured
* @throws IOException Rethrows the OkHttp execute method exception
* @throws UnsupportedOperationException If the API returns an informational or redirection response
* @throws ClientException If the API returns a client error response
* @throws ServerException If the API returns a server error response
*/
@Suppress("UNCHECKED_CAST")
@Throws(IllegalStateException::class, IOException::class, UnsupportedOperationException::class, ClientException::class, ServerException::class)
fun getProviders(include: kotlin.collections.List<kotlin.String>? = null, filterId: kotlin.collections.List<kotlin.String>? = null) : ProvidersDataDocument {
val localVarResponse = getProvidersWithHttpInfo(include = include, filterId = filterId)

return when (localVarResponse.responseType) {
ResponseType.Success -> (localVarResponse as Success<*>).data as ProvidersDataDocument
ResponseType.Informational -> throw UnsupportedOperationException("Client does not support Informational responses.")
ResponseType.Redirection -> throw UnsupportedOperationException("Client does not support Redirection responses.")
ResponseType.ClientError -> {
val localVarError = localVarResponse as ClientError<*>
throw ClientException("Client error : ${localVarError.statusCode} ${localVarError.message.orEmpty()}", localVarError.statusCode, localVarResponse)
}
ResponseType.ServerError -> {
val localVarError = localVarResponse as ServerError<*>
throw ServerException("Server error : ${localVarError.statusCode} ${localVarError.message.orEmpty()} ${localVarError.body}", localVarError.statusCode, localVarResponse)
}
}
}

/**
* Get multiple providers
* Retrieve multiple provider details.
* @param include Allows the client to customize which related resources should be returned (optional)
* @param filterId Allows to filter the collection of resources based on id attribute value (optional)
* @return ApiResponse<ProvidersDataDocument?>
* @throws IllegalStateException If the request is not correctly configured
* @throws IOException Rethrows the OkHttp execute method exception
*/
@Suppress("UNCHECKED_CAST")
@Throws(IllegalStateException::class, IOException::class)
fun getProvidersWithHttpInfo(include: kotlin.collections.List<kotlin.String>?, filterId: kotlin.collections.List<kotlin.String>?) : ApiResponse<ProvidersDataDocument?> {
val localVariableConfig = getProvidersRequestConfig(include = include, filterId = filterId)

return request<Unit, ProvidersDataDocument>(
localVariableConfig
)
}

/**
* To obtain the request config of the operation getProviders
*
* @param include Allows the client to customize which related resources should be returned (optional)
* @param filterId Allows to filter the collection of resources based on id attribute value (optional)
* @return RequestConfig
*/
fun getProvidersRequestConfig(include: kotlin.collections.List<kotlin.String>?, filterId: kotlin.collections.List<kotlin.String>?) : RequestConfig<Unit> {
val localVariableBody = null
val localVariableQuery: MultiValueMap = mutableMapOf<kotlin.String, kotlin.collections.List<kotlin.String>>()
.apply {
if (include != null) {
put("include", toMultiValue(include.toList(), "multi"))
}
if (filterId != null) {
put("filter[id]", toMultiValue(filterId.toList(), "multi"))
}
}
val localVariableHeaders: MutableMap<String, String> = mutableMapOf()
localVariableHeaders["Content-Type"] = "application/vnd.api+json"
localVariableHeaders["Accept"] = "application/vnd.api+json"

return RequestConfig(
method = RequestMethod.GET,
path = "/providers",
query = localVariableQuery,
headers = localVariableHeaders,
requiresAuthentication = true,
body = localVariableBody
)
}


private fun encodeURIComponent(uriComponent: kotlin.String): kotlin.String =
HttpUrl.Builder().scheme("http").host("localhost").addPathSegment(uriComponent).build().encodedPathSegments[0]
}
Loading
Loading