Skip to content

Commit

Permalink
Add generated catalog code to SDK
Browse files Browse the repository at this point in the history
This is an API client generated by openapi-generator-cli

Only changes made to this are:
- Adding dependencies to our version catalog
- Changing package structure to fit with the SDK paradigm

This state is temporary.
  • Loading branch information
michpohl committed Jun 19, 2024
1 parent 363afe1 commit 12e663e
Show file tree
Hide file tree
Showing 140 changed files with 9,292 additions and 60 deletions.
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.

561 changes: 561 additions & 0 deletions catalog/src/main/kotlin/com/tidal/sdk/catalog/apis/AlbumJSONAPIApi.kt

Large diffs are not rendered by default.

555 changes: 555 additions & 0 deletions catalog/src/main/kotlin/com/tidal/sdk/catalog/apis/ArtistJSONAPIApi.kt

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

0 comments on commit 12e663e

Please sign in to comment.