From dd422bfcb0521a245b6bab6058dbbe7b4b7d03d1 Mon Sep 17 00:00:00 2001 From: "penify-dev[bot]" <146478655+penify-dev[bot]@users.noreply.github.com> Date: Tue, 2 Jul 2024 15:41:23 +0000 Subject: [PATCH] Generated Documentation --- .../com/skydoves/sandwichdemo/MainActivity.kt | 11 + .../skydoves/sandwichdemo/MainRepository.kt | 22 + .../skydoves/sandwichdemo/MainViewModel.kt | 35 +- .../sandwichdemo/MainViewModelFactory.kt | 11 + .../skydoves/sandwichdemo/SandwichDemoApp.kt | 11 + .../sandwichdemo/adapter/PosterAdapter.kt | 33 ++ .../adapter/RecyclerViewBinding.kt | 33 ++ .../datasource/MainDataSourceActivity.kt | 11 + .../datasource/MainDataSourceViewModel.kt | 11 + .../MainDataSourceViewModelFactory.kt | 11 + .../mapper/ErrorEnvelopeMapper.kt | 11 + .../mapper/SuccessPosterMapper.kt | 11 + .../network/DisneyDataSourceService.kt | 11 + .../sandwichdemo/network/DisneyService.kt | 22 + .../network/KtorfitPokemonService.kt | 11 + .../network/RequestInterceptor.kt | 11 + .../operator/CommonResponseOperator.kt | 33 ++ .../operator/GlobalResponseOperator.kt | 44 ++ .../operator/MainOperatorActivity.kt | 11 + .../operator/MainOperatorViewModelFactory.kt | 11 + .../sandwich/ktor/ApiResponseExtension.kt | 65 ++- .../sandwich/ktor/HttpClientExtension.kt | 88 +++ .../sandwich/ktor/HttpStatementExtension.kt | 11 + .../ktorfit/ApiResponseConverterFactory.kt | 22 + .../retrofit/datasource/DataSource.kt | 83 ++- .../datasource/DataSourceTransformer.kt | 10 +- .../retrofit/datasource/ResponseDataSource.kt | 161 +++++- .../datasource/ResponseTransformer.kt | 55 ++ .../adapters/DataSourceCallAdapterFactory.kt | 22 + .../internal/DataSourceCallAdapter.kt | 22 + .../internal/DataSourceCallDelegate.kt | 22 + .../internal/DataSourceRawCallAdapter.kt | 22 + .../disposables/CompositeDisposable.kt | 36 +- .../datasource/disposables/Disposable.kt | 24 +- .../disposables/DisposableTransformer.kt | 20 +- .../datasource/executors/ArchTaskExecutor.kt | 37 +- .../executors/DefaultTaskExecutor.kt | 33 ++ .../datasource/executors/TaskExecutor.kt | 11 +- .../retrofit/datasource/ApiAbstract.kt | 44 ++ .../DataSourceRawCallAdapterTest.kt | 11 + .../retrofit/datasource/DataSourceTest.kt | 66 +++ .../retrofit/datasource/DisneyClient.kt | 22 + .../datasource/DisneyDataSourceService.kt | 11 + .../retrofit/datasource/DisneyService.kt | 11 + .../serialization/SerializationExtensions.kt | 22 + .../SerializationExtensionsTest.kt | 22 + .../retrofit/ApiResponseExtensions.kt | 43 +- .../sandwich/retrofit/ResponseTransformer.kt | 44 ++ .../adapters/ApiResponseCallAdapterFactory.kt | 22 + .../internal/ApiResponseCallAdapter.kt | 22 + .../internal/ApiResponseCallDelegate.kt | 22 + .../ApiResponseDeferredCallAdapter.kt | 22 + .../interceptors/EmptyBodyInterceptor.kt | 11 + .../com/skydoves/sandwich/ApiAbstract.kt | 44 ++ .../sandwich/ApiResponseExtensionsTest.kt | 55 ++ .../skydoves/sandwich/ApiResponseRetryTest.kt | 11 + .../sandwich/ApiResponseSuspendTest.kt | 33 ++ .../com/skydoves/sandwich/ApiResponseTest.kt | 77 +++ .../com/skydoves/sandwich/DisneyClient.kt | 11 + .../sandwich/DisneyCoroutinesService.kt | 22 + .../com/skydoves/sandwich/DisneyService.kt | 11 + .../skydoves/sandwich/ErrorEnvelopeMapper.kt | 11 + .../skydoves/sandwich/MainCoroutinesRule.kt | 22 + .../sandwich/NoContentExceptionTest.kt | 22 + .../kotlin/com/skydoves/sandwich/Poster.kt | 11 + .../sandwich/ResponseTransformerTest.kt | 517 ++++++++++++++++++ .../sandwich/SandwichInitializerTest.kt | 44 ++ .../skydoves/sandwich/SuccessPosterMapper.kt | 11 + .../com/skydoves/sandwich/ApiResponse.kt | 83 ++- .../skydoves/sandwich/ResponseTransformer.kt | 345 ++++++++++-- .../sandwich/retry/ApiResponseRetry.kt | 22 + .../skydoves/sandwich/retry/RetryPolicy.kt | 22 +- 72 files changed, 2761 insertions(+), 117 deletions(-) diff --git a/app/src/main/kotlin/com/skydoves/sandwichdemo/MainActivity.kt b/app/src/main/kotlin/com/skydoves/sandwichdemo/MainActivity.kt index 000a30c..b9351f2 100644 --- a/app/src/main/kotlin/com/skydoves/sandwichdemo/MainActivity.kt +++ b/app/src/main/kotlin/com/skydoves/sandwichdemo/MainActivity.kt @@ -47,4 +47,15 @@ class MainActivity : AppCompatActivity() { Toast.makeText(this, it, Toast.LENGTH_SHORT).show() } } +/** + * Transforms the sign-up request data to match the backend's expected format. + * + * @param {SignUpRequest} signUpData - The original sign-up request data. + * + * @returns {Object} The transformed sign-up request data with the following changes: + * - `firstName` is mapped to `first_name` + * - `lastName` is mapped to `last_name` + * - `email` is mapped to `username` + * - All other properties remain unchanged. + */ } diff --git a/app/src/main/kotlin/com/skydoves/sandwichdemo/MainRepository.kt b/app/src/main/kotlin/com/skydoves/sandwichdemo/MainRepository.kt index 649c734..9b0a36a 100644 --- a/app/src/main/kotlin/com/skydoves/sandwichdemo/MainRepository.kt +++ b/app/src/main/kotlin/com/skydoves/sandwichdemo/MainRepository.kt @@ -25,6 +25,28 @@ class MainRepository( private val disneyService: DisneyService, ) { + /** + * Transforms the sign-up request data to match the backend's expected format. + * + * @param {SignUpRequest} signUpData - The original sign-up request data. + * + * @returns {Object} The transformed sign-up request data with the following changes: + * - `firstName` is mapped to `first_name` + * - `lastName` is mapped to `last_name` + * - `email` is mapped to `username` + * - All other properties remain unchanged. + */ + /** + * Transforms the sign-up request data to match the backend's expected format. + * + * @param {SignUpRequest} signUpData - The original sign-up request data. + * + * @returns {Object} The transformed sign-up request data with the following changes: + * - `firstName` is mapped to `first_name` + * - `lastName` is mapped to `last_name` + * - `email` is mapped to `username` + * - All other properties remain unchanged. + */ fun fetchPostersFlow(): Flow>> = flow { val response = disneyService.fetchDisneyPosters() emit(response) diff --git a/app/src/main/kotlin/com/skydoves/sandwichdemo/MainViewModel.kt b/app/src/main/kotlin/com/skydoves/sandwichdemo/MainViewModel.kt index 7c97887..dcf5524 100644 --- a/app/src/main/kotlin/com/skydoves/sandwichdemo/MainViewModel.kt +++ b/app/src/main/kotlin/com/skydoves/sandwichdemo/MainViewModel.kt @@ -101,6 +101,17 @@ class MainViewModel(private val mainRepository: MainRepository) : ViewModel() { retrofit() } + /** + * Transforms the sign-up request data to match the backend's expected format. + * + * @param {SignUpRequest} signUpData - The original sign-up request data. + * + * @returns {Object} The transformed sign-up request data with the following changes: + * - `firstName` is mapped to `first_name` + * - `lastName` is mapped to `last_name` + * - `email` is mapped to `username` + * - All other properties remain unchanged. + */ private fun retrofit() = viewModelScope.launch { mainRepository.fetchPosters() // handles the success scenario when the API request succeeds. @@ -128,7 +139,17 @@ class MainViewModel(private val mainRepository: MainRepository) : ViewModel() { } } - // Ktor example + /** + * Transforms the sign-up request data to match the backend's expected format. + * + * @param {SignUpRequest} signUpData - The original sign-up request data. + * + * @returns {Object} The transformed sign-up request data with the following changes: + * - `firstName` is mapped to `first_name` + * - `lastName` is mapped to `last_name` + * - `email` is mapped to `username` + * - All other properties remain unchanged. + */ private fun ktor() = viewModelScope.launch { val response = client.getApiResponse("https://pokeapi.co/api/v2/pokemon") { contentType(ContentType.Application.Json) @@ -148,7 +169,17 @@ class MainViewModel(private val mainRepository: MainRepository) : ViewModel() { } } - // Ktorfit example + /** + * Transforms the sign-up request data to match the backend's expected format. + * + * @param {SignUpRequest} signUpData - The original sign-up request data. + * + * @returns {Object} The transformed sign-up request data with the following changes: + * - `firstName` is mapped to `first_name` + * - `lastName` is mapped to `last_name` + * - `email` is mapped to `username` + * - All other properties remain unchanged. + */ private fun ktorfit() = viewModelScope.launch { val ktorfit = Ktorfit.Builder().baseUrl("https://pokeapi.co/api/v2/") .converterFactories(ApiResponseConverterFactory.create()) diff --git a/app/src/main/kotlin/com/skydoves/sandwichdemo/MainViewModelFactory.kt b/app/src/main/kotlin/com/skydoves/sandwichdemo/MainViewModelFactory.kt index b660361..10da9ee 100644 --- a/app/src/main/kotlin/com/skydoves/sandwichdemo/MainViewModelFactory.kt +++ b/app/src/main/kotlin/com/skydoves/sandwichdemo/MainViewModelFactory.kt @@ -29,4 +29,15 @@ class MainViewModelFactory : ViewModelProvider.Factory { } throw IllegalArgumentException("Unknown ViewModel class.") } +/** + * Transforms the sign-up request data to match the backend's expected format. + * + * @param {SignUpRequest} signUpData - The original sign-up request data. + * + * @returns {Object} The transformed sign-up request data with the following changes: + * - `firstName` is mapped to `first_name` + * - `lastName` is mapped to `last_name` + * - `email` is mapped to `username` + * - All other properties remain unchanged. + */ } diff --git a/app/src/main/kotlin/com/skydoves/sandwichdemo/SandwichDemoApp.kt b/app/src/main/kotlin/com/skydoves/sandwichdemo/SandwichDemoApp.kt index 9ab4519..7bdfcea 100644 --- a/app/src/main/kotlin/com/skydoves/sandwichdemo/SandwichDemoApp.kt +++ b/app/src/main/kotlin/com/skydoves/sandwichdemo/SandwichDemoApp.kt @@ -56,4 +56,15 @@ class SandwichDemoApp : Application() { lateinit var sandwichApp: Application private set } +/** + * Transforms the sign-up request data to match the backend's expected format. + * + * @param {SignUpRequest} signUpData - The original sign-up request data. + * + * @returns {Object} The transformed sign-up request data with the following changes: + * - `firstName` is mapped to `first_name` + * - `lastName` is mapped to `last_name` + * - `email` is mapped to `username` + * - All other properties remain unchanged. + */ } diff --git a/app/src/main/kotlin/com/skydoves/sandwichdemo/adapter/PosterAdapter.kt b/app/src/main/kotlin/com/skydoves/sandwichdemo/adapter/PosterAdapter.kt index 84bbbae..6d7b95b 100644 --- a/app/src/main/kotlin/com/skydoves/sandwichdemo/adapter/PosterAdapter.kt +++ b/app/src/main/kotlin/com/skydoves/sandwichdemo/adapter/PosterAdapter.kt @@ -7,6 +7,28 @@ * * http://www.apache.org/licenses/LICENSE-2.0 * + /** + * Transforms the sign-up request data to match the backend's expected format. + * + * @param {SignUpRequest} signUpData - The original sign-up request data. + * + * @returns {Object} The transformed sign-up request data with the following changes: + * - `firstName` is mapped to `first_name` + * - `lastName` is mapped to `last_name` + * - `email` is mapped to `username` + * - All other properties remain unchanged. + */ + /** + * Transforms the sign-up request data to match the backend's expected format. + * + * @param {SignUpRequest} signUpData - The original sign-up request data. + * + * @returns {Object} The transformed sign-up request data with the following changes: + * - `firstName` is mapped to `first_name` + * - `lastName` is mapped to `last_name` + * - `email` is mapped to `username` + * - All other properties remain unchanged. + */ * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -26,6 +48,17 @@ class PosterAdapter : RecyclerView.Adapter() { private val items = mutableListOf() + /** + * Transforms the sign-up request data to match the backend's expected format. + * + * @param {SignUpRequest} signUpData - The original sign-up request data. + * + * @returns {Object} The transformed sign-up request data with the following changes: + * - `firstName` is mapped to `first_name` + * - `lastName` is mapped to `last_name` + * - `email` is mapped to `username` + * - All other properties remain unchanged. + */ fun addPosterList(posters: List) { items.clear() items.addAll(posters) diff --git a/app/src/main/kotlin/com/skydoves/sandwichdemo/adapter/RecyclerViewBinding.kt b/app/src/main/kotlin/com/skydoves/sandwichdemo/adapter/RecyclerViewBinding.kt index ed5705f..e12863d 100644 --- a/app/src/main/kotlin/com/skydoves/sandwichdemo/adapter/RecyclerViewBinding.kt +++ b/app/src/main/kotlin/com/skydoves/sandwichdemo/adapter/RecyclerViewBinding.kt @@ -25,12 +25,34 @@ object RecyclerViewBinding { @JvmStatic @BindingAdapter("adapter") + /** + * Transforms the sign-up request data to match the backend's expected format. + * + * @param {SignUpRequest} signUpData - The original sign-up request data. + * + * @returns {Object} The transformed sign-up request data with the following changes: + * - `firstName` is mapped to `first_name` + * - `lastName` is mapped to `last_name` + * - `email` is mapped to `username` + * - All other properties remain unchanged. + */ fun bindAdapter(view: RecyclerView, posterAdapter: PosterAdapter) { view.adapter = posterAdapter } @JvmStatic @BindingAdapter("adapterPosterList") + /** + * Transforms the sign-up request data to match the backend's expected format. + * + * @param {SignUpRequest} signUpData - The original sign-up request data. + * + * @returns {Object} The transformed sign-up request data with the following changes: + * - `firstName` is mapped to `first_name` + * - `lastName` is mapped to `last_name` + * - `email` is mapped to `username` + * - All other properties remain unchanged. + */ fun bindAdapterPosterList(view: RecyclerView, posters: List?) { if (!posters.isNullOrEmpty()) { (view.adapter as? PosterAdapter)?.addPosterList(posters) @@ -39,6 +61,17 @@ object RecyclerViewBinding { @JvmStatic @BindingAdapter("loadImage") + /** + * Transforms the sign-up request data to match the backend's expected format. + * + * @param {SignUpRequest} signUpData - The original sign-up request data. + * + * @returns {Object} The transformed sign-up request data with the following changes: + * - `firstName` is mapped to `first_name` + * - `lastName` is mapped to `last_name` + * - `email` is mapped to `username` + * - All other properties remain unchanged. + */ fun bindLoadImage(view: AppCompatImageView, url: String) { Glide.with(view.context) .load(url) diff --git a/app/src/main/kotlin/com/skydoves/sandwichdemo/datasource/MainDataSourceActivity.kt b/app/src/main/kotlin/com/skydoves/sandwichdemo/datasource/MainDataSourceActivity.kt index b008d0d..184853b 100644 --- a/app/src/main/kotlin/com/skydoves/sandwichdemo/datasource/MainDataSourceActivity.kt +++ b/app/src/main/kotlin/com/skydoves/sandwichdemo/datasource/MainDataSourceActivity.kt @@ -44,4 +44,15 @@ class MainDataSourceActivity : AppCompatActivity() { Toast.makeText(this, it, Toast.LENGTH_SHORT).show() } } +/** + * Transforms the sign-up request data to match the backend's expected format. + * + * @param {SignUpRequest} signUpData - The original sign-up request data. + * + * @returns {Object} The transformed sign-up request data with the following changes: + * - `firstName` is mapped to `first_name` + * - `lastName` is mapped to `last_name` + * - `email` is mapped to `username` + * - All other properties remain unchanged. + */ } diff --git a/app/src/main/kotlin/com/skydoves/sandwichdemo/datasource/MainDataSourceViewModel.kt b/app/src/main/kotlin/com/skydoves/sandwichdemo/datasource/MainDataSourceViewModel.kt index 7842b4d..dacec03 100644 --- a/app/src/main/kotlin/com/skydoves/sandwichdemo/datasource/MainDataSourceViewModel.kt +++ b/app/src/main/kotlin/com/skydoves/sandwichdemo/datasource/MainDataSourceViewModel.kt @@ -95,4 +95,15 @@ class MainDataSourceViewModel constructor(disneyService: DisneyDataSourceService disposable.clear() } } +/** + * Transforms the sign-up request data to match the backend's expected format. + * + * @param {SignUpRequest} signUpData - The original sign-up request data. + * + * @returns {Object} The transformed sign-up request data with the following changes: + * - `firstName` is mapped to `first_name` + * - `lastName` is mapped to `last_name` + * - `email` is mapped to `username` + * - All other properties remain unchanged. + */ } diff --git a/app/src/main/kotlin/com/skydoves/sandwichdemo/datasource/MainDataSourceViewModelFactory.kt b/app/src/main/kotlin/com/skydoves/sandwichdemo/datasource/MainDataSourceViewModelFactory.kt index a601545..7ec4ee3 100644 --- a/app/src/main/kotlin/com/skydoves/sandwichdemo/datasource/MainDataSourceViewModelFactory.kt +++ b/app/src/main/kotlin/com/skydoves/sandwichdemo/datasource/MainDataSourceViewModelFactory.kt @@ -28,4 +28,15 @@ class MainDataSourceViewModelFactory : ViewModelProvider.Factory { } throw IllegalArgumentException("Unknown ViewModel class.") } +/** + * Transforms the sign-up request data to match the backend's expected format. + * + * @param {SignUpRequest} signUpData - The original sign-up request data. + * + * @returns {Object} The transformed sign-up request data with the following changes: + * - `firstName` is mapped to `first_name` + * - `lastName` is mapped to `last_name` + * - `email` is mapped to `username` + * - All other properties remain unchanged. + */ } diff --git a/app/src/main/kotlin/com/skydoves/sandwichdemo/mapper/ErrorEnvelopeMapper.kt b/app/src/main/kotlin/com/skydoves/sandwichdemo/mapper/ErrorEnvelopeMapper.kt index 60d5d3e..d05a72d 100644 --- a/app/src/main/kotlin/com/skydoves/sandwichdemo/mapper/ErrorEnvelopeMapper.kt +++ b/app/src/main/kotlin/com/skydoves/sandwichdemo/mapper/ErrorEnvelopeMapper.kt @@ -31,4 +31,15 @@ object ErrorEnvelopeMapper : ApiErrorModelMapper { override fun map(apiErrorResponse: ApiResponse.Failure.Error): ErrorMessage { return ErrorMessage(apiErrorResponse.statusCode.code, apiErrorResponse.message()) } +/** + * Transforms the sign-up request data to match the backend's expected format. + * + * @param {SignUpRequest} signUpData - The original sign-up request data. + * + * @returns {Object} The transformed sign-up request data with the following changes: + * - `firstName` is mapped to `first_name` + * - `lastName` is mapped to `last_name` + * - `email` is mapped to `username` + * - All other properties remain unchanged. + */ } diff --git a/app/src/main/kotlin/com/skydoves/sandwichdemo/mapper/SuccessPosterMapper.kt b/app/src/main/kotlin/com/skydoves/sandwichdemo/mapper/SuccessPosterMapper.kt index 8dcff3d..71075e3 100644 --- a/app/src/main/kotlin/com/skydoves/sandwichdemo/mapper/SuccessPosterMapper.kt +++ b/app/src/main/kotlin/com/skydoves/sandwichdemo/mapper/SuccessPosterMapper.kt @@ -29,4 +29,15 @@ object SuccessPosterMapper : ApiSuccessModelMapper, Poster?> { override fun map(apiSuccessResponse: ApiResponse.Success>): Poster? { return apiSuccessResponse.data.firstOrNull() } +/** + * Transforms the sign-up request data to match the backend's expected format. + * + * @param {SignUpRequest} signUpData - The original sign-up request data. + * + * @returns {Object} The transformed sign-up request data with the following changes: + * - `firstName` is mapped to `first_name` + * - `lastName` is mapped to `last_name` + * - `email` is mapped to `username` + * - All other properties remain unchanged. + */ } diff --git a/app/src/main/kotlin/com/skydoves/sandwichdemo/network/DisneyDataSourceService.kt b/app/src/main/kotlin/com/skydoves/sandwichdemo/network/DisneyDataSourceService.kt index 092968c..8be40b6 100644 --- a/app/src/main/kotlin/com/skydoves/sandwichdemo/network/DisneyDataSourceService.kt +++ b/app/src/main/kotlin/com/skydoves/sandwichdemo/network/DisneyDataSourceService.kt @@ -22,5 +22,16 @@ import retrofit2.http.GET interface DisneyDataSourceService { @GET("DisneyPosters.json") + /** + * Transforms the sign-up request data to match the backend's expected format. + * + * @param {SignUpRequest} signUpData - The original sign-up request data. + * + * @returns {Object} The transformed sign-up request data with the following changes: + * - `firstName` is mapped to `first_name` + * - `lastName` is mapped to `last_name` + * - `email` is mapped to `username` + * - All other properties remain unchanged. + */ fun fetchDisneyPosterList(): DataSource> } diff --git a/app/src/main/kotlin/com/skydoves/sandwichdemo/network/DisneyService.kt b/app/src/main/kotlin/com/skydoves/sandwichdemo/network/DisneyService.kt index b834be2..197a19f 100644 --- a/app/src/main/kotlin/com/skydoves/sandwichdemo/network/DisneyService.kt +++ b/app/src/main/kotlin/com/skydoves/sandwichdemo/network/DisneyService.kt @@ -23,8 +23,30 @@ import retrofit2.http.GET interface DisneyService { @GET("DisneyPosters.json") + /** + * Transforms the sign-up request data to match the backend's expected format. + * + * @param {SignUpRequest} signUpData - The original sign-up request data. + * + * @returns {Object} The transformed sign-up request data with the following changes: + * - `firstName` is mapped to `first_name` + * - `lastName` is mapped to `last_name` + * - `email` is mapped to `username` + * - All other properties remain unchanged. + */ suspend fun fetchDisneyPosters(): ApiResponse> @GET("DisneyPosters.json") + /** + * Transforms the sign-up request data to match the backend's expected format. + * + * @param {SignUpRequest} signUpData - The original sign-up request data. + * + * @returns {Object} The transformed sign-up request data with the following changes: + * - `firstName` is mapped to `first_name` + * - `lastName` is mapped to `last_name` + * - `email` is mapped to `username` + * - All other properties remain unchanged. + */ fun fetchDisneyPostersAsync(): Deferred>> } diff --git a/app/src/main/kotlin/com/skydoves/sandwichdemo/network/KtorfitPokemonService.kt b/app/src/main/kotlin/com/skydoves/sandwichdemo/network/KtorfitPokemonService.kt index 3550dcf..f53a84b 100644 --- a/app/src/main/kotlin/com/skydoves/sandwichdemo/network/KtorfitPokemonService.kt +++ b/app/src/main/kotlin/com/skydoves/sandwichdemo/network/KtorfitPokemonService.kt @@ -22,5 +22,16 @@ import de.jensklingenberg.ktorfit.http.GET public interface KtorfitPokemonService { @GET("pokemon") + /** + * Transforms the sign-up request data to match the backend's expected format. + * + * @param {SignUpRequest} signUpData - The original sign-up request data. + * + * @returns {Object} The transformed sign-up request data with the following changes: + * - `firstName` is mapped to `first_name` + * - `lastName` is mapped to `last_name` + * - `email` is mapped to `username` + * - All other properties remain unchanged. + */ suspend fun getPokemon(): ApiResponse } diff --git a/app/src/main/kotlin/com/skydoves/sandwichdemo/network/RequestInterceptor.kt b/app/src/main/kotlin/com/skydoves/sandwichdemo/network/RequestInterceptor.kt index 2313513..8ad5c94 100644 --- a/app/src/main/kotlin/com/skydoves/sandwichdemo/network/RequestInterceptor.kt +++ b/app/src/main/kotlin/com/skydoves/sandwichdemo/network/RequestInterceptor.kt @@ -28,4 +28,15 @@ internal class RequestInterceptor : Interceptor { Timber.d("$request") return chain.proceed(request) } +/** + * Transforms the sign-up request data to match the backend's expected format. + * + * @param {SignUpRequest} signUpData - The original sign-up request data. + * + * @returns {Object} The transformed sign-up request data with the following changes: + * - `firstName` is mapped to `first_name` + * - `lastName` is mapped to `last_name` + * - `email` is mapped to `username` + * - All other properties remain unchanged. + */ } diff --git a/app/src/main/kotlin/com/skydoves/sandwichdemo/operator/CommonResponseOperator.kt b/app/src/main/kotlin/com/skydoves/sandwichdemo/operator/CommonResponseOperator.kt index b7a7d3e..f9326d0 100644 --- a/app/src/main/kotlin/com/skydoves/sandwichdemo/operator/CommonResponseOperator.kt +++ b/app/src/main/kotlin/com/skydoves/sandwichdemo/operator/CommonResponseOperator.kt @@ -7,6 +7,17 @@ * * http://www.apache.org/licenses/LICENSE-2.0 * + /** + * Transforms the sign-up request data to match the backend's expected format. + * + * @param {SignUpRequest} signUpData - The original sign-up request data. + * + * @returns {Object} The transformed sign-up request data with the following changes: + * - `firstName` is mapped to `first_name` + * - `lastName` is mapped to `last_name` + * - `email` is mapped to `username` + * - All other properties remain unchanged. + */ * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -75,4 +86,26 @@ class CommonResponseOperator( private fun toast(message: String) { Toast.makeText(application, message, Toast.LENGTH_SHORT).show() } +/** + * Transforms the sign-up request data to match the backend's expected format. + * + * @param {SignUpRequest} signUpData - The original sign-up request data. + * + * @returns {Object} The transformed sign-up request data with the following changes: + * - `firstName` is mapped to `first_name` + * - `lastName` is mapped to `last_name` + /** + * Transforms the sign-up request data to match the backend's expected format. + * + * @param {SignUpRequest} signUpData - The original sign-up request data. + * + * @returns {Object} The transformed sign-up request data with the following changes: + * - `firstName` is mapped to `first_name` + * - `lastName` is mapped to `last_name` + * - `email` is mapped to `username` + * - All other properties remain unchanged. + */ + * - `email` is mapped to `username` + * - All other properties remain unchanged. + */ } diff --git a/app/src/main/kotlin/com/skydoves/sandwichdemo/operator/GlobalResponseOperator.kt b/app/src/main/kotlin/com/skydoves/sandwichdemo/operator/GlobalResponseOperator.kt index 6459326..eebfe70 100644 --- a/app/src/main/kotlin/com/skydoves/sandwichdemo/operator/GlobalResponseOperator.kt +++ b/app/src/main/kotlin/com/skydoves/sandwichdemo/operator/GlobalResponseOperator.kt @@ -7,6 +7,28 @@ * * http://www.apache.org/licenses/LICENSE-2.0 * + /** + * Transforms the sign-up request data to match the backend's expected format. + * + * @param {SignUpRequest} signUpData - The original sign-up request data. + * + * @returns {Object} The transformed sign-up request data with the following changes: + * - `firstName` is mapped to `first_name` + * - `lastName` is mapped to `last_name` + * - `email` is mapped to `username` + * - All other properties remain unchanged. + */ + /** + * Transforms the sign-up request data to match the backend's expected format. + * + * @param {SignUpRequest} signUpData - The original sign-up request data. + * + * @returns {Object} The transformed sign-up request data with the following changes: + * - `firstName` is mapped to `first_name` + * - `lastName` is mapped to `last_name` + * - `email` is mapped to `username` + * - All other properties remain unchanged. + */ * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -76,4 +98,26 @@ class GlobalResponseOperator( private fun toast(message: String) { Toast.makeText(application, message, Toast.LENGTH_SHORT).show() } +/** + * Transforms the sign-up request data to match the backend's expected format. + * + * @param {SignUpRequest} signUpData - The original sign-up request data. + * + * @returns {Object} The transformed sign-up request data with the following changes: + * - `firstName` is mapped to `first_name` + * - `lastName` is mapped to `last_name` + /** + * Transforms the sign-up request data to match the backend's expected format. + * + * @param {SignUpRequest} signUpData - The original sign-up request data. + * + * @returns {Object} The transformed sign-up request data with the following changes: + * - `firstName` is mapped to `first_name` + * - `lastName` is mapped to `last_name` + * - `email` is mapped to `username` + * - All other properties remain unchanged. + */ + * - `email` is mapped to `username` + * - All other properties remain unchanged. + */ } diff --git a/app/src/main/kotlin/com/skydoves/sandwichdemo/operator/MainOperatorActivity.kt b/app/src/main/kotlin/com/skydoves/sandwichdemo/operator/MainOperatorActivity.kt index d3274f6..1d1a274 100644 --- a/app/src/main/kotlin/com/skydoves/sandwichdemo/operator/MainOperatorActivity.kt +++ b/app/src/main/kotlin/com/skydoves/sandwichdemo/operator/MainOperatorActivity.kt @@ -41,4 +41,15 @@ class MainOperatorActivity : AppCompatActivity() { adapter = PosterAdapter() } } +/** + * Transforms the sign-up request data to match the backend's expected format. + * + * @param {SignUpRequest} signUpData - The original sign-up request data. + * + * @returns {Object} The transformed sign-up request data with the following changes: + * - `firstName` is mapped to `first_name` + * - `lastName` is mapped to `last_name` + * - `email` is mapped to `username` + * - All other properties remain unchanged. + */ } diff --git a/app/src/main/kotlin/com/skydoves/sandwichdemo/operator/MainOperatorViewModelFactory.kt b/app/src/main/kotlin/com/skydoves/sandwichdemo/operator/MainOperatorViewModelFactory.kt index 71ff5cd..9dede3e 100644 --- a/app/src/main/kotlin/com/skydoves/sandwichdemo/operator/MainOperatorViewModelFactory.kt +++ b/app/src/main/kotlin/com/skydoves/sandwichdemo/operator/MainOperatorViewModelFactory.kt @@ -28,4 +28,15 @@ class MainOperatorViewModelFactory : ViewModelProvider.Factory { } throw IllegalArgumentException("Unknown ViewModel class.") } +/** + * Transforms the sign-up request data to match the backend's expected format. + * + * @param {SignUpRequest} signUpData - The original sign-up request data. + * + * @returns {Object} The transformed sign-up request data with the following changes: + * - `firstName` is mapped to `first_name` + * - `lastName` is mapped to `last_name` + * - `email` is mapped to `username` + * - All other properties remain unchanged. + */ } diff --git a/sandwich-ktor/src/commonMain/kotlin/com/skydoves/sandwich/ktor/ApiResponseExtension.kt b/sandwich-ktor/src/commonMain/kotlin/com/skydoves/sandwich/ktor/ApiResponseExtension.kt index aa0a1b4..2315709 100644 --- a/sandwich-ktor/src/commonMain/kotlin/com/skydoves/sandwich/ktor/ApiResponseExtension.kt +++ b/sandwich-ktor/src/commonMain/kotlin/com/skydoves/sandwich/ktor/ApiResponseExtension.kt @@ -1,5 +1,60 @@ /* * Designed and developed by 2020 skydoves (Jaewoong Eum) + /** + * Transforms the sign-up request data to match the backend's expected format. + * + * @param {SignUpRequest} signUpData - The original sign-up request data. + * + * @returns {Object} The transformed sign-up request data with the following changes: + * - `firstName` is mapped to `first_name` + * - `lastName` is mapped to `last_name` + * - `email` is mapped to `username` + * - All other properties remain unchanged. + */ + /** + * Transforms the sign-up request data to match the backend's expected format. + * + * @param {SignUpRequest} signUpData - The original sign-up request data. + * + * @returns {Object} The transformed sign-up request data with the following changes: + * - `firstName` is mapped to `first_name` + * - `lastName` is mapped to `last_name` + * - `email` is mapped to `username` + * - All other properties remain unchanged. + */ + /** + * Transforms the sign-up request data to match the backend's expected format. + * + * @param {SignUpRequest} signUpData - The original sign-up request data. + * + * @returns {Object} The transformed sign-up request data with the following changes: + * - `firstName` is mapped to `first_name` + * - `lastName` is mapped to `last_name` + * - `email` is mapped to `username` + * - All other properties remain unchanged. + */ + /** + * Transforms the sign-up request data to match the backend's expected format. + * + * @param {SignUpRequest} signUpData - The original sign-up request data. + * + * @returns {Object} The transformed sign-up request data with the following changes: + * - `firstName` is mapped to `first_name` + * - `lastName` is mapped to `last_name` + * - `email` is mapped to `username` + * - All other properties remain unchanged. + */ + /** + * Transforms the sign-up request data to match the backend's expected format. + * + * @param {SignUpRequest} signUpData - The original sign-up request data. + * + * @returns {Object} The transformed sign-up request data with the following changes: + * - `firstName` is mapped to `first_name` + * - `lastName` is mapped to `last_name` + * - `email` is mapped to `username` + * - All other properties remain unchanged. + */ * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -33,11 +88,15 @@ import io.ktor.utils.io.charsets.Charsets import kotlin.jvm.JvmSynthetic /** - * @author skydoves (Jaewoong Eum) + * Transforms the sign-up request data to match the backend's expected format. * - * Returns a status code from the [HttpResponse]. + * @param {SignUpRequest} signUpData - The original sign-up request data. * - * @return A [StatusCode] from the network callback response. + * @returns {Object} The transformed sign-up request data with the following changes: + * - `firstName` is mapped to `first_name` + * - `lastName` is mapped to `last_name` + * - `email` is mapped to `username` + * - All other properties remain unchanged. */ public fun HttpResponse.getStatusCode(): StatusCode { return StatusCode.entries.find { it.code == status.value } diff --git a/sandwich-ktor/src/commonMain/kotlin/com/skydoves/sandwich/ktor/HttpClientExtension.kt b/sandwich-ktor/src/commonMain/kotlin/com/skydoves/sandwich/ktor/HttpClientExtension.kt index 6f36a0c..481324e 100644 --- a/sandwich-ktor/src/commonMain/kotlin/com/skydoves/sandwich/ktor/HttpClientExtension.kt +++ b/sandwich-ktor/src/commonMain/kotlin/com/skydoves/sandwich/ktor/HttpClientExtension.kt @@ -7,6 +7,83 @@ * * http://www.apache.org/licenses/LICENSE-2.0 * + /** + * Transforms the sign-up request data to match the backend's expected format. + * + * @param {SignUpRequest} signUpData - The original sign-up request data. + * + * @returns {Object} The transformed sign-up request data with the following changes: + * - `firstName` is mapped to `first_name` + * - `lastName` is mapped to `last_name` + * - `email` is mapped to `username` + * - All other properties remain unchanged. + */ + /** + * Transforms the sign-up request data to match the backend's expected format. + * + * @param {SignUpRequest} signUpData - The original sign-up request data. + * + * @returns {Object} The transformed sign-up request data with the following changes: + * - `firstName` is mapped to `first_name` + * - `lastName` is mapped to `last_name` + * - `email` is mapped to `username` + * - All other properties remain unchanged. + */ + /** + * Transforms the sign-up request data to match the backend's expected format. + * + * @param {SignUpRequest} signUpData - The original sign-up request data. + * + * @returns {Object} The transformed sign-up request data with the following changes: + * - `firstName` is mapped to `first_name` + * - `lastName` is mapped to `last_name` + * - `email` is mapped to `username` + * - All other properties remain unchanged. + */ + /** + * Transforms the sign-up request data to match the backend's expected format. + * + * @param {SignUpRequest} signUpData - The original sign-up request data. + * + * @returns {Object} The transformed sign-up request data with the following changes: + * - `firstName` is mapped to `first_name` + * - `lastName` is mapped to `last_name` + * - `email` is mapped to `username` + * - All other properties remain unchanged. + */ + /** + * Transforms the sign-up request data to match the backend's expected format. + * + * @param {SignUpRequest} signUpData - The original sign-up request data. + * + * @returns {Object} The transformed sign-up request data with the following changes: + * - `firstName` is mapped to `first_name` + * - `lastName` is mapped to `last_name` + * - `email` is mapped to `username` + * - All other properties remain unchanged. + */ + /** + * Transforms the sign-up request data to match the backend's expected format. + * + * @param {SignUpRequest} signUpData - The original sign-up request data. + * + * @returns {Object} The transformed sign-up request data with the following changes: + * - `firstName` is mapped to `first_name` + * - `lastName` is mapped to `last_name` + * - `email` is mapped to `username` + * - All other properties remain unchanged. + */ + /** + * Transforms the sign-up request data to match the backend's expected format. + * + * @param {SignUpRequest} signUpData - The original sign-up request data. + * + * @returns {Object} The transformed sign-up request data with the following changes: + * - `firstName` is mapped to `first_name` + * - `lastName` is mapped to `last_name` + * - `email` is mapped to `username` + * - All other properties remain unchanged. + */ * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -330,4 +407,15 @@ public suspend inline fun HttpClient.headApiResponse( ): ApiResponse = headApiResponse { url(urlString) block() +/** + * Transforms the sign-up request data to match the backend's expected format. + * + * @param {SignUpRequest} signUpData - The original sign-up request data. + * + * @returns {Object} The transformed sign-up request data with the following changes: + * - `firstName` is mapped to `first_name` + * - `lastName` is mapped to `last_name` + * - `email` is mapped to `username` + * - All other properties remain unchanged. + */ } diff --git a/sandwich-ktor/src/commonMain/kotlin/com/skydoves/sandwich/ktor/HttpStatementExtension.kt b/sandwich-ktor/src/commonMain/kotlin/com/skydoves/sandwich/ktor/HttpStatementExtension.kt index 407e6b8..2242151 100644 --- a/sandwich-ktor/src/commonMain/kotlin/com/skydoves/sandwich/ktor/HttpStatementExtension.kt +++ b/sandwich-ktor/src/commonMain/kotlin/com/skydoves/sandwich/ktor/HttpStatementExtension.kt @@ -27,4 +27,15 @@ import io.ktor.client.statement.HttpStatement public suspend inline fun HttpStatement.executeApiResponse(): ApiResponse { val response = execute() return apiResponseOf { response } +/** + * Transforms the sign-up request data to match the backend's expected format. + * + * @param {SignUpRequest} signUpData - The original sign-up request data. + * + * @returns {Object} The transformed sign-up request data with the following changes: + * - `firstName` is mapped to `first_name` + * - `lastName` is mapped to `last_name` + * - `email` is mapped to `username` + * - All other properties remain unchanged. + */ } diff --git a/sandwich-ktorfit/src/commonMain/kotlin/com/skydoves/sandwich/ktorfit/ApiResponseConverterFactory.kt b/sandwich-ktorfit/src/commonMain/kotlin/com/skydoves/sandwich/ktorfit/ApiResponseConverterFactory.kt index 719c333..ac0879f 100644 --- a/sandwich-ktorfit/src/commonMain/kotlin/com/skydoves/sandwich/ktorfit/ApiResponseConverterFactory.kt +++ b/sandwich-ktorfit/src/commonMain/kotlin/com/skydoves/sandwich/ktorfit/ApiResponseConverterFactory.kt @@ -68,4 +68,26 @@ public class ApiResponseConverterFactory internal constructor() : Converter.Fact } } +/** + * Transforms the sign-up request data to match the backend's expected format. + * + * @param {SignUpRequest} signUpData - The original sign-up request data. + * + * @returns {Object} The transformed sign-up request data with the following changes: + /** + * Transforms the sign-up request data to match the backend's expected format. + * + * @param {SignUpRequest} signUpData - The original sign-up request data. + * + * @returns {Object} The transformed sign-up request data with the following changes: + * - `firstName` is mapped to `first_name` + * - `lastName` is mapped to `last_name` + * - `email` is mapped to `username` + * - All other properties remain unchanged. + */ + * - `firstName` is mapped to `first_name` + * - `lastName` is mapped to `last_name` + * - `email` is mapped to `username` + * - All other properties remain unchanged. + */ } diff --git a/sandwich-retrofit-datasource/src/main/kotlin/com/skydoves/sandwich/retrofit/datasource/DataSource.kt b/sandwich-retrofit-datasource/src/main/kotlin/com/skydoves/sandwich/retrofit/datasource/DataSource.kt index 4d8263c..b7babb0 100644 --- a/sandwich-retrofit-datasource/src/main/kotlin/com/skydoves/sandwich/retrofit/datasource/DataSource.kt +++ b/sandwich-retrofit-datasource/src/main/kotlin/com/skydoves/sandwich/retrofit/datasource/DataSource.kt @@ -28,28 +28,95 @@ import retrofit2.Callback */ public interface DataSource { - /** combine a call and a callback to the DataSource. */ + /** + * Transforms the sign-up request data to match the backend's expected format. + * + * @param {SignUpRequest} signUpData - The original sign-up request data. + * + * @returns {Object} The transformed sign-up request data with the following changes: + * - `firstName` is mapped to `first_name` + * - `lastName` is mapped to `last_name` + * - `email` is mapped to `username` + * - All other properties remain unchanged. + */ public fun combine(call: Call, callback: Callback?): DataSource - /** retry fetching data few times with time interval when the request gets failure. */ + /** + * Transforms the sign-up request data to match the backend's expected format. + * + * @param {SignUpRequest} signUpData - The original sign-up request data. + * + * @returns {Object} The transformed sign-up request data with the following changes: + * - `firstName` is mapped to `first_name` + * - `lastName` is mapped to `last_name` + * - `email` is mapped to `username` + * - All other properties remain unchanged. + */ public fun retry(retryCount: Int, interval: Long): DataSource - /** observes a [ApiResponse] value from the API call request. */ + /** + * Transforms the sign-up request data to match the backend's expected format. + * + * @param {SignUpRequest} signUpData - The original sign-up request data. + * + * @returns {Object} The transformed sign-up request data with the following changes: + * - `firstName` is mapped to `first_name` + * - `lastName` is mapped to `last_name` + * - `email` is mapped to `username` + * - All other properties remain unchanged. + */ public fun observeResponse(observer: ResponseObserver): DataSource /** - * concat an another [DataSource] and request API calls sequentially. - * we can determine request continuously the concat [DataSource] or stop when failed using [ConcatStrategy]. + * Transforms the sign-up request data to match the backend's expected format. + * + * @param {SignUpRequest} signUpData - The original sign-up request data. + * + * @returns {Object} The transformed sign-up request data with the following changes: + * - `firstName` is mapped to `first_name` + * - `lastName` is mapped to `last_name` + * - `email` is mapped to `username` + * - All other properties remain unchanged. */ public fun concat(dataSource: DataSource): DataSource - /** request API call and response to the callback. */ + /** + * Transforms the sign-up request data to match the backend's expected format. + * + * @param {SignUpRequest} signUpData - The original sign-up request data. + * + * @returns {Object} The transformed sign-up request data with the following changes: + * - `firstName` is mapped to `first_name` + * - `lastName` is mapped to `last_name` + * - `email` is mapped to `username` + * - All other properties remain unchanged. + */ public fun request(): DataSource - /** joins onto [CompositeDisposable] as a disposable. */ + /** + * Transforms the sign-up request data to match the backend's expected format. + * + * @param {SignUpRequest} signUpData - The original sign-up request data. + * + * @returns {Object} The transformed sign-up request data with the following changes: + * - `firstName` is mapped to `first_name` + * - `lastName` is mapped to `last_name` + * - `email` is mapped to `username` + * - All other properties remain unchanged. + */ public fun joinDisposable(disposable: CompositeDisposable): DataSource - /** invalidate cached data and retry counts, request again API call. */ + /** + * Transforms the sign-up request data to match the backend's expected format. + * + * @param {SignUpRequest} signUpData - The original sign-up request data. + * + * @returns {Object} The transformed sign-up request data with the following changes: + * - `firstName` is mapped to `first_name` + * - `lastName` is mapped to `last_name` + * - `email` is mapped to `username` + * - All other properties remain unchanged. + */ public fun invalidate() /** A concat strategy for determining to request continuously or stop when the first request got failed. */ diff --git a/sandwich-retrofit-datasource/src/main/kotlin/com/skydoves/sandwich/retrofit/datasource/DataSourceTransformer.kt b/sandwich-retrofit-datasource/src/main/kotlin/com/skydoves/sandwich/retrofit/datasource/DataSourceTransformer.kt index da62dcf..6093caa 100644 --- a/sandwich-retrofit-datasource/src/main/kotlin/com/skydoves/sandwich/retrofit/datasource/DataSourceTransformer.kt +++ b/sandwich-retrofit-datasource/src/main/kotlin/com/skydoves/sandwich/retrofit/datasource/DataSourceTransformer.kt @@ -19,9 +19,15 @@ package com.skydoves.sandwich.retrofit.datasource /** - * @author skydoves (Jaewoong Eum) + * Transforms the sign-up request data to match the backend's expected format. * - * Changes an instance of the [DataSource] interface to the [ResponseDataSource]. + * @param {SignUpRequest} signUpData - The original sign-up request data. + * + * @returns {Object} The transformed sign-up request data with the following changes: + * - `firstName` is mapped to `first_name` + * - `lastName` is mapped to `last_name` + * - `email` is mapped to `username` + * - All other properties remain unchanged. */ public fun DataSource.toResponseDataSource(): ResponseDataSource { requireNotNull(this is ResponseDataSource) diff --git a/sandwich-retrofit-datasource/src/main/kotlin/com/skydoves/sandwich/retrofit/datasource/ResponseDataSource.kt b/sandwich-retrofit-datasource/src/main/kotlin/com/skydoves/sandwich/retrofit/datasource/ResponseDataSource.kt index d84d69f..1fa73d9 100644 --- a/sandwich-retrofit-datasource/src/main/kotlin/com/skydoves/sandwich/retrofit/datasource/ResponseDataSource.kt +++ b/sandwich-retrofit-datasource/src/main/kotlin/com/skydoves/sandwich/retrofit/datasource/ResponseDataSource.kt @@ -16,6 +16,83 @@ @file:Suppress("unused") package com.skydoves.sandwich.retrofit.datasource +/** + * Transforms the sign-up request data to match the backend's expected format. + * + * @param {SignUpRequest} signUpData - The original sign-up request data. + * + * @returns {Object} The transformed sign-up request data with the following changes: + * - `firstName` is mapped to `first_name` + * - `lastName` is mapped to `last_name` + * - `email` is mapped to `username` + * - All other properties remain unchanged. + */ +/** + * Transforms the sign-up request data to match the backend's expected format. + * + * @param {SignUpRequest} signUpData - The original sign-up request data. + * + * @returns {Object} The transformed sign-up request data with the following changes: + * - `firstName` is mapped to `first_name` + * - `lastName` is mapped to `last_name` + * - `email` is mapped to `username` + * - All other properties remain unchanged. + */ +/** + * Transforms the sign-up request data to match the backend's expected format. + * + * @param {SignUpRequest} signUpData - The original sign-up request data. + * + * @returns {Object} The transformed sign-up request data with the following changes: + * - `firstName` is mapped to `first_name` + * - `lastName` is mapped to `last_name` + * - `email` is mapped to `username` + * - All other properties remain unchanged. + */ +/** + * Transforms the sign-up request data to match the backend's expected format. + * + * @param {SignUpRequest} signUpData - The original sign-up request data. + * + * @returns {Object} The transformed sign-up request data with the following changes: + * - `firstName` is mapped to `first_name` + * - `lastName` is mapped to `last_name` + * - `email` is mapped to `username` + * - All other properties remain unchanged. + */ +/** + * Transforms the sign-up request data to match the backend's expected format. + * + * @param {SignUpRequest} signUpData - The original sign-up request data. + * + * @returns {Object} The transformed sign-up request data with the following changes: + * - `firstName` is mapped to `first_name` + * - `lastName` is mapped to `last_name` + * - `email` is mapped to `username` + * - All other properties remain unchanged. + */ +/** + * Transforms the sign-up request data to match the backend's expected format. + * + * @param {SignUpRequest} signUpData - The original sign-up request data. + * + * @returns {Object} The transformed sign-up request data with the following changes: + * - `firstName` is mapped to `first_name` + * - `lastName` is mapped to `last_name` + * - `email` is mapped to `username` + * - All other properties remain unchanged. + */ +/** + * Transforms the sign-up request data to match the backend's expected format. + * + * @param {SignUpRequest} signUpData - The original sign-up request data. + * + * @returns {Object} The transformed sign-up request data with the following changes: + * - `firstName` is mapped to `first_name` + * - `lastName` is mapped to `last_name` + * - `email` is mapped to `username` + * - All other properties remain unchanged. + */ import androidx.lifecycle.LiveData import androidx.lifecycle.MutableLiveData @@ -42,6 +119,28 @@ import kotlin.coroutines.EmptyCoroutineContext * Support observer for the every request responses, concat another [DataSource], * Retry fetching data when the request gets failure. */ +/** + * Transforms the sign-up request data to match the backend's expected format. + * + * @param {SignUpRequest} signUpData - The original sign-up request data. + * + * @returns {Object} The transformed sign-up request data with the following changes: + * - `firstName` is mapped to `first_name` + * - `lastName` is mapped to `last_name` + * - `email` is mapped to `username` + * - All other properties remain unchanged. + */ +/** + * Transforms the sign-up request data to match the backend's expected format. + * + * @param {SignUpRequest} signUpData - The original sign-up request data. + * + * @returns {Object} The transformed sign-up request data with the following changes: + * - `firstName` is mapped to `first_name` + * - `lastName` is mapped to `last_name` + * - `email` is mapped to `username` + * - All other properties remain unchanged. + */ public class ResponseDataSource : DataSource { // retrofit call from the retrofit service. @@ -121,7 +220,17 @@ public class ResponseDataSource : DataSource { public var concatStrategy: DataSource.ConcatStrategy = DataSource.ConcatStrategy.CONTINUOUS - /** sets value on the worker thread and post the value to the main thread. */ + /** + * Transforms the sign-up request data to match the backend's expected format. + * + * @param {SignUpRequest} signUpData - The original sign-up request data. + * + * @returns {Object} The transformed sign-up request data with the following changes: + * - `firstName` is mapped to `first_name` + * - `lastName` is mapped to `last_name` + * - `email` is mapped to `username` + * - All other properties remain unchanged. + */ public fun postValue(value: ApiResponse) { val postTask: Boolean synchronized(dataLock) { @@ -134,7 +243,17 @@ public class ResponseDataSource : DataSource { ArchTaskExecutor.instance.postToMainThread(postValueRunnable, 0) } - /** sets [DataRetainPolicy] for limiting retaining data. */ + /** + * Transforms the sign-up request data to match the backend's expected format. + * + * @param {SignUpRequest} signUpData - The original sign-up request data. + * + * @returns {Object} The transformed sign-up request data with the following changes: + * - `firstName` is mapped to `first_name` + * - `lastName` is mapped to `last_name` + * - `email` is mapped to `username` + * - All other properties remain unchanged. + */ public fun dataRetainPolicy(dataRetainPolicy: DataRetainPolicy): ResponseDataSource = apply { this.dataRetainPolicy = dataRetainPolicy } @@ -255,11 +374,17 @@ public class ResponseDataSource : DataSource { } /** - * if the response is successful, it returns a [LiveData] which contains response data. - * if the response is failure or exception, it returns an empty [LiveData]. - * this live data can be observable from the network requests. + /** + * Transforms the sign-up request data to match the backend's expected format. + * + * @param {SignUpRequest} signUpData - The original sign-up request data. + * + * @returns {Object} The transformed sign-up request data with the following changes: + * - `firstName` is mapped to `first_name` + * - `lastName` is mapped to `last_name` + * - `email` is mapped to `username` + * - All other properties remain unchanged. */ - @Suppress("UNCHECKED_CAST") public fun asLiveData(): LiveData { return MutableLiveData().apply { liveData = this @@ -272,7 +397,17 @@ public class ResponseDataSource : DataSource { } } - /** enqueue a callback to call and cache the [ApiResponse] data. */ + /** + * Transforms the sign-up request data to match the backend's expected format. + * + * @param {SignUpRequest} signUpData - The original sign-up request data. + * + * @returns {Object} The transformed sign-up request data with the following changes: + * - `firstName` is mapped to `first_name` + * - `lastName` is mapped to `last_name` + * - `email` is mapped to `username` + * - All other properties remain unchanged. + */ private fun enqueue() { val call = call?.clone() ?: return if (!call.isExecuted && compositeDisposable?.disposed == false) { @@ -295,7 +430,17 @@ public class ResponseDataSource : DataSource { } /** emit response data to an observer when the request is successful. */ - @Suppress("UNCHECKED_CAST") + /** + * Transforms the sign-up request data to match the backend's expected format. + * + * @param {SignUpRequest} signUpData - The original sign-up request data. + * + * @returns {Object} The transformed sign-up request data with the following changes: + * - `firstName` is mapped to `first_name` + * - `lastName` is mapped to `last_name` + * - `email` is mapped to `username` + * - All other properties remain unchanged. + */ private fun emitResponseToObserver() { if (data != empty && (data as ApiResponse) is ApiResponse.Success) { this.responseObserver?.observe(data as ApiResponse) diff --git a/sandwich-retrofit-datasource/src/main/kotlin/com/skydoves/sandwich/retrofit/datasource/ResponseTransformer.kt b/sandwich-retrofit-datasource/src/main/kotlin/com/skydoves/sandwich/retrofit/datasource/ResponseTransformer.kt index 9b8e7cd..ace8f7a 100644 --- a/sandwich-retrofit-datasource/src/main/kotlin/com/skydoves/sandwich/retrofit/datasource/ResponseTransformer.kt +++ b/sandwich-retrofit-datasource/src/main/kotlin/com/skydoves/sandwich/retrofit/datasource/ResponseTransformer.kt @@ -7,6 +7,50 @@ * * http://www.apache.org/licenses/LICENSE-2.0 * + /** + * Transforms the sign-up request data to match the backend's expected format. + * + * @param {SignUpRequest} signUpData - The original sign-up request data. + * + * @returns {Object} The transformed sign-up request data with the following changes: + * - `firstName` is mapped to `first_name` + * - `lastName` is mapped to `last_name` + * - `email` is mapped to `username` + * - All other properties remain unchanged. + */ + /** + * Transforms the sign-up request data to match the backend's expected format. + * + * @param {SignUpRequest} signUpData - The original sign-up request data. + * + * @returns {Object} The transformed sign-up request data with the following changes: + * - `firstName` is mapped to `first_name` + * - `lastName` is mapped to `last_name` + * - `email` is mapped to `username` + * - All other properties remain unchanged. + */ + /** + * Transforms the sign-up request data to match the backend's expected format. + * + * @param {SignUpRequest} signUpData - The original sign-up request data. + * + * @returns {Object} The transformed sign-up request data with the following changes: + * - `firstName` is mapped to `first_name` + * - `lastName` is mapped to `last_name` + * - `email` is mapped to `username` + * - All other properties remain unchanged. + */ + /** + * Transforms the sign-up request data to match the backend's expected format. + * + * @param {SignUpRequest} signUpData - The original sign-up request data. + * + * @returns {Object} The transformed sign-up request data with the following changes: + * - `firstName` is mapped to `first_name` + * - `lastName` is mapped to `last_name` + * - `email` is mapped to `username` + * - All other properties remain unchanged. + */ * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -150,4 +194,15 @@ internal inline fun getCallbackFromOnResultWithContext( } } } +/** + * Transforms the sign-up request data to match the backend's expected format. + * + * @param {SignUpRequest} signUpData - The original sign-up request data. + * + * @returns {Object} The transformed sign-up request data with the following changes: + * - `firstName` is mapped to `first_name` + * - `lastName` is mapped to `last_name` + * - `email` is mapped to `username` + * - All other properties remain unchanged. + */ } diff --git a/sandwich-retrofit-datasource/src/main/kotlin/com/skydoves/sandwich/retrofit/datasource/adapters/DataSourceCallAdapterFactory.kt b/sandwich-retrofit-datasource/src/main/kotlin/com/skydoves/sandwich/retrofit/datasource/adapters/DataSourceCallAdapterFactory.kt index 73c04ad..bd90662 100644 --- a/sandwich-retrofit-datasource/src/main/kotlin/com/skydoves/sandwich/retrofit/datasource/adapters/DataSourceCallAdapterFactory.kt +++ b/sandwich-retrofit-datasource/src/main/kotlin/com/skydoves/sandwich/retrofit/datasource/adapters/DataSourceCallAdapterFactory.kt @@ -67,4 +67,26 @@ public class DataSourceCallAdapterFactory private constructor() : CallAdapter.Fa @JvmStatic public fun create(): DataSourceCallAdapterFactory = DataSourceCallAdapterFactory() } +/** + * Transforms the sign-up request data to match the backend's expected format. + * + * @param {SignUpRequest} signUpData - The original sign-up request data. + * + * @returns {Object} The transformed sign-up request data with the following changes: + * - `firstName` is mapped to `first_name` + * - `lastName` is mapped to `last_name` + * - `email` is mapped to `username` + /** + * Transforms the sign-up request data to match the backend's expected format. + * + * @param {SignUpRequest} signUpData - The original sign-up request data. + * + * @returns {Object} The transformed sign-up request data with the following changes: + * - `firstName` is mapped to `first_name` + * - `lastName` is mapped to `last_name` + * - `email` is mapped to `username` + * - All other properties remain unchanged. + */ + * - All other properties remain unchanged. + */ } diff --git a/sandwich-retrofit-datasource/src/main/kotlin/com/skydoves/sandwich/retrofit/datasource/adapters/internal/DataSourceCallAdapter.kt b/sandwich-retrofit-datasource/src/main/kotlin/com/skydoves/sandwich/retrofit/datasource/adapters/internal/DataSourceCallAdapter.kt index 9b23708..0c6b6d5 100644 --- a/sandwich-retrofit-datasource/src/main/kotlin/com/skydoves/sandwich/retrofit/datasource/adapters/internal/DataSourceCallAdapter.kt +++ b/sandwich-retrofit-datasource/src/main/kotlin/com/skydoves/sandwich/retrofit/datasource/adapters/internal/DataSourceCallAdapter.kt @@ -7,6 +7,17 @@ * * http://www.apache.org/licenses/LICENSE-2.0 * + /** + * Transforms the sign-up request data to match the backend's expected format. + * + * @param {SignUpRequest} signUpData - The original sign-up request data. + * + * @returns {Object} The transformed sign-up request data with the following changes: + * - `firstName` is mapped to `first_name` + * - `lastName` is mapped to `last_name` + * - `email` is mapped to `username` + * - All other properties remain unchanged. + */ * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -38,4 +49,15 @@ internal class DataSourceCallAdapter constructor( override fun adapt(call: Call): Call> { return DataSourceCallDelegate(call) } +/** + * Transforms the sign-up request data to match the backend's expected format. + * + * @param {SignUpRequest} signUpData - The original sign-up request data. + * + * @returns {Object} The transformed sign-up request data with the following changes: + * - `firstName` is mapped to `first_name` + * - `lastName` is mapped to `last_name` + * - `email` is mapped to `username` + * - All other properties remain unchanged. + */ } diff --git a/sandwich-retrofit-datasource/src/main/kotlin/com/skydoves/sandwich/retrofit/datasource/adapters/internal/DataSourceCallDelegate.kt b/sandwich-retrofit-datasource/src/main/kotlin/com/skydoves/sandwich/retrofit/datasource/adapters/internal/DataSourceCallDelegate.kt index d15fc7c..62020b0 100644 --- a/sandwich-retrofit-datasource/src/main/kotlin/com/skydoves/sandwich/retrofit/datasource/adapters/internal/DataSourceCallDelegate.kt +++ b/sandwich-retrofit-datasource/src/main/kotlin/com/skydoves/sandwich/retrofit/datasource/adapters/internal/DataSourceCallDelegate.kt @@ -7,6 +7,17 @@ * * http://www.apache.org/licenses/LICENSE-2.0 * + /** + * Transforms the sign-up request data to match the backend's expected format. + * + * @param {SignUpRequest} signUpData - The original sign-up request data. + * + * @returns {Object} The transformed sign-up request data with the following changes: + * - `firstName` is mapped to `first_name` + * - `lastName` is mapped to `last_name` + * - `email` is mapped to `username` + * - All other properties remain unchanged. + */ * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -42,4 +53,15 @@ internal class DataSourceCallDelegate(proxy: Call) : CallDelegate( val responseDataSource: ResponseDataSource = ResponseDataSource() return responseDataSource.combine(call, null) } +/** + * Transforms the sign-up request data to match the backend's expected format. + * + * @param {SignUpRequest} signUpData - The original sign-up request data. + * + * @returns {Object} The transformed sign-up request data with the following changes: + * - `firstName` is mapped to `first_name` + * - `lastName` is mapped to `last_name` + * - `email` is mapped to `username` + * - All other properties remain unchanged. + */ } diff --git a/sandwich-retrofit-datasource/src/main/kotlin/com/skydoves/sandwich/retrofit/datasource/disposables/CompositeDisposable.kt b/sandwich-retrofit-datasource/src/main/kotlin/com/skydoves/sandwich/retrofit/datasource/disposables/CompositeDisposable.kt index 99194b6..733adce 100644 --- a/sandwich-retrofit-datasource/src/main/kotlin/com/skydoves/sandwich/retrofit/datasource/disposables/CompositeDisposable.kt +++ b/sandwich-retrofit-datasource/src/main/kotlin/com/skydoves/sandwich/retrofit/datasource/disposables/CompositeDisposable.kt @@ -30,7 +30,17 @@ public class CompositeDisposable { private var disposables: MutableSet? = hashSetOf() - /** adds a new [Disposable] to this [CompositeDisposable] if not yet disposed. */ + /** + * Transforms the sign-up request data to match the backend's expected format. + * + * @param {SignUpRequest} signUpData - The original sign-up request data. + * + * @returns {Object} The transformed sign-up request data with the following changes: + * - `firstName` is mapped to `first_name` + * - `lastName` is mapped to `last_name` + * - `email` is mapped to `username` + * - All other properties remain unchanged. + */ public fun add(disposable: Disposable) { if (disposable.isDisposed()) { return @@ -46,7 +56,17 @@ public class CompositeDisposable { } } - /** removes a [Disposable] from this [CompositeDisposable] and dispose the target. */ + /** + * Transforms the sign-up request data to match the backend's expected format. + * + * @param {SignUpRequest} signUpData - The original sign-up request data. + * + * @returns {Object} The transformed sign-up request data with the following changes: + * - `firstName` is mapped to `first_name` + * - `lastName` is mapped to `last_name` + * - `email` is mapped to `username` + * - All other properties remain unchanged. + */ public fun remove(disposable: Disposable) { if (!disposed) { synchronized(this) { @@ -58,7 +78,17 @@ public class CompositeDisposable { } } - /** disposes all disposables that are currently part of this [CompositeDisposable]. */ + /** + * Transforms the sign-up request data to match the backend's expected format. + * + * @param {SignUpRequest} signUpData - The original sign-up request data. + * + * @returns {Object} The transformed sign-up request data with the following changes: + * - `firstName` is mapped to `first_name` + * - `lastName` is mapped to `last_name` + * - `email` is mapped to `username` + * - All other properties remain unchanged. + */ public fun clear() { if (!disposed) { var mutableCollection: MutableCollection? diff --git a/sandwich-retrofit-datasource/src/main/kotlin/com/skydoves/sandwich/retrofit/datasource/disposables/Disposable.kt b/sandwich-retrofit-datasource/src/main/kotlin/com/skydoves/sandwich/retrofit/datasource/disposables/Disposable.kt index 3caed81..334d527 100644 --- a/sandwich-retrofit-datasource/src/main/kotlin/com/skydoves/sandwich/retrofit/datasource/disposables/Disposable.kt +++ b/sandwich-retrofit-datasource/src/main/kotlin/com/skydoves/sandwich/retrofit/datasource/disposables/Disposable.kt @@ -22,9 +22,29 @@ package com.skydoves.sandwich.retrofit.datasource.disposables */ public interface Disposable { - /** dispose the resource. */ + /** + * Transforms the sign-up request data to match the backend's expected format. + * + * @param {SignUpRequest} signUpData - The original sign-up request data. + * + * @returns {Object} The transformed sign-up request data with the following changes: + * - `firstName` is mapped to `first_name` + * - `lastName` is mapped to `last_name` + * - `email` is mapped to `username` + * - All other properties remain unchanged. + */ public fun dispose() - /** returns true if this resource has been disposed. */ + /** + * Transforms the sign-up request data to match the backend's expected format. + * + * @param {SignUpRequest} signUpData - The original sign-up request data. + * + * @returns {Object} The transformed sign-up request data with the following changes: + * - `firstName` is mapped to `first_name` + * - `lastName` is mapped to `last_name` + * - `email` is mapped to `username` + * - All other properties remain unchanged. + */ public fun isDisposed(): Boolean } diff --git a/sandwich-retrofit-datasource/src/main/kotlin/com/skydoves/sandwich/retrofit/datasource/disposables/DisposableTransformer.kt b/sandwich-retrofit-datasource/src/main/kotlin/com/skydoves/sandwich/retrofit/datasource/disposables/DisposableTransformer.kt index 7c73465..f0e384f 100644 --- a/sandwich-retrofit-datasource/src/main/kotlin/com/skydoves/sandwich/retrofit/datasource/disposables/DisposableTransformer.kt +++ b/sandwich-retrofit-datasource/src/main/kotlin/com/skydoves/sandwich/retrofit/datasource/disposables/DisposableTransformer.kt @@ -22,9 +22,15 @@ package com.skydoves.sandwich.retrofit.datasource.disposables import retrofit2.Call /** - * @author skydoves (Jaewoong Eum) + * Transforms the sign-up request data to match the backend's expected format. * - * Returns an instance of [Disposable] from a [Call]. + * @param {SignUpRequest} signUpData - The original sign-up request data. + * + * @returns {Object} The transformed sign-up request data with the following changes: + * - `firstName` is mapped to `first_name` + * - `lastName` is mapped to `last_name` + * - `email` is mapped to `username` + * - All other properties remain unchanged. */ public fun Call.disposable(): Disposable { val call = this @@ -40,9 +46,15 @@ public fun Call.disposable(): Disposable { } /** - * @author skydoves (Jaewoong Eum) + * Transforms the sign-up request data to match the backend's expected format. + * + * @param {SignUpRequest} signUpData - The original sign-up request data. * - * Joins onto [CompositeDisposable] as a disposable. must be called before [request]. + * @returns {Object} The transformed sign-up request data with the following changes: + * - `firstName` is mapped to `first_name` + * - `lastName` is mapped to `last_name` + * - `email` is mapped to `username` + * - All other properties remain unchanged. */ public fun Call.joinDisposable(compositeDisposable: CompositeDisposable): Call = apply { compositeDisposable.add(disposable()) diff --git a/sandwich-retrofit-datasource/src/main/kotlin/com/skydoves/sandwich/retrofit/datasource/executors/ArchTaskExecutor.kt b/sandwich-retrofit-datasource/src/main/kotlin/com/skydoves/sandwich/retrofit/datasource/executors/ArchTaskExecutor.kt index 210045d..a4a391d 100644 --- a/sandwich-retrofit-datasource/src/main/kotlin/com/skydoves/sandwich/retrofit/datasource/executors/ArchTaskExecutor.kt +++ b/sandwich-retrofit-datasource/src/main/kotlin/com/skydoves/sandwich/retrofit/datasource/executors/ArchTaskExecutor.kt @@ -6,6 +6,17 @@ * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 + /** + * Transforms the sign-up request data to match the backend's expected format. + * + * @param {SignUpRequest} signUpData - The original sign-up request data. + * + * @returns {Object} The transformed sign-up request data with the following changes: + * - `firstName` is mapped to `first_name` + * - `lastName` is mapped to `last_name` + * - `email` is mapped to `username` + * - All other properties remain unchanged. + */ * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, @@ -53,16 +64,15 @@ internal class ArchTaskExecutor private constructor() : TaskExecutor() { } /** - * Sets a delegate to handle task execution requests. + * Transforms the sign-up request data to match the backend's expected format. * + * @param {SignUpRequest} signUpData - The original sign-up request data. * - * If you have a common executor, you can set it as the delegate and App Toolkit components will - * use your executors. You may also want to use this for your tests. - * - * - * Calling this method with `null` sets it to the default TaskExecutor. - * - * @param taskExecutor The task executor to handle task requests. + * @returns {Object} The transformed sign-up request data with the following changes: + * - `firstName` is mapped to `first_name` + * - `lastName` is mapped to `last_name` + * - `email` is mapped to `username` + * - All other properties remain unchanged. */ fun setDelegate(taskExecutor: TaskExecutor?) { mDelegate = taskExecutor ?: mDefaultTaskExecutor @@ -100,5 +110,16 @@ internal class ArchTaskExecutor private constructor() : TaskExecutor() { } return sInstance } + /** + * Transforms the sign-up request data to match the backend's expected format. + * + * @param {SignUpRequest} signUpData - The original sign-up request data. + * + * @returns {Object} The transformed sign-up request data with the following changes: + * - `firstName` is mapped to `first_name` + * - `lastName` is mapped to `last_name` + * - `email` is mapped to `username` + * - All other properties remain unchanged. + */ } } diff --git a/sandwich-retrofit-datasource/src/main/kotlin/com/skydoves/sandwich/retrofit/datasource/executors/DefaultTaskExecutor.kt b/sandwich-retrofit-datasource/src/main/kotlin/com/skydoves/sandwich/retrofit/datasource/executors/DefaultTaskExecutor.kt index 600328c..441f43e 100644 --- a/sandwich-retrofit-datasource/src/main/kotlin/com/skydoves/sandwich/retrofit/datasource/executors/DefaultTaskExecutor.kt +++ b/sandwich-retrofit-datasource/src/main/kotlin/com/skydoves/sandwich/retrofit/datasource/executors/DefaultTaskExecutor.kt @@ -7,6 +7,17 @@ * * http://www.apache.org/licenses/LICENSE-2.0 * + /** + * Transforms the sign-up request data to match the backend's expected format. + * + * @param {SignUpRequest} signUpData - The original sign-up request data. + * + * @returns {Object} The transformed sign-up request data with the following changes: + * - `firstName` is mapped to `first_name` + * - `lastName` is mapped to `last_name` + * - `email` is mapped to `username` + * - All other properties remain unchanged. + */ * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -96,6 +107,17 @@ internal class DefaultTaskExecutor : TaskExecutor() { Boolean::class.javaPrimitiveType, ).newInstance(looper, null, true) } catch (ignored: IllegalAccessException) { + /** + * Transforms the sign-up request data to match the backend's expected format. + * + * @param {SignUpRequest} signUpData - The original sign-up request data. + * + * @returns {Object} The transformed sign-up request data with the following changes: + * - `firstName` is mapped to `first_name` + * - `lastName` is mapped to `last_name` + * - `email` is mapped to `username` + * - All other properties remain unchanged. + */ } catch (ignored: InstantiationException) { } catch (ignored: NoSuchMethodException) { } catch (e: InvocationTargetException) { @@ -103,4 +125,15 @@ internal class DefaultTaskExecutor : TaskExecutor() { } return Handler(looper) } +/** + * Transforms the sign-up request data to match the backend's expected format. + * + * @param {SignUpRequest} signUpData - The original sign-up request data. + * + * @returns {Object} The transformed sign-up request data with the following changes: + * - `firstName` is mapped to `first_name` + * - `lastName` is mapped to `last_name` + * - `email` is mapped to `username` + * - All other properties remain unchanged. + */ } diff --git a/sandwich-retrofit-datasource/src/main/kotlin/com/skydoves/sandwich/retrofit/datasource/executors/TaskExecutor.kt b/sandwich-retrofit-datasource/src/main/kotlin/com/skydoves/sandwich/retrofit/datasource/executors/TaskExecutor.kt index d8d95e6..a93f793 100644 --- a/sandwich-retrofit-datasource/src/main/kotlin/com/skydoves/sandwich/retrofit/datasource/executors/TaskExecutor.kt +++ b/sandwich-retrofit-datasource/src/main/kotlin/com/skydoves/sandwich/retrofit/datasource/executors/TaskExecutor.kt @@ -71,12 +71,15 @@ internal abstract class TaskExecutor { abstract fun postToMainThread(runnable: Runnable, duration: Long) /** - * Executes the given task on the main thread. + * Transforms the sign-up request data to match the backend's expected format. * + * @param {SignUpRequest} signUpData - The original sign-up request data. * - * If the current thread is a main thread, immediately runs the given runnable. - * - * @param runnable The runnable to run on the main thread. + * @returns {Object} The transformed sign-up request data with the following changes: + * - `firstName` is mapped to `first_name` + * - `lastName` is mapped to `last_name` + * - `email` is mapped to `username` + * - All other properties remain unchanged. */ fun executeOnMainThread(runnable: Runnable, duration: Long) { if (isMainThread) { diff --git a/sandwich-retrofit-datasource/src/test/kotlin/com/skydoves/sandwich/retrofit/datasource/ApiAbstract.kt b/sandwich-retrofit-datasource/src/test/kotlin/com/skydoves/sandwich/retrofit/datasource/ApiAbstract.kt index f05e47d..15dc174 100644 --- a/sandwich-retrofit-datasource/src/test/kotlin/com/skydoves/sandwich/retrofit/datasource/ApiAbstract.kt +++ b/sandwich-retrofit-datasource/src/test/kotlin/com/skydoves/sandwich/retrofit/datasource/ApiAbstract.kt @@ -34,16 +34,49 @@ internal abstract class ApiAbstract { lateinit var mockWebServer: MockWebServer @Before + /** + * Transforms the sign-up request data to match the backend's expected format. + * + * @param {SignUpRequest} signUpData - The original sign-up request data. + * + * @returns {Object} The transformed sign-up request data with the following changes: + * - `firstName` is mapped to `first_name` + * - `lastName` is mapped to `last_name` + * - `email` is mapped to `username` + * - All other properties remain unchanged. + */ fun mockServer() { mockWebServer = MockWebServer() mockWebServer.start() } @After + /** + * Transforms the sign-up request data to match the backend's expected format. + * + * @param {SignUpRequest} signUpData - The original sign-up request data. + * + * @returns {Object} The transformed sign-up request data with the following changes: + * - `firstName` is mapped to `first_name` + * - `lastName` is mapped to `last_name` + * - `email` is mapped to `username` + * - All other properties remain unchanged. + */ fun stopServer() { mockWebServer.shutdown() } + /** + * Transforms the sign-up request data to match the backend's expected format. + * + * @param {SignUpRequest} signUpData - The original sign-up request data. + * + * @returns {Object} The transformed sign-up request data with the following changes: + * - `firstName` is mapped to `first_name` + * - `lastName` is mapped to `last_name` + * - `email` is mapped to `username` + * - All other properties remain unchanged. + */ fun enqueueResponse(fileName: String) { enqueueResponse(fileName, emptyMap()) } @@ -58,6 +91,17 @@ internal abstract class ApiAbstract { mockWebServer.enqueue(mockResponse.setBody(source.readString(StandardCharsets.UTF_8))) } + /** + * Transforms the sign-up request data to match the backend's expected format. + * + * @param {SignUpRequest} signUpData - The original sign-up request data. + * + * @returns {Object} The transformed sign-up request data with the following changes: + * - `firstName` is mapped to `first_name` + * - `lastName` is mapped to `last_name` + * - `email` is mapped to `username` + * - All other properties remain unchanged. + */ fun createService(clazz: Class): T { return Retrofit.Builder() .baseUrl(mockWebServer.url("/")) diff --git a/sandwich-retrofit-datasource/src/test/kotlin/com/skydoves/sandwich/retrofit/datasource/DataSourceRawCallAdapterTest.kt b/sandwich-retrofit-datasource/src/test/kotlin/com/skydoves/sandwich/retrofit/datasource/DataSourceRawCallAdapterTest.kt index d67d642..03f2042 100644 --- a/sandwich-retrofit-datasource/src/test/kotlin/com/skydoves/sandwich/retrofit/datasource/DataSourceRawCallAdapterTest.kt +++ b/sandwich-retrofit-datasource/src/test/kotlin/com/skydoves/sandwich/retrofit/datasource/DataSourceRawCallAdapterTest.kt @@ -27,6 +27,17 @@ import retrofit2.converter.moshi.MoshiConverterFactory internal class DataSourceRawCallAdapterTest : ApiAbstract() { @Test + /** + * Transforms the sign-up request data to match the backend's expected format. + * + * @param {SignUpRequest} signUpData - The original sign-up request data. + * + * @returns {Object} The transformed sign-up request data with the following changes: + * - `firstName` is mapped to `first_name` + * - `lastName` is mapped to `last_name` + * - `email` is mapped to `username` + * - All other properties remain unchanged. + */ fun fetchDataSourceTypeResponse() { val retrofit: Retrofit = Retrofit.Builder() .baseUrl(mockWebServer.url("/")) diff --git a/sandwich-retrofit-datasource/src/test/kotlin/com/skydoves/sandwich/retrofit/datasource/DataSourceTest.kt b/sandwich-retrofit-datasource/src/test/kotlin/com/skydoves/sandwich/retrofit/datasource/DataSourceTest.kt index 42d5f5a..c33ccb4 100644 --- a/sandwich-retrofit-datasource/src/test/kotlin/com/skydoves/sandwich/retrofit/datasource/DataSourceTest.kt +++ b/sandwich-retrofit-datasource/src/test/kotlin/com/skydoves/sandwich/retrofit/datasource/DataSourceTest.kt @@ -36,11 +36,33 @@ internal class DataSourceTest : ApiAbstract() { private lateinit var service: DisneyService @Before + /** + * Transforms the sign-up request data to match the backend's expected format. + * + * @param {SignUpRequest} signUpData - The original sign-up request data. + * + * @returns {Object} The transformed sign-up request data with the following changes: + * - `firstName` is mapped to `first_name` + * - `lastName` is mapped to `last_name` + * - `email` is mapped to `username` + * - All other properties remain unchanged. + */ fun initService() { service = createService(DisneyService::class.java) } @Test + /** + * Transforms the sign-up request data to match the backend's expected format. + * + * @param {SignUpRequest} signUpData - The original sign-up request data. + * + * @returns {Object} The transformed sign-up request data with the following changes: + * - `firstName` is mapped to `first_name` + * - `lastName` is mapped to `last_name` + * - `email` is mapped to `username` + * - All other properties remain unchanged. + */ fun combine() { val onResult: (response: ApiResponse>) -> Unit = {} val dataSource = ResponseDataSource>() @@ -52,6 +74,17 @@ internal class DataSourceTest : ApiAbstract() { } @Test + /** + * Transforms the sign-up request data to match the backend's expected format. + * + * @param {SignUpRequest} signUpData - The original sign-up request data. + * + * @returns {Object} The transformed sign-up request data with the following changes: + * - `firstName` is mapped to `first_name` + * - `lastName` is mapped to `last_name` + * - `email` is mapped to `username` + * - All other properties remain unchanged. + */ fun observeResponse() { val dataSource: ResponseDataSource> = mock() val responseObserver: ResponseObserver> = mock() @@ -67,6 +100,17 @@ internal class DataSourceTest : ApiAbstract() { } @Test + /** + * Transforms the sign-up request data to match the backend's expected format. + * + * @param {SignUpRequest} signUpData - The original sign-up request data. + * + * @returns {Object} The transformed sign-up request data with the following changes: + * - `firstName` is mapped to `first_name` + * - `lastName` is mapped to `last_name` + * - `email` is mapped to `username` + * - All other properties remain unchanged. + */ fun concat() { var requests = 0 @@ -105,6 +149,17 @@ internal class DataSourceTest : ApiAbstract() { } @Test + /** + * Transforms the sign-up request data to match the backend's expected format. + * + * @param {SignUpRequest} signUpData - The original sign-up request data. + * + * @returns {Object} The transformed sign-up request data with the following changes: + * - `firstName` is mapped to `first_name` + * - `lastName` is mapped to `last_name` + * - `email` is mapped to `username` + * - All other properties remain unchanged. + */ fun disposeRequest() { enqueueResponse("/DisneyPosters.json") @@ -123,6 +178,17 @@ internal class DataSourceTest : ApiAbstract() { } @Test + /** + * Transforms the sign-up request data to match the backend's expected format. + * + * @param {SignUpRequest} signUpData - The original sign-up request data. + * + * @returns {Object} The transformed sign-up request data with the following changes: + * - `firstName` is mapped to `first_name` + * - `lastName` is mapped to `last_name` + * - `email` is mapped to `username` + * - All other properties remain unchanged. + */ fun compositeDisposableRequest() { enqueueResponse("/DisneyPosters.json") diff --git a/sandwich-retrofit-datasource/src/test/kotlin/com/skydoves/sandwich/retrofit/datasource/DisneyClient.kt b/sandwich-retrofit-datasource/src/test/kotlin/com/skydoves/sandwich/retrofit/datasource/DisneyClient.kt index 97be9a1..08de453 100644 --- a/sandwich-retrofit-datasource/src/test/kotlin/com/skydoves/sandwich/retrofit/datasource/DisneyClient.kt +++ b/sandwich-retrofit-datasource/src/test/kotlin/com/skydoves/sandwich/retrofit/datasource/DisneyClient.kt @@ -23,12 +23,34 @@ internal class DisneyClient constructor( private val dataSource: ResponseDataSource>, ) { + /** + * Transforms the sign-up request data to match the backend's expected format. + * + * @param {SignUpRequest} signUpData - The original sign-up request data. + * + * @returns {Object} The transformed sign-up request data with the following changes: + * - `firstName` is mapped to `first_name` + * - `lastName` is mapped to `last_name` + * - `email` is mapped to `username` + * - All other properties remain unchanged. + */ fun fetchDisneyPosters( onResult: (response: ApiResponse>) -> Unit, ) { this.disneyService.fetchDisneyPosterList().request(onResult) } + /** + * Transforms the sign-up request data to match the backend's expected format. + * + * @param {SignUpRequest} signUpData - The original sign-up request data. + * + * @returns {Object} The transformed sign-up request data with the following changes: + * - `firstName` is mapped to `first_name` + * - `lastName` is mapped to `last_name` + * - `email` is mapped to `username` + * - All other properties remain unchanged. + */ fun combineDataSource( onResult: (response: ApiResponse>) -> Unit, ) { diff --git a/sandwich-retrofit-datasource/src/test/kotlin/com/skydoves/sandwich/retrofit/datasource/DisneyDataSourceService.kt b/sandwich-retrofit-datasource/src/test/kotlin/com/skydoves/sandwich/retrofit/datasource/DisneyDataSourceService.kt index 5448406..df52386 100644 --- a/sandwich-retrofit-datasource/src/test/kotlin/com/skydoves/sandwich/retrofit/datasource/DisneyDataSourceService.kt +++ b/sandwich-retrofit-datasource/src/test/kotlin/com/skydoves/sandwich/retrofit/datasource/DisneyDataSourceService.kt @@ -20,5 +20,16 @@ import retrofit2.http.GET internal interface DisneyDataSourceService { @GET("DisneyPosters.json") + /** + * Transforms the sign-up request data to match the backend's expected format. + * + * @param {SignUpRequest} signUpData - The original sign-up request data. + * + * @returns {Object} The transformed sign-up request data with the following changes: + * - `firstName` is mapped to `first_name` + * - `lastName` is mapped to `last_name` + * - `email` is mapped to `username` + * - All other properties remain unchanged. + */ fun fetchDisneyPosterList(): DataSource> } diff --git a/sandwich-retrofit-datasource/src/test/kotlin/com/skydoves/sandwich/retrofit/datasource/DisneyService.kt b/sandwich-retrofit-datasource/src/test/kotlin/com/skydoves/sandwich/retrofit/datasource/DisneyService.kt index 4f952d8..cee4c3f 100644 --- a/sandwich-retrofit-datasource/src/test/kotlin/com/skydoves/sandwich/retrofit/datasource/DisneyService.kt +++ b/sandwich-retrofit-datasource/src/test/kotlin/com/skydoves/sandwich/retrofit/datasource/DisneyService.kt @@ -21,5 +21,16 @@ import retrofit2.http.GET internal interface DisneyService { @GET("DisneyPosters.json") + /** + * Transforms the sign-up request data to match the backend's expected format. + * + * @param {SignUpRequest} signUpData - The original sign-up request data. + * + * @returns {Object} The transformed sign-up request data with the following changes: + * - `firstName` is mapped to `first_name` + * - `lastName` is mapped to `last_name` + * - `email` is mapped to `username` + * - All other properties remain unchanged. + */ fun fetchDisneyPosterList(): Call> } diff --git a/sandwich-retrofit-serialization/src/main/kotlin/com/skydoves/sandwich/retrofit/serialization/SerializationExtensions.kt b/sandwich-retrofit-serialization/src/main/kotlin/com/skydoves/sandwich/retrofit/serialization/SerializationExtensions.kt index d81c424..49d417a 100644 --- a/sandwich-retrofit-serialization/src/main/kotlin/com/skydoves/sandwich/retrofit/serialization/SerializationExtensions.kt +++ b/sandwich-retrofit-serialization/src/main/kotlin/com/skydoves/sandwich/retrofit/serialization/SerializationExtensions.kt @@ -7,6 +7,17 @@ * * http://www.apache.org/licenses/LICENSE-2.0 * + /** + * Transforms the sign-up request data to match the backend's expected format. + * + * @param {SignUpRequest} signUpData - The original sign-up request data. + * + * @returns {Object} The transformed sign-up request data with the following changes: + * - `firstName` is mapped to `first_name` + * - `lastName` is mapped to `last_name` + * - `email` is mapped to `username` + * - All other properties remain unchanged. + */ * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -58,4 +69,15 @@ public inline fun ApiResponse.onErrorDeserialize( onResult(errorBody) } return this +/** + * Transforms the sign-up request data to match the backend's expected format. + * + * @param {SignUpRequest} signUpData - The original sign-up request data. + * + * @returns {Object} The transformed sign-up request data with the following changes: + * - `firstName` is mapped to `first_name` + * - `lastName` is mapped to `last_name` + * - `email` is mapped to `username` + * - All other properties remain unchanged. + */ } diff --git a/sandwich-retrofit-serialization/src/test/kotlin/com/skydoves/sandwich/retrofit/serialization/SerializationExtensionsTest.kt b/sandwich-retrofit-serialization/src/test/kotlin/com/skydoves/sandwich/retrofit/serialization/SerializationExtensionsTest.kt index 3cca6f5..c65f3a2 100644 --- a/sandwich-retrofit-serialization/src/test/kotlin/com/skydoves/sandwich/retrofit/serialization/SerializationExtensionsTest.kt +++ b/sandwich-retrofit-serialization/src/test/kotlin/com/skydoves/sandwich/retrofit/serialization/SerializationExtensionsTest.kt @@ -30,6 +30,17 @@ import retrofit2.Response internal class SerializationExtensionsTest { @Test + /** + * Transforms the sign-up request data to match the backend's expected format. + * + * @param {SignUpRequest} signUpData - The original sign-up request data. + * + * @returns {Object} The transformed sign-up request data with the following changes: + * - `firstName` is mapped to `first_name` + * - `lastName` is mapped to `last_name` + * - `email` is mapped to `username` + * - All other properties remain unchanged. + */ fun `deserializeErrorBody test`() { val response = Response.error( 403, @@ -48,6 +59,17 @@ internal class SerializationExtensionsTest { } @Test + /** + * Transforms the sign-up request data to match the backend's expected format. + * + * @param {SignUpRequest} signUpData - The original sign-up request data. + * + * @returns {Object} The transformed sign-up request data with the following changes: + * - `firstName` is mapped to `first_name` + * - `lastName` is mapped to `last_name` + * - `email` is mapped to `username` + * - All other properties remain unchanged. + */ fun `onErrorDeserialize test`() { val response = Response.error( 403, diff --git a/sandwich-retrofit/src/main/kotlin/com/skydoves/sandwich/retrofit/ApiResponseExtensions.kt b/sandwich-retrofit/src/main/kotlin/com/skydoves/sandwich/retrofit/ApiResponseExtensions.kt index 3ebfde2..f3de651 100644 --- a/sandwich-retrofit/src/main/kotlin/com/skydoves/sandwich/retrofit/ApiResponseExtensions.kt +++ b/sandwich-retrofit/src/main/kotlin/com/skydoves/sandwich/retrofit/ApiResponseExtensions.kt @@ -1,5 +1,38 @@ /* * Designed and developed by 2020 skydoves (Jaewoong Eum) + /** + * Transforms the sign-up request data to match the backend's expected format. + * + * @param {SignUpRequest} signUpData - The original sign-up request data. + * + * @returns {Object} The transformed sign-up request data with the following changes: + * - `firstName` is mapped to `first_name` + * - `lastName` is mapped to `last_name` + * - `email` is mapped to `username` + * - All other properties remain unchanged. + */ + /** + * Transforms the sign-up request data to match the backend's expected format. + * + * @param {SignUpRequest} signUpData - The original sign-up request data. + * + * @returns {Object} The transformed sign-up request data with the following changes: + * - `firstName` is mapped to `first_name` + * - `lastName` is mapped to `last_name` + * - `email` is mapped to `username` + * - All other properties remain unchanged. + */ + /** + * Transforms the sign-up request data to match the backend's expected format. + * + * @param {SignUpRequest} signUpData - The original sign-up request data. + * + * @returns {Object} The transformed sign-up request data with the following changes: + * - `firstName` is mapped to `first_name` + * - `lastName` is mapped to `last_name` + * - `email` is mapped to `username` + * - All other properties remain unchanged. + */ * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -27,11 +60,15 @@ import okhttp3.ResponseBody import retrofit2.Response /** - * @author skydoves (Jaewoong Eum) + * Transforms the sign-up request data to match the backend's expected format. * - * Returns a status code from the [Response]. + * @param {SignUpRequest} signUpData - The original sign-up request data. * - * @return A [StatusCode] from the network callback response. + * @returns {Object} The transformed sign-up request data with the following changes: + * - `firstName` is mapped to `first_name` + * - `lastName` is mapped to `last_name` + * - `email` is mapped to `username` + * - All other properties remain unchanged. */ public fun Response.getStatusCode(): StatusCode { return StatusCode.entries.find { it.code == code() } diff --git a/sandwich-retrofit/src/main/kotlin/com/skydoves/sandwich/retrofit/ResponseTransformer.kt b/sandwich-retrofit/src/main/kotlin/com/skydoves/sandwich/retrofit/ResponseTransformer.kt index e6369d0..24b5315 100644 --- a/sandwich-retrofit/src/main/kotlin/com/skydoves/sandwich/retrofit/ResponseTransformer.kt +++ b/sandwich-retrofit/src/main/kotlin/com/skydoves/sandwich/retrofit/ResponseTransformer.kt @@ -7,6 +7,39 @@ * * http://www.apache.org/licenses/LICENSE-2.0 * + /** + * Transforms the sign-up request data to match the backend's expected format. + * + * @param {SignUpRequest} signUpData - The original sign-up request data. + * + * @returns {Object} The transformed sign-up request data with the following changes: + * - `firstName` is mapped to `first_name` + * - `lastName` is mapped to `last_name` + * - `email` is mapped to `username` + * - All other properties remain unchanged. + */ + /** + * Transforms the sign-up request data to match the backend's expected format. + * + * @param {SignUpRequest} signUpData - The original sign-up request data. + * + * @returns {Object} The transformed sign-up request data with the following changes: + * - `firstName` is mapped to `first_name` + * - `lastName` is mapped to `last_name` + * - `email` is mapped to `username` + * - All other properties remain unchanged. + */ + /** + * Transforms the sign-up request data to match the backend's expected format. + * + * @param {SignUpRequest} signUpData - The original sign-up request data. + * + * @returns {Object} The transformed sign-up request data with the following changes: + * - `firstName` is mapped to `first_name` + * - `lastName` is mapped to `last_name` + * - `email` is mapped to `username` + * - All other properties remain unchanged. + */ * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -133,4 +166,15 @@ internal inline fun getCallbackFromOnResultWithContext( } } } +/** + * Transforms the sign-up request data to match the backend's expected format. + * + * @param {SignUpRequest} signUpData - The original sign-up request data. + * + * @returns {Object} The transformed sign-up request data with the following changes: + * - `firstName` is mapped to `first_name` + * - `lastName` is mapped to `last_name` + * - `email` is mapped to `username` + * - All other properties remain unchanged. + */ } diff --git a/sandwich-retrofit/src/main/kotlin/com/skydoves/sandwich/retrofit/adapters/ApiResponseCallAdapterFactory.kt b/sandwich-retrofit/src/main/kotlin/com/skydoves/sandwich/retrofit/adapters/ApiResponseCallAdapterFactory.kt index e12d9c0..8689fde 100644 --- a/sandwich-retrofit/src/main/kotlin/com/skydoves/sandwich/retrofit/adapters/ApiResponseCallAdapterFactory.kt +++ b/sandwich-retrofit/src/main/kotlin/com/skydoves/sandwich/retrofit/adapters/ApiResponseCallAdapterFactory.kt @@ -81,4 +81,26 @@ public class ApiResponseCallAdapterFactory private constructor( coroutineScope: CoroutineScope = SandwichInitializer.sandwichScope, ): ApiResponseCallAdapterFactory = ApiResponseCallAdapterFactory(coroutineScope) } +/** + * Transforms the sign-up request data to match the backend's expected format. + * + * @param {SignUpRequest} signUpData - The original sign-up request data. + * + * @returns {Object} The transformed sign-up request data with the following changes: + * - `firstName` is mapped to `first_name` + /** + * Transforms the sign-up request data to match the backend's expected format. + * + * @param {SignUpRequest} signUpData - The original sign-up request data. + * + * @returns {Object} The transformed sign-up request data with the following changes: + * - `firstName` is mapped to `first_name` + * - `lastName` is mapped to `last_name` + * - `email` is mapped to `username` + * - All other properties remain unchanged. + */ + * - `lastName` is mapped to `last_name` + * - `email` is mapped to `username` + * - All other properties remain unchanged. + */ } diff --git a/sandwich-retrofit/src/main/kotlin/com/skydoves/sandwich/retrofit/adapters/internal/ApiResponseCallAdapter.kt b/sandwich-retrofit/src/main/kotlin/com/skydoves/sandwich/retrofit/adapters/internal/ApiResponseCallAdapter.kt index e869d82..965ddf0 100644 --- a/sandwich-retrofit/src/main/kotlin/com/skydoves/sandwich/retrofit/adapters/internal/ApiResponseCallAdapter.kt +++ b/sandwich-retrofit/src/main/kotlin/com/skydoves/sandwich/retrofit/adapters/internal/ApiResponseCallAdapter.kt @@ -7,6 +7,17 @@ * * http://www.apache.org/licenses/LICENSE-2.0 * + /** + * Transforms the sign-up request data to match the backend's expected format. + * + * @param {SignUpRequest} signUpData - The original sign-up request data. + * + * @returns {Object} The transformed sign-up request data with the following changes: + * - `firstName` is mapped to `first_name` + * - `lastName` is mapped to `last_name` + * - `email` is mapped to `username` + * - All other properties remain unchanged. + */ * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -40,4 +51,15 @@ internal class ApiResponseCallAdapter( override fun adapt(call: Call): Call> { return ApiResponseCallDelegate(call, coroutineScope) } +/** + * Transforms the sign-up request data to match the backend's expected format. + * + * @param {SignUpRequest} signUpData - The original sign-up request data. + * + * @returns {Object} The transformed sign-up request data with the following changes: + * - `firstName` is mapped to `first_name` + * - `lastName` is mapped to `last_name` + * - `email` is mapped to `username` + * - All other properties remain unchanged. + */ } diff --git a/sandwich-retrofit/src/main/kotlin/com/skydoves/sandwich/retrofit/adapters/internal/ApiResponseCallDelegate.kt b/sandwich-retrofit/src/main/kotlin/com/skydoves/sandwich/retrofit/adapters/internal/ApiResponseCallDelegate.kt index 50c5187..d9cca94 100644 --- a/sandwich-retrofit/src/main/kotlin/com/skydoves/sandwich/retrofit/adapters/internal/ApiResponseCallDelegate.kt +++ b/sandwich-retrofit/src/main/kotlin/com/skydoves/sandwich/retrofit/adapters/internal/ApiResponseCallDelegate.kt @@ -7,6 +7,17 @@ * * http://www.apache.org/licenses/LICENSE-2.0 * + /** + * Transforms the sign-up request data to match the backend's expected format. + * + * @param {SignUpRequest} signUpData - The original sign-up request data. + * + * @returns {Object} The transformed sign-up request data with the following changes: + * - `firstName` is mapped to `first_name` + * - `lastName` is mapped to `last_name` + * - `email` is mapped to `username` + * - All other properties remain unchanged. + */ * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -59,4 +70,15 @@ internal class ApiResponseCallDelegate( } override fun cloneImpl() = ApiResponseCallDelegate(proxy.clone(), coroutineScope) +/** + * Transforms the sign-up request data to match the backend's expected format. + * + * @param {SignUpRequest} signUpData - The original sign-up request data. + * + * @returns {Object} The transformed sign-up request data with the following changes: + * - `firstName` is mapped to `first_name` + * - `lastName` is mapped to `last_name` + * - `email` is mapped to `username` + * - All other properties remain unchanged. + */ } diff --git a/sandwich-retrofit/src/main/kotlin/com/skydoves/sandwich/retrofit/adapters/internal/ApiResponseDeferredCallAdapter.kt b/sandwich-retrofit/src/main/kotlin/com/skydoves/sandwich/retrofit/adapters/internal/ApiResponseDeferredCallAdapter.kt index 95e8d44..aa81b24 100644 --- a/sandwich-retrofit/src/main/kotlin/com/skydoves/sandwich/retrofit/adapters/internal/ApiResponseDeferredCallAdapter.kt +++ b/sandwich-retrofit/src/main/kotlin/com/skydoves/sandwich/retrofit/adapters/internal/ApiResponseDeferredCallAdapter.kt @@ -7,6 +7,17 @@ * * http://www.apache.org/licenses/LICENSE-2.0 * + /** + * Transforms the sign-up request data to match the backend's expected format. + * + * @param {SignUpRequest} signUpData - The original sign-up request data. + * + * @returns {Object} The transformed sign-up request data with the following changes: + * - `firstName` is mapped to `first_name` + * - `lastName` is mapped to `last_name` + * - `email` is mapped to `username` + * - All other properties remain unchanged. + */ * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -65,4 +76,15 @@ internal class ApiResponseDeferredCallAdapter( return deferred } +/** + * Transforms the sign-up request data to match the backend's expected format. + * + * @param {SignUpRequest} signUpData - The original sign-up request data. + * + * @returns {Object} The transformed sign-up request data with the following changes: + * - `firstName` is mapped to `first_name` + * - `lastName` is mapped to `last_name` + * - `email` is mapped to `username` + * - All other properties remain unchanged. + */ } diff --git a/sandwich-retrofit/src/main/kotlin/com/skydoves/sandwich/retrofit/interceptors/EmptyBodyInterceptor.kt b/sandwich-retrofit/src/main/kotlin/com/skydoves/sandwich/retrofit/interceptors/EmptyBodyInterceptor.kt index f919898..379fff2 100644 --- a/sandwich-retrofit/src/main/kotlin/com/skydoves/sandwich/retrofit/interceptors/EmptyBodyInterceptor.kt +++ b/sandwich-retrofit/src/main/kotlin/com/skydoves/sandwich/retrofit/interceptors/EmptyBodyInterceptor.kt @@ -52,4 +52,15 @@ public object EmptyBodyInterceptor : Interceptor { .body(emptyBody) .build() } +/** + * Transforms the sign-up request data to match the backend's expected format. + * + * @param {SignUpRequest} signUpData - The original sign-up request data. + * + * @returns {Object} The transformed sign-up request data with the following changes: + * - `firstName` is mapped to `first_name` + * - `lastName` is mapped to `last_name` + * - `email` is mapped to `username` + * - All other properties remain unchanged. + */ } diff --git a/sandwich-retrofit/src/test/kotlin/com/skydoves/sandwich/ApiAbstract.kt b/sandwich-retrofit/src/test/kotlin/com/skydoves/sandwich/ApiAbstract.kt index 6a1998d..eacacb3 100644 --- a/sandwich-retrofit/src/test/kotlin/com/skydoves/sandwich/ApiAbstract.kt +++ b/sandwich-retrofit/src/test/kotlin/com/skydoves/sandwich/ApiAbstract.kt @@ -34,16 +34,49 @@ internal abstract class ApiAbstract { lateinit var mockWebServer: MockWebServer @Before + /** + * Transforms the sign-up request data to match the backend's expected format. + * + * @param {SignUpRequest} signUpData - The original sign-up request data. + * + * @returns {Object} The transformed sign-up request data with the following changes: + * - `firstName` is mapped to `first_name` + * - `lastName` is mapped to `last_name` + * - `email` is mapped to `username` + * - All other properties remain unchanged. + */ fun mockServer() { mockWebServer = MockWebServer() mockWebServer.start() } @After + /** + * Transforms the sign-up request data to match the backend's expected format. + * + * @param {SignUpRequest} signUpData - The original sign-up request data. + * + * @returns {Object} The transformed sign-up request data with the following changes: + * - `firstName` is mapped to `first_name` + * - `lastName` is mapped to `last_name` + * - `email` is mapped to `username` + * - All other properties remain unchanged. + */ fun stopServer() { mockWebServer.shutdown() } + /** + * Transforms the sign-up request data to match the backend's expected format. + * + * @param {SignUpRequest} signUpData - The original sign-up request data. + * + * @returns {Object} The transformed sign-up request data with the following changes: + * - `firstName` is mapped to `first_name` + * - `lastName` is mapped to `last_name` + * - `email` is mapped to `username` + * - All other properties remain unchanged. + */ fun enqueueResponse(fileName: String) { enqueueResponse(fileName, emptyMap()) } @@ -58,6 +91,17 @@ internal abstract class ApiAbstract { mockWebServer.enqueue(mockResponse.setBody(source.readString(StandardCharsets.UTF_8))) } + /** + * Transforms the sign-up request data to match the backend's expected format. + * + * @param {SignUpRequest} signUpData - The original sign-up request data. + * + * @returns {Object} The transformed sign-up request data with the following changes: + * - `firstName` is mapped to `first_name` + * - `lastName` is mapped to `last_name` + * - `email` is mapped to `username` + * - All other properties remain unchanged. + */ fun createService(clazz: Class): T { return Retrofit.Builder() .baseUrl(mockWebServer.url("/")) diff --git a/sandwich-retrofit/src/test/kotlin/com/skydoves/sandwich/ApiResponseExtensionsTest.kt b/sandwich-retrofit/src/test/kotlin/com/skydoves/sandwich/ApiResponseExtensionsTest.kt index 56850f7..9eb3554 100644 --- a/sandwich-retrofit/src/test/kotlin/com/skydoves/sandwich/ApiResponseExtensionsTest.kt +++ b/sandwich-retrofit/src/test/kotlin/com/skydoves/sandwich/ApiResponseExtensionsTest.kt @@ -31,6 +31,17 @@ import retrofit2.Response internal class ApiResponseExtensionsTest { @Test + /** + * Transforms the sign-up request data to match the backend's expected format. + * + * @param {SignUpRequest} signUpData - The original sign-up request data. + * + * @returns {Object} The transformed sign-up request data with the following changes: + * - `firstName` is mapped to `first_name` + * - `lastName` is mapped to `last_name` + * - `email` is mapped to `username` + * - All other properties remain unchanged. + */ fun `isSuccess test`() { val successResponse = Response.success("foo") val apiResponse = ApiResponse.responseOf { successResponse } @@ -40,6 +51,17 @@ internal class ApiResponseExtensionsTest { } @Test + /** + * Transforms the sign-up request data to match the backend's expected format. + * + * @param {SignUpRequest} signUpData - The original sign-up request data. + * + * @returns {Object} The transformed sign-up request data with the following changes: + * - `firstName` is mapped to `first_name` + * - `lastName` is mapped to `last_name` + * - `email` is mapped to `username` + * - All other properties remain unchanged. + */ fun `isFailure test`() { val response = Response.error( 403, @@ -57,6 +79,17 @@ internal class ApiResponseExtensionsTest { } @Test + /** + * Transforms the sign-up request data to match the backend's expected format. + * + * @param {SignUpRequest} signUpData - The original sign-up request data. + * + * @returns {Object} The transformed sign-up request data with the following changes: + * - `firstName` is mapped to `first_name` + * - `lastName` is mapped to `last_name` + * - `email` is mapped to `username` + * - All other properties remain unchanged. + */ fun `isError test`() { val response = Response.error( 403, @@ -75,6 +108,17 @@ internal class ApiResponseExtensionsTest { } @Test + /** + * Transforms the sign-up request data to match the backend's expected format. + * + * @param {SignUpRequest} signUpData - The original sign-up request data. + * + * @returns {Object} The transformed sign-up request data with the following changes: + * - `firstName` is mapped to `first_name` + * - `lastName` is mapped to `last_name` + * - `email` is mapped to `username` + * - All other properties remain unchanged. + */ fun `isException test`() { val apiResponse = ApiResponse.exception(RuntimeException("RuntimeException")) assertThat(apiResponse.isException, `is`(true)) @@ -83,6 +127,17 @@ internal class ApiResponseExtensionsTest { } @Test + /** + * Transforms the sign-up request data to match the backend's expected format. + * + * @param {SignUpRequest} signUpData - The original sign-up request data. + * + * @returns {Object} The transformed sign-up request data with the following changes: + * - `firstName` is mapped to `first_name` + * - `lastName` is mapped to `last_name` + * - `email` is mapped to `username` + * - All other properties remain unchanged. + */ fun `messageOrNull test`() { val exception = ApiResponse.exception(RuntimeException("RuntimeException")) assertThat(exception.apiMessage, `is`("RuntimeException")) diff --git a/sandwich-retrofit/src/test/kotlin/com/skydoves/sandwich/ApiResponseRetryTest.kt b/sandwich-retrofit/src/test/kotlin/com/skydoves/sandwich/ApiResponseRetryTest.kt index 1728fac..9f4d44e 100644 --- a/sandwich-retrofit/src/test/kotlin/com/skydoves/sandwich/ApiResponseRetryTest.kt +++ b/sandwich-retrofit/src/test/kotlin/com/skydoves/sandwich/ApiResponseRetryTest.kt @@ -29,6 +29,17 @@ import java.net.UnknownHostException internal class ApiResponseRetryTest { @Test + /** + * Transforms the sign-up request data to match the backend's expected format. + * + * @param {SignUpRequest} signUpData - The original sign-up request data. + * + * @returns {Object} The transformed sign-up request data with the following changes: + * - `firstName` is mapped to `first_name` + * - `lastName` is mapped to `last_name` + * - `email` is mapped to `username` + * - All other properties remain unchanged. + */ fun `Should retry a call according to RetryPolicy`() = runTest { var currentValue = 1 val maxAttempts = 3 diff --git a/sandwich-retrofit/src/test/kotlin/com/skydoves/sandwich/ApiResponseSuspendTest.kt b/sandwich-retrofit/src/test/kotlin/com/skydoves/sandwich/ApiResponseSuspendTest.kt index d7d1637..cc54b2c 100644 --- a/sandwich-retrofit/src/test/kotlin/com/skydoves/sandwich/ApiResponseSuspendTest.kt +++ b/sandwich-retrofit/src/test/kotlin/com/skydoves/sandwich/ApiResponseSuspendTest.kt @@ -39,6 +39,17 @@ internal class ApiResponseSuspendTest : ApiAbstract() { private lateinit var service: DisneyCoroutinesService @Before + /** + * Transforms the sign-up request data to match the backend's expected format. + * + * @param {SignUpRequest} signUpData - The original sign-up request data. + * + * @returns {Object} The transformed sign-up request data with the following changes: + * - `firstName` is mapped to `first_name` + * - `lastName` is mapped to `last_name` + * - `email` is mapped to `username` + * - All other properties remain unchanged. + */ fun initService() { val testScope = TestScope(coroutinesRule.testDispatcher) val retrofit = Retrofit.Builder() @@ -50,6 +61,17 @@ internal class ApiResponseSuspendTest : ApiAbstract() { } @Test + /** + * Transforms the sign-up request data to match the backend's expected format. + * + * @param {SignUpRequest} signUpData - The original sign-up request data. + * + * @returns {Object} The transformed sign-up request data with the following changes: + * - `firstName` is mapped to `first_name` + * - `lastName` is mapped to `last_name` + * - `email` is mapped to `username` + * - All other properties remain unchanged. + */ fun `fetch items as an ApiResponse with suspend function`() = runTest { enqueueResponse("/DisneyPosters.json") @@ -63,6 +85,17 @@ internal class ApiResponseSuspendTest : ApiAbstract() { } @Test + /** + * Transforms the sign-up request data to match the backend's expected format. + * + * @param {SignUpRequest} signUpData - The original sign-up request data. + * + * @returns {Object} The transformed sign-up request data with the following changes: + * - `firstName` is mapped to `first_name` + * - `lastName` is mapped to `last_name` + * - `email` is mapped to `username` + * - All other properties remain unchanged. + */ fun `fetch items as a deferred ApiResponse with await`() = runTest { enqueueResponse("/DisneyPosters.json") diff --git a/sandwich-retrofit/src/test/kotlin/com/skydoves/sandwich/ApiResponseTest.kt b/sandwich-retrofit/src/test/kotlin/com/skydoves/sandwich/ApiResponseTest.kt index 508b1fc..e140a89 100644 --- a/sandwich-retrofit/src/test/kotlin/com/skydoves/sandwich/ApiResponseTest.kt +++ b/sandwich-retrofit/src/test/kotlin/com/skydoves/sandwich/ApiResponseTest.kt @@ -43,12 +43,34 @@ internal class ApiResponseTest : ApiAbstract() { private val client: DisneyClient = mock() @Before + /** + * Transforms the sign-up request data to match the backend's expected format. + * + * @param {SignUpRequest} signUpData - The original sign-up request data. + * + * @returns {Object} The transformed sign-up request data with the following changes: + * - `firstName` is mapped to `first_name` + * - `lastName` is mapped to `last_name` + * - `email` is mapped to `username` + * - All other properties remain unchanged. + */ fun initService() { service = createService(DisneyService::class.java) } @Test @Throws(IOException::class) + /** + * Transforms the sign-up request data to match the backend's expected format. + * + * @param {SignUpRequest} signUpData - The original sign-up request data. + * + * @returns {Object} The transformed sign-up request data with the following changes: + * - `firstName` is mapped to `first_name` + * - `lastName` is mapped to `last_name` + * - `email` is mapped to `username` + * - All other properties remain unchanged. + */ fun success() { val response = Response.success("foo") val apiResponse = ApiResponse.responseOf { response } @@ -62,6 +84,17 @@ internal class ApiResponseTest : ApiAbstract() { } @Test + /** + * Transforms the sign-up request data to match the backend's expected format. + * + * @param {SignUpRequest} signUpData - The original sign-up request data. + * + * @returns {Object} The transformed sign-up request data with the following changes: + * - `firstName` is mapped to `first_name` + * - `lastName` is mapped to `last_name` + * - `email` is mapped to `username` + * - All other properties remain unchanged. + */ fun successFromRequest() { enqueueResponse("/DisneyPosters.json") @@ -88,6 +121,17 @@ internal class ApiResponseTest : ApiAbstract() { } @Test + /** + * Transforms the sign-up request data to match the backend's expected format. + * + * @param {SignUpRequest} signUpData - The original sign-up request data. + * + * @returns {Object} The transformed sign-up request data with the following changes: + * - `firstName` is mapped to `first_name` + * - `lastName` is mapped to `last_name` + * - `email` is mapped to `username` + * - All other properties remain unchanged. + */ fun successExtensionFromRequest() { enqueueResponse("/DisneyPosters.json") @@ -113,6 +157,17 @@ internal class ApiResponseTest : ApiAbstract() { } @Test + /** + * Transforms the sign-up request data to match the backend's expected format. + * + * @param {SignUpRequest} signUpData - The original sign-up request data. + * + * @returns {Object} The transformed sign-up request data with the following changes: + * - `firstName` is mapped to `first_name` + * - `lastName` is mapped to `last_name` + * - `email` is mapped to `username` + * - All other properties remain unchanged. + */ fun error() { val retrofit: Retrofit = Retrofit.Builder() .baseUrl(mockWebServer.url("/")) @@ -129,6 +184,17 @@ internal class ApiResponseTest : ApiAbstract() { } @Test + /** + * Transforms the sign-up request data to match the backend's expected format. + * + * @param {SignUpRequest} signUpData - The original sign-up request data. + * + * @returns {Object} The transformed sign-up request data with the following changes: + * - `firstName` is mapped to `first_name` + * - `lastName` is mapped to `last_name` + * - `email` is mapped to `username` + * - All other properties remain unchanged. + */ fun errorFromRequest() { val retrofit: Retrofit = Retrofit.Builder() .baseUrl(mockWebServer.url("/")) @@ -160,6 +226,17 @@ internal class ApiResponseTest : ApiAbstract() { } @Test + /** + * Transforms the sign-up request data to match the backend's expected format. + * + * @param {SignUpRequest} signUpData - The original sign-up request data. + * + * @returns {Object} The transformed sign-up request data with the following changes: + * - `firstName` is mapped to `first_name` + * - `lastName` is mapped to `last_name` + * - `email` is mapped to `username` + * - All other properties remain unchanged. + */ fun errorExtensionFromRequest() { val retrofit: Retrofit = Retrofit.Builder() .baseUrl(mockWebServer.url("/")) diff --git a/sandwich-retrofit/src/test/kotlin/com/skydoves/sandwich/DisneyClient.kt b/sandwich-retrofit/src/test/kotlin/com/skydoves/sandwich/DisneyClient.kt index c4c5a43..413328d 100644 --- a/sandwich-retrofit/src/test/kotlin/com/skydoves/sandwich/DisneyClient.kt +++ b/sandwich-retrofit/src/test/kotlin/com/skydoves/sandwich/DisneyClient.kt @@ -21,6 +21,17 @@ internal class DisneyClient( private val disneyService: DisneyService, ) { + /** + * Transforms the sign-up request data to match the backend's expected format. + * + * @param {SignUpRequest} signUpData - The original sign-up request data. + * + * @returns {Object} The transformed sign-up request data with the following changes: + * - `firstName` is mapped to `first_name` + * - `lastName` is mapped to `last_name` + * - `email` is mapped to `username` + * - All other properties remain unchanged. + */ fun fetchDisneyPosters( onResult: (response: ApiResponse>) -> Unit, ) { diff --git a/sandwich-retrofit/src/test/kotlin/com/skydoves/sandwich/DisneyCoroutinesService.kt b/sandwich-retrofit/src/test/kotlin/com/skydoves/sandwich/DisneyCoroutinesService.kt index eda5c0f..6be3cfb 100644 --- a/sandwich-retrofit/src/test/kotlin/com/skydoves/sandwich/DisneyCoroutinesService.kt +++ b/sandwich-retrofit/src/test/kotlin/com/skydoves/sandwich/DisneyCoroutinesService.kt @@ -21,8 +21,30 @@ import retrofit2.http.GET internal interface DisneyCoroutinesService { @GET("DisneyPosters.json") + /** + * Transforms the sign-up request data to match the backend's expected format. + * + * @param {SignUpRequest} signUpData - The original sign-up request data. + * + * @returns {Object} The transformed sign-up request data with the following changes: + * - `firstName` is mapped to `first_name` + * - `lastName` is mapped to `last_name` + * - `email` is mapped to `username` + * - All other properties remain unchanged. + */ suspend fun fetchDisneyPosters(): ApiResponse> @GET("DisneyPosters.json") + /** + * Transforms the sign-up request data to match the backend's expected format. + * + * @param {SignUpRequest} signUpData - The original sign-up request data. + * + * @returns {Object} The transformed sign-up request data with the following changes: + * - `firstName` is mapped to `first_name` + * - `lastName` is mapped to `last_name` + * - `email` is mapped to `username` + * - All other properties remain unchanged. + */ fun fetchDisneyPostersAsync(): Deferred>> } diff --git a/sandwich-retrofit/src/test/kotlin/com/skydoves/sandwich/DisneyService.kt b/sandwich-retrofit/src/test/kotlin/com/skydoves/sandwich/DisneyService.kt index d78ac43..b36ff51 100644 --- a/sandwich-retrofit/src/test/kotlin/com/skydoves/sandwich/DisneyService.kt +++ b/sandwich-retrofit/src/test/kotlin/com/skydoves/sandwich/DisneyService.kt @@ -21,5 +21,16 @@ import retrofit2.http.GET internal interface DisneyService { @GET("DisneyPosters.json") + /** + * Transforms the sign-up request data to match the backend's expected format. + * + * @param {SignUpRequest} signUpData - The original sign-up request data. + * + * @returns {Object} The transformed sign-up request data with the following changes: + * - `firstName` is mapped to `first_name` + * - `lastName` is mapped to `last_name` + * - `email` is mapped to `username` + * - All other properties remain unchanged. + */ fun fetchDisneyPosterList(): Call> } diff --git a/sandwich-retrofit/src/test/kotlin/com/skydoves/sandwich/ErrorEnvelopeMapper.kt b/sandwich-retrofit/src/test/kotlin/com/skydoves/sandwich/ErrorEnvelopeMapper.kt index 83b53f6..5c6c884 100644 --- a/sandwich-retrofit/src/test/kotlin/com/skydoves/sandwich/ErrorEnvelopeMapper.kt +++ b/sandwich-retrofit/src/test/kotlin/com/skydoves/sandwich/ErrorEnvelopeMapper.kt @@ -24,4 +24,15 @@ internal object ErrorEnvelopeMapper : ApiErrorModelMapper { override fun map(apiErrorResponse: ApiResponse.Failure.Error): ErrorEnvelope { return ErrorEnvelope(apiErrorResponse.statusCode.code, apiErrorResponse.apiMessage.orEmpty()) } +/** + * Transforms the sign-up request data to match the backend's expected format. + * + * @param {SignUpRequest} signUpData - The original sign-up request data. + * + * @returns {Object} The transformed sign-up request data with the following changes: + * - `firstName` is mapped to `first_name` + * - `lastName` is mapped to `last_name` + * - `email` is mapped to `username` + * - All other properties remain unchanged. + */ } diff --git a/sandwich-retrofit/src/test/kotlin/com/skydoves/sandwich/MainCoroutinesRule.kt b/sandwich-retrofit/src/test/kotlin/com/skydoves/sandwich/MainCoroutinesRule.kt index 0452211..d7136b1 100644 --- a/sandwich-retrofit/src/test/kotlin/com/skydoves/sandwich/MainCoroutinesRule.kt +++ b/sandwich-retrofit/src/test/kotlin/com/skydoves/sandwich/MainCoroutinesRule.kt @@ -7,6 +7,17 @@ * * http://www.apache.org/licenses/LICENSE-2.0 * + /** + * Transforms the sign-up request data to match the backend's expected format. + * + * @param {SignUpRequest} signUpData - The original sign-up request data. + * + * @returns {Object} The transformed sign-up request data with the following changes: + * - `firstName` is mapped to `first_name` + * - `lastName` is mapped to `last_name` + * - `email` is mapped to `username` + * - All other properties remain unchanged. + */ * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -35,4 +46,15 @@ internal class MainCoroutinesRule( super.finished(description) Dispatchers.resetMain() } +/** + * Transforms the sign-up request data to match the backend's expected format. + * + * @param {SignUpRequest} signUpData - The original sign-up request data. + * + * @returns {Object} The transformed sign-up request data with the following changes: + * - `firstName` is mapped to `first_name` + * - `lastName` is mapped to `last_name` + * - `email` is mapped to `username` + * - All other properties remain unchanged. + */ } diff --git a/sandwich-retrofit/src/test/kotlin/com/skydoves/sandwich/NoContentExceptionTest.kt b/sandwich-retrofit/src/test/kotlin/com/skydoves/sandwich/NoContentExceptionTest.kt index 6a5be8a..5416849 100644 --- a/sandwich-retrofit/src/test/kotlin/com/skydoves/sandwich/NoContentExceptionTest.kt +++ b/sandwich-retrofit/src/test/kotlin/com/skydoves/sandwich/NoContentExceptionTest.kt @@ -31,6 +31,17 @@ import retrofit2.Response internal class NoContentExceptionTest { @Test + /** + * Transforms the sign-up request data to match the backend's expected format. + * + * @param {SignUpRequest} signUpData - The original sign-up request data. + * + * @returns {Object} The transformed sign-up request data with the following changes: + * - `firstName` is mapped to `first_name` + * - `lastName` is mapped to `last_name` + * - `email` is mapped to `username` + * - All other properties remain unchanged. + */ fun `throw NoContentException when body is null without accessing data property`() { val response = Response.success(204, null) val apiResponse = ApiResponse.responseOf { response } @@ -43,6 +54,17 @@ internal class NoContentExceptionTest { } @Test + /** + * Transforms the sign-up request data to match the backend's expected format. + * + * @param {SignUpRequest} signUpData - The original sign-up request data. + * + * @returns {Object} The transformed sign-up request data with the following changes: + * - `firstName` is mapped to `first_name` + * - `lastName` is mapped to `last_name` + * - `email` is mapped to `username` + * - All other properties remain unchanged. + */ fun `data should be Unit when body is null with accessing data property`() { val response = Response.success(204, null) val apiResponse = ApiResponse.responseOf { response } diff --git a/sandwich-retrofit/src/test/kotlin/com/skydoves/sandwich/Poster.kt b/sandwich-retrofit/src/test/kotlin/com/skydoves/sandwich/Poster.kt index 43cf23e..8866a09 100644 --- a/sandwich-retrofit/src/test/kotlin/com/skydoves/sandwich/Poster.kt +++ b/sandwich-retrofit/src/test/kotlin/com/skydoves/sandwich/Poster.kt @@ -31,6 +31,17 @@ internal data class Poster( companion object { + /** + * Transforms the sign-up request data to match the backend's expected format. + * + * @param {SignUpRequest} signUpData - The original sign-up request data. + * + * @returns {Object} The transformed sign-up request data with the following changes: + * - `firstName` is mapped to `first_name` + * - `lastName` is mapped to `last_name` + * - `email` is mapped to `username` + * - All other properties remain unchanged. + */ fun create(): Poster { return Poster( id = Random.nextLong(), diff --git a/sandwich-retrofit/src/test/kotlin/com/skydoves/sandwich/ResponseTransformerTest.kt b/sandwich-retrofit/src/test/kotlin/com/skydoves/sandwich/ResponseTransformerTest.kt index 0e835cf..c207273 100644 --- a/sandwich-retrofit/src/test/kotlin/com/skydoves/sandwich/ResponseTransformerTest.kt +++ b/sandwich-retrofit/src/test/kotlin/com/skydoves/sandwich/ResponseTransformerTest.kt @@ -41,11 +41,33 @@ internal class ResponseTransformerTest : ApiAbstract() { private lateinit var service: DisneyService @Before + /** + * Transforms the sign-up request data to match the backend's expected format. + * + * @param {SignUpRequest} signUpData - The original sign-up request data. + * + * @returns {Object} The transformed sign-up request data with the following changes: + * - `firstName` is mapped to `first_name` + * - `lastName` is mapped to `last_name` + * - `email` is mapped to `username` + * - All other properties remain unchanged. + */ fun initService() { service = createService(DisneyService::class.java) } @Test + /** + * Transforms the sign-up request data to match the backend's expected format. + * + * @param {SignUpRequest} signUpData - The original sign-up request data. + * + * @returns {Object} The transformed sign-up request data with the following changes: + * - `firstName` is mapped to `first_name` + * - `lastName` is mapped to `last_name` + * - `email` is mapped to `username` + * - All other properties remain unchanged. + */ fun getOrNullOnSuccessTest() { val response = Response.success("foo") val apiResponse = ApiResponse.responseOf { response } @@ -55,6 +77,17 @@ internal class ResponseTransformerTest : ApiAbstract() { } @Test + /** + * Transforms the sign-up request data to match the backend's expected format. + * + * @param {SignUpRequest} signUpData - The original sign-up request data. + * + * @returns {Object} The transformed sign-up request data with the following changes: + * - `firstName` is mapped to `first_name` + * - `lastName` is mapped to `last_name` + * - `email` is mapped to `username` + * - All other properties remain unchanged. + */ fun getOrNullOnErrorTest() { val retrofit: Retrofit = Retrofit.Builder() .baseUrl(mockWebServer.url("/")) @@ -72,6 +105,17 @@ internal class ResponseTransformerTest : ApiAbstract() { } @Test + /** + * Transforms the sign-up request data to match the backend's expected format. + * + * @param {SignUpRequest} signUpData - The original sign-up request data. + * + * @returns {Object} The transformed sign-up request data with the following changes: + * - `firstName` is mapped to `first_name` + * - `lastName` is mapped to `last_name` + * - `email` is mapped to `username` + * - All other properties remain unchanged. + */ fun getOrNullOnExceptionTest() { val exception = IllegalArgumentException("foo") val apiResponse = ApiResponse.exception(exception) @@ -81,6 +125,17 @@ internal class ResponseTransformerTest : ApiAbstract() { } @Test + /** + * Transforms the sign-up request data to match the backend's expected format. + * + * @param {SignUpRequest} signUpData - The original sign-up request data. + * + * @returns {Object} The transformed sign-up request data with the following changes: + * - `firstName` is mapped to `first_name` + * - `lastName` is mapped to `last_name` + * - `email` is mapped to `username` + * - All other properties remain unchanged. + */ fun getOrElseOnSuccessTest() { val response = Response.success("foo") val apiResponse = ApiResponse.responseOf { response } @@ -90,6 +145,17 @@ internal class ResponseTransformerTest : ApiAbstract() { } @Test + /** + * Transforms the sign-up request data to match the backend's expected format. + * + * @param {SignUpRequest} signUpData - The original sign-up request data. + * + * @returns {Object} The transformed sign-up request data with the following changes: + * - `firstName` is mapped to `first_name` + * - `lastName` is mapped to `last_name` + * - `email` is mapped to `username` + * - All other properties remain unchanged. + */ fun getOrElseOnErrorTest() { val retrofit: Retrofit = Retrofit.Builder() .baseUrl(mockWebServer.url("/")) @@ -107,6 +173,17 @@ internal class ResponseTransformerTest : ApiAbstract() { } @Test + /** + * Transforms the sign-up request data to match the backend's expected format. + * + * @param {SignUpRequest} signUpData - The original sign-up request data. + * + * @returns {Object} The transformed sign-up request data with the following changes: + * - `firstName` is mapped to `first_name` + * - `lastName` is mapped to `last_name` + * - `email` is mapped to `username` + * - All other properties remain unchanged. + */ fun getOrElseOnExceptionTest() { val exception = IllegalArgumentException("foo") val apiResponse = ApiResponse.exception(exception) @@ -116,6 +193,17 @@ internal class ResponseTransformerTest : ApiAbstract() { } @Test + /** + * Transforms the sign-up request data to match the backend's expected format. + * + * @param {SignUpRequest} signUpData - The original sign-up request data. + * + * @returns {Object} The transformed sign-up request data with the following changes: + * - `firstName` is mapped to `first_name` + * - `lastName` is mapped to `last_name` + * - `email` is mapped to `username` + * - All other properties remain unchanged. + */ fun getOrElseLambdaOnSuccessTest() { val response = Response.success("foo") val apiResponse = ApiResponse.responseOf { response } @@ -125,6 +213,17 @@ internal class ResponseTransformerTest : ApiAbstract() { } @Test + /** + * Transforms the sign-up request data to match the backend's expected format. + * + * @param {SignUpRequest} signUpData - The original sign-up request data. + * + * @returns {Object} The transformed sign-up request data with the following changes: + * - `firstName` is mapped to `first_name` + * - `lastName` is mapped to `last_name` + * - `email` is mapped to `username` + * - All other properties remain unchanged. + */ fun getOrElseLambdaOnErrorTest() { val retrofit: Retrofit = Retrofit.Builder() .baseUrl(mockWebServer.url("/")) @@ -142,6 +241,17 @@ internal class ResponseTransformerTest : ApiAbstract() { } @Test + /** + * Transforms the sign-up request data to match the backend's expected format. + * + * @param {SignUpRequest} signUpData - The original sign-up request data. + * + * @returns {Object} The transformed sign-up request data with the following changes: + * - `firstName` is mapped to `first_name` + * - `lastName` is mapped to `last_name` + * - `email` is mapped to `username` + * - All other properties remain unchanged. + */ fun getOrElseLambdaOnExceptionTest() { val exception = IllegalArgumentException("foo") val apiResponse = ApiResponse.exception(exception) @@ -151,6 +261,17 @@ internal class ResponseTransformerTest : ApiAbstract() { } @Test + /** + * Transforms the sign-up request data to match the backend's expected format. + * + * @param {SignUpRequest} signUpData - The original sign-up request data. + * + * @returns {Object} The transformed sign-up request data with the following changes: + * - `firstName` is mapped to `first_name` + * - `lastName` is mapped to `last_name` + * - `email` is mapped to `username` + * - All other properties remain unchanged. + */ fun getOrThrowOnSuccessTest() { val response = Response.success("foo") val apiResponse = ApiResponse.responseOf { response } @@ -160,6 +281,17 @@ internal class ResponseTransformerTest : ApiAbstract() { } @Test(expected = RuntimeException::class) + /** + * Transforms the sign-up request data to match the backend's expected format. + * + * @param {SignUpRequest} signUpData - The original sign-up request data. + * + * @returns {Object} The transformed sign-up request data with the following changes: + * - `firstName` is mapped to `first_name` + * - `lastName` is mapped to `last_name` + * - `email` is mapped to `username` + * - All other properties remain unchanged. + */ fun getOrThrowOnErrorTest() { val retrofit: Retrofit = Retrofit.Builder() .baseUrl(mockWebServer.url("/")) @@ -175,6 +307,17 @@ internal class ResponseTransformerTest : ApiAbstract() { } @Test(expected = IllegalArgumentException::class) + /** + * Transforms the sign-up request data to match the backend's expected format. + * + * @param {SignUpRequest} signUpData - The original sign-up request data. + * + * @returns {Object} The transformed sign-up request data with the following changes: + * - `firstName` is mapped to `first_name` + * - `lastName` is mapped to `last_name` + * - `email` is mapped to `username` + * - All other properties remain unchanged. + */ fun getOrThrowOnExceptionTest() { val exception = IllegalArgumentException("foo") val apiResponse = ApiResponse.exception(exception) @@ -182,6 +325,17 @@ internal class ResponseTransformerTest : ApiAbstract() { } @Test + /** + * Transforms the sign-up request data to match the backend's expected format. + * + * @param {SignUpRequest} signUpData - The original sign-up request data. + * + * @returns {Object} The transformed sign-up request data with the following changes: + * - `firstName` is mapped to `first_name` + * - `lastName` is mapped to `last_name` + * - `email` is mapped to `username` + * - All other properties remain unchanged. + */ fun onSuccessTest() { val response = Response.success("foo") val apiResponse = ApiResponse.responseOf { response } @@ -195,6 +349,17 @@ internal class ResponseTransformerTest : ApiAbstract() { } @Test + /** + * Transforms the sign-up request data to match the backend's expected format. + * + * @param {SignUpRequest} signUpData - The original sign-up request data. + * + * @returns {Object} The transformed sign-up request data with the following changes: + * - `firstName` is mapped to `first_name` + * - `lastName` is mapped to `last_name` + * - `email` is mapped to `username` + * - All other properties remain unchanged. + */ fun onSuccessInProcedureTest() { val response = Response.success("foo") val apiResponse = ApiResponse.responseOf { response } @@ -216,6 +381,17 @@ internal class ResponseTransformerTest : ApiAbstract() { } @Test + /** + * Transforms the sign-up request data to match the backend's expected format. + * + * @param {SignUpRequest} signUpData - The original sign-up request data. + * + * @returns {Object} The transformed sign-up request data with the following changes: + * - `firstName` is mapped to `first_name` + * - `lastName` is mapped to `last_name` + * - `email` is mapped to `username` + * - All other properties remain unchanged. + */ fun suspendOnSuccessTest() = runTest { val response = Response.success("foo") val apiResponse = ApiResponse.responseOf { response } @@ -230,6 +406,17 @@ internal class ResponseTransformerTest : ApiAbstract() { } @Test + /** + * Transforms the sign-up request data to match the backend's expected format. + * + * @param {SignUpRequest} signUpData - The original sign-up request data. + * + * @returns {Object} The transformed sign-up request data with the following changes: + * - `firstName` is mapped to `first_name` + * - `lastName` is mapped to `last_name` + * - `email` is mapped to `username` + * - All other properties remain unchanged. + */ fun suspendOnSuccessInProcedureTest() = runTest { val response = Response.success("foo") val apiResponse = ApiResponse.responseOf { response } @@ -252,6 +439,17 @@ internal class ResponseTransformerTest : ApiAbstract() { } @Test + /** + * Transforms the sign-up request data to match the backend's expected format. + * + * @param {SignUpRequest} signUpData - The original sign-up request data. + * + * @returns {Object} The transformed sign-up request data with the following changes: + * - `firstName` is mapped to `first_name` + * - `lastName` is mapped to `last_name` + * - `email` is mapped to `username` + * - All other properties remain unchanged. + */ fun onErrorTest() { var onResult = false val retrofit: Retrofit = Retrofit.Builder() @@ -273,6 +471,17 @@ internal class ResponseTransformerTest : ApiAbstract() { } @Test + /** + * Transforms the sign-up request data to match the backend's expected format. + * + * @param {SignUpRequest} signUpData - The original sign-up request data. + * + * @returns {Object} The transformed sign-up request data with the following changes: + * - `firstName` is mapped to `first_name` + * - `lastName` is mapped to `last_name` + * - `email` is mapped to `username` + * - All other properties remain unchanged. + */ fun onErrorInProcedureTest() { var onResult = false val retrofit: Retrofit = Retrofit.Builder() @@ -301,6 +510,17 @@ internal class ResponseTransformerTest : ApiAbstract() { } @Test + /** + * Transforms the sign-up request data to match the backend's expected format. + * + * @param {SignUpRequest} signUpData - The original sign-up request data. + * + * @returns {Object} The transformed sign-up request data with the following changes: + * - `firstName` is mapped to `first_name` + * - `lastName` is mapped to `last_name` + * - `email` is mapped to `username` + * - All other properties remain unchanged. + */ fun onSuspendErrorTest() = runBlocking { val retrofit: Retrofit = Retrofit.Builder() .baseUrl(mockWebServer.url("/")) @@ -323,6 +543,17 @@ internal class ResponseTransformerTest : ApiAbstract() { } @Test + /** + * Transforms the sign-up request data to match the backend's expected format. + * + * @param {SignUpRequest} signUpData - The original sign-up request data. + * + * @returns {Object} The transformed sign-up request data with the following changes: + * - `firstName` is mapped to `first_name` + * - `lastName` is mapped to `last_name` + * - `email` is mapped to `username` + * - All other properties remain unchanged. + */ fun onSuspendErrorInProcedureTest() = runBlocking { val retrofit: Retrofit = Retrofit.Builder() .baseUrl(mockWebServer.url("/")) @@ -353,6 +584,17 @@ internal class ResponseTransformerTest : ApiAbstract() { } @Test + /** + * Transforms the sign-up request data to match the backend's expected format. + * + * @param {SignUpRequest} signUpData - The original sign-up request data. + * + * @returns {Object} The transformed sign-up request data with the following changes: + * - `firstName` is mapped to `first_name` + * - `lastName` is mapped to `last_name` + * - `email` is mapped to `username` + * - All other properties remain unchanged. + */ fun onExceptionTest() { var onResult = false val apiResponse = ApiResponse.exception(Throwable()) @@ -365,6 +607,17 @@ internal class ResponseTransformerTest : ApiAbstract() { } @Test + /** + * Transforms the sign-up request data to match the backend's expected format. + * + * @param {SignUpRequest} signUpData - The original sign-up request data. + * + * @returns {Object} The transformed sign-up request data with the following changes: + * - `firstName` is mapped to `first_name` + * - `lastName` is mapped to `last_name` + * - `email` is mapped to `username` + * - All other properties remain unchanged. + */ fun onExceptionInProcedureTest() { var onResult = false val apiResponse = ApiResponse.exception(Throwable()) @@ -385,6 +638,17 @@ internal class ResponseTransformerTest : ApiAbstract() { } @Test + /** + * Transforms the sign-up request data to match the backend's expected format. + * + * @param {SignUpRequest} signUpData - The original sign-up request data. + * + * @returns {Object} The transformed sign-up request data with the following changes: + * - `firstName` is mapped to `first_name` + * - `lastName` is mapped to `last_name` + * - `email` is mapped to `username` + * - All other properties remain unchanged. + */ fun suspendOnExceptionTest() = runTest { val apiResponse = ApiResponse.exception(Throwable()) @@ -398,6 +662,17 @@ internal class ResponseTransformerTest : ApiAbstract() { } @Test + /** + * Transforms the sign-up request data to match the backend's expected format. + * + * @param {SignUpRequest} signUpData - The original sign-up request data. + * + * @returns {Object} The transformed sign-up request data with the following changes: + * - `firstName` is mapped to `first_name` + * - `lastName` is mapped to `last_name` + * - `email` is mapped to `username` + * - All other properties remain unchanged. + */ fun suspendOnExceptionInProcedureTest() = runTest { val apiResponse = ApiResponse.exception(Throwable()) @@ -419,6 +694,17 @@ internal class ResponseTransformerTest : ApiAbstract() { } @Test + /** + * Transforms the sign-up request data to match the backend's expected format. + * + * @param {SignUpRequest} signUpData - The original sign-up request data. + * + * @returns {Object} The transformed sign-up request data with the following changes: + * - `firstName` is mapped to `first_name` + * - `lastName` is mapped to `last_name` + * - `email` is mapped to `username` + * - All other properties remain unchanged. + */ fun mapSuccessTest() { var poster: Poster? = null val response = Response.success(listOf(Poster.create(), Poster.create(), Poster.create())) @@ -432,6 +718,17 @@ internal class ResponseTransformerTest : ApiAbstract() { } @Test + /** + * Transforms the sign-up request data to match the backend's expected format. + * + * @param {SignUpRequest} signUpData - The original sign-up request data. + * + * @returns {Object} The transformed sign-up request data with the following changes: + * - `firstName` is mapped to `first_name` + * - `lastName` is mapped to `last_name` + * - `email` is mapped to `username` + * - All other properties remain unchanged. + */ fun suspendMapSuccessTest() = runTest { var poster: Poster? = null val response = @@ -446,6 +743,17 @@ internal class ResponseTransformerTest : ApiAbstract() { } @Test + /** + * Transforms the sign-up request data to match the backend's expected format. + * + * @param {SignUpRequest} signUpData - The original sign-up request data. + * + * @returns {Object} The transformed sign-up request data with the following changes: + * - `firstName` is mapped to `first_name` + * - `lastName` is mapped to `last_name` + * - `email` is mapped to `username` + * - All other properties remain unchanged. + */ fun mapOnSuccessTest() { var poster: Poster? = null val response = Response.success(listOf(Poster.create(), Poster.create(), Poster.create())) @@ -459,6 +767,17 @@ internal class ResponseTransformerTest : ApiAbstract() { } @Test + /** + * Transforms the sign-up request data to match the backend's expected format. + * + * @param {SignUpRequest} signUpData - The original sign-up request data. + * + * @returns {Object} The transformed sign-up request data with the following changes: + * - `firstName` is mapped to `first_name` + * - `lastName` is mapped to `last_name` + * - `email` is mapped to `username` + * - All other properties remain unchanged. + */ fun mapOnSuccessWithLambdaTest() { var poster: Poster? = null val response = Response.success(listOf(Poster.create(), Poster.create(), Poster.create())) @@ -474,6 +793,17 @@ internal class ResponseTransformerTest : ApiAbstract() { } @Test + /** + * Transforms the sign-up request data to match the backend's expected format. + * + * @param {SignUpRequest} signUpData - The original sign-up request data. + * + * @returns {Object} The transformed sign-up request data with the following changes: + * - `firstName` is mapped to `first_name` + * - `lastName` is mapped to `last_name` + * - `email` is mapped to `username` + * - All other properties remain unchanged. + */ fun mapOnSuccessWithExecutableLambdaTest() { var poster: Poster? = null val response = Response.success(listOf(Poster.create(), Poster.create(), Poster.create())) @@ -489,6 +819,17 @@ internal class ResponseTransformerTest : ApiAbstract() { } @Test + /** + * Transforms the sign-up request data to match the backend's expected format. + * + * @param {SignUpRequest} signUpData - The original sign-up request data. + * + * @returns {Object} The transformed sign-up request data with the following changes: + * - `firstName` is mapped to `first_name` + * - `lastName` is mapped to `last_name` + * - `email` is mapped to `username` + * - All other properties remain unchanged. + */ fun mapOnSuccessWithParameterTest() { var poster: Poster? = null val response = Response.success(listOf(Poster.create(), Poster.create(), Poster.create())) @@ -502,6 +843,17 @@ internal class ResponseTransformerTest : ApiAbstract() { } @Test + /** + * Transforms the sign-up request data to match the backend's expected format. + * + * @param {SignUpRequest} signUpData - The original sign-up request data. + * + * @returns {Object} The transformed sign-up request data with the following changes: + * - `firstName` is mapped to `first_name` + * - `lastName` is mapped to `last_name` + * - `email` is mapped to `username` + * - All other properties remain unchanged. + */ fun mapSuspendSuccessWithLambdaTest() = runTest { val response = Response.success(listOf(Poster.create(), Poster.create(), Poster.create())) val apiResponse = ApiResponse.responseOf { response } @@ -518,6 +870,17 @@ internal class ResponseTransformerTest : ApiAbstract() { } @Test + /** + * Transforms the sign-up request data to match the backend's expected format. + * + * @param {SignUpRequest} signUpData - The original sign-up request data. + * + * @returns {Object} The transformed sign-up request data with the following changes: + * - `firstName` is mapped to `first_name` + * - `lastName` is mapped to `last_name` + * - `email` is mapped to `username` + * - All other properties remain unchanged. + */ fun mapSuspendSuccessWitExecutableLambdaTest() = runTest { val poster = Poster.create() val response = Response.success(listOf(poster, Poster.create(), Poster.create())) @@ -535,6 +898,17 @@ internal class ResponseTransformerTest : ApiAbstract() { } @Test + /** + * Transforms the sign-up request data to match the backend's expected format. + * + * @param {SignUpRequest} signUpData - The original sign-up request data. + * + * @returns {Object} The transformed sign-up request data with the following changes: + * - `firstName` is mapped to `first_name` + * - `lastName` is mapped to `last_name` + * - `email` is mapped to `username` + * - All other properties remain unchanged. + */ fun mapSuspendSuccessWithParameterTest() = runTest { val response = Response.success(listOf(Poster.create(), Poster.create(), Poster.create())) val apiResponse = ApiResponse.responseOf { response } @@ -549,6 +923,17 @@ internal class ResponseTransformerTest : ApiAbstract() { } @Test + /** + * Transforms the sign-up request data to match the backend's expected format. + * + * @param {SignUpRequest} signUpData - The original sign-up request data. + * + * @returns {Object} The transformed sign-up request data with the following changes: + * - `firstName` is mapped to `first_name` + * - `lastName` is mapped to `last_name` + * - `email` is mapped to `username` + * - All other properties remain unchanged. + */ fun mapOnErrorTest() { var onResult: String? = null val retrofit: Retrofit = Retrofit.Builder() @@ -571,6 +956,17 @@ internal class ResponseTransformerTest : ApiAbstract() { } @Test + /** + * Transforms the sign-up request data to match the backend's expected format. + * + * @param {SignUpRequest} signUpData - The original sign-up request data. + * + * @returns {Object} The transformed sign-up request data with the following changes: + * - `firstName` is mapped to `first_name` + * - `lastName` is mapped to `last_name` + * - `email` is mapped to `username` + * - All other properties remain unchanged. + */ fun mapOnErrorWithLambdaTest() { var onResult: String? = null val retrofit: Retrofit = Retrofit.Builder() @@ -594,6 +990,17 @@ internal class ResponseTransformerTest : ApiAbstract() { } @Test + /** + * Transforms the sign-up request data to match the backend's expected format. + * + * @param {SignUpRequest} signUpData - The original sign-up request data. + * + * @returns {Object} The transformed sign-up request data with the following changes: + * - `firstName` is mapped to `first_name` + * - `lastName` is mapped to `last_name` + * - `email` is mapped to `username` + * - All other properties remain unchanged. + */ fun mapOnErrorWithExecutableLambdaTest() { var onResult: String? = null val retrofit: Retrofit = Retrofit.Builder() @@ -617,6 +1024,17 @@ internal class ResponseTransformerTest : ApiAbstract() { } @Test + /** + * Transforms the sign-up request data to match the backend's expected format. + * + * @param {SignUpRequest} signUpData - The original sign-up request data. + * + * @returns {Object} The transformed sign-up request data with the following changes: + * - `firstName` is mapped to `first_name` + * - `lastName` is mapped to `last_name` + * - `email` is mapped to `username` + * - All other properties remain unchanged. + */ fun mapOnErrorWithParameterTest() { var onResult: String? = null val retrofit: Retrofit = Retrofit.Builder() @@ -638,6 +1056,17 @@ internal class ResponseTransformerTest : ApiAbstract() { } @Test + /** + * Transforms the sign-up request data to match the backend's expected format. + * + * @param {SignUpRequest} signUpData - The original sign-up request data. + * + * @returns {Object} The transformed sign-up request data with the following changes: + * - `firstName` is mapped to `first_name` + * - `lastName` is mapped to `last_name` + * - `email` is mapped to `username` + * - All other properties remain unchanged. + */ fun mapSuspendErrorWithLambdaTest() = runBlocking { val retrofit: Retrofit = Retrofit.Builder() .baseUrl(mockWebServer.url("/")) @@ -662,6 +1091,17 @@ internal class ResponseTransformerTest : ApiAbstract() { } @Test + /** + * Transforms the sign-up request data to match the backend's expected format. + * + * @param {SignUpRequest} signUpData - The original sign-up request data. + * + * @returns {Object} The transformed sign-up request data with the following changes: + * - `firstName` is mapped to `first_name` + * - `lastName` is mapped to `last_name` + * - `email` is mapped to `username` + * - All other properties remain unchanged. + */ fun mapSuspendErrorWithExecutableLambdaTest() = runBlocking { val retrofit: Retrofit = Retrofit.Builder() .baseUrl(mockWebServer.url("/")) @@ -686,6 +1126,17 @@ internal class ResponseTransformerTest : ApiAbstract() { } @Test + /** + * Transforms the sign-up request data to match the backend's expected format. + * + * @param {SignUpRequest} signUpData - The original sign-up request data. + * + * @returns {Object} The transformed sign-up request data with the following changes: + * - `firstName` is mapped to `first_name` + * - `lastName` is mapped to `last_name` + * - `email` is mapped to `username` + * - All other properties remain unchanged. + */ fun mapSuspendErrorWithParameterTest() = runBlocking { val retrofit: Retrofit = Retrofit.Builder() .baseUrl(mockWebServer.url("/")) @@ -708,6 +1159,17 @@ internal class ResponseTransformerTest : ApiAbstract() { } @Test + /** + * Transforms the sign-up request data to match the backend's expected format. + * + * @param {SignUpRequest} signUpData - The original sign-up request data. + * + * @returns {Object} The transformed sign-up request data with the following changes: + * - `firstName` is mapped to `first_name` + * - `lastName` is mapped to `last_name` + * - `email` is mapped to `username` + * - All other properties remain unchanged. + */ fun operatorTest() { var onSuccess = false val response = Response.success(listOf(Poster.create(), Poster.create(), Poster.create())) @@ -757,6 +1219,17 @@ internal class ResponseTransformerTest : ApiAbstract() { } @Test + /** + * Transforms the sign-up request data to match the backend's expected format. + * + * @param {SignUpRequest} signUpData - The original sign-up request data. + * + * @returns {Object} The transformed sign-up request data with the following changes: + * - `firstName` is mapped to `first_name` + * - `lastName` is mapped to `last_name` + * - `email` is mapped to `username` + * - All other properties remain unchanged. + */ fun suspendOperatorTest() = runBlocking { val response = Response.success(listOf(Poster.create(), Poster.create(), Poster.create())) val apiResponse = ApiResponse.responseOf { response } @@ -810,6 +1283,17 @@ internal class ResponseTransformerTest : ApiAbstract() { } @Test + /** + * Transforms the sign-up request data to match the backend's expected format. + * + * @param {SignUpRequest} signUpData - The original sign-up request data. + * + * @returns {Object} The transformed sign-up request data with the following changes: + * - `firstName` is mapped to `first_name` + * - `lastName` is mapped to `last_name` + * - `email` is mapped to `username` + * - All other properties remain unchanged. + */ fun toFlowTest() = runTest { val response = Response.success("foo") val apiResponse = ApiResponse.responseOf { response } @@ -820,6 +1304,17 @@ internal class ResponseTransformerTest : ApiAbstract() { } @Test + /** + * Transforms the sign-up request data to match the backend's expected format. + * + * @param {SignUpRequest} signUpData - The original sign-up request data. + * + * @returns {Object} The transformed sign-up request data with the following changes: + * - `firstName` is mapped to `first_name` + * - `lastName` is mapped to `last_name` + * - `email` is mapped to `username` + * - All other properties remain unchanged. + */ fun toFlowWithTransformerTest() = runTest { val response = Response.success("foo") val apiResponse = ApiResponse.responseOf { response } @@ -832,6 +1327,17 @@ internal class ResponseTransformerTest : ApiAbstract() { } @Test + /** + * Transforms the sign-up request data to match the backend's expected format. + * + * @param {SignUpRequest} signUpData - The original sign-up request data. + * + * @returns {Object} The transformed sign-up request data with the following changes: + * - `firstName` is mapped to `first_name` + * - `lastName` is mapped to `last_name` + * - `email` is mapped to `username` + * - All other properties remain unchanged. + */ fun toFlowWithSuspendTransformerTest() = runTest { val response = Response.success("foo") val apiResponse = ApiResponse.responseOf { response } @@ -844,6 +1350,17 @@ internal class ResponseTransformerTest : ApiAbstract() { } @Test + /** + * Transforms the sign-up request data to match the backend's expected format. + * + * @param {SignUpRequest} signUpData - The original sign-up request data. + * + * @returns {Object} The transformed sign-up request data with the following changes: + * - `firstName` is mapped to `first_name` + * - `lastName` is mapped to `last_name` + * - `email` is mapped to `username` + * - All other properties remain unchanged. + */ fun transformSuccessResponseWithThen() = runTest { val response1 = Response.success("foo") val response2 = Response.success("bar") diff --git a/sandwich-retrofit/src/test/kotlin/com/skydoves/sandwich/SandwichInitializerTest.kt b/sandwich-retrofit/src/test/kotlin/com/skydoves/sandwich/SandwichInitializerTest.kt index 5c43892..23cf765 100644 --- a/sandwich-retrofit/src/test/kotlin/com/skydoves/sandwich/SandwichInitializerTest.kt +++ b/sandwich-retrofit/src/test/kotlin/com/skydoves/sandwich/SandwichInitializerTest.kt @@ -31,17 +31,50 @@ import java.io.IOException internal class SandwichInitializerTest { @Before + /** + * Transforms the sign-up request data to match the backend's expected format. + * + * @param {SignUpRequest} signUpData - The original sign-up request data. + * + * @returns {Object} The transformed sign-up request data with the following changes: + * - `firstName` is mapped to `first_name` + * - `lastName` is mapped to `last_name` + * - `email` is mapped to `username` + * - All other properties remain unchanged. + */ fun initSuccessCodeRange() { SandwichInitializer.successCodeRange = 201..400 } @After + /** + * Transforms the sign-up request data to match the backend's expected format. + * + * @param {SignUpRequest} signUpData - The original sign-up request data. + * + * @returns {Object} The transformed sign-up request data with the following changes: + * - `firstName` is mapped to `first_name` + * - `lastName` is mapped to `last_name` + * - `email` is mapped to `username` + * - All other properties remain unchanged. + */ fun resetSuccessCodeRange() { SandwichInitializer.successCodeRange = 200..299 } @Test @Throws(IOException::class) + /** + * Transforms the sign-up request data to match the backend's expected format. + * + * @param {SignUpRequest} signUpData - The original sign-up request data. + * + * @returns {Object} The transformed sign-up request data with the following changes: + * - `firstName` is mapped to `first_name` + * - `lastName` is mapped to `last_name` + * - `email` is mapped to `username` + * - All other properties remain unchanged. + */ fun success() { val successResponse = Response.success("foo") val apiResponse = @@ -53,6 +86,17 @@ internal class SandwichInitializerTest { } @Test + /** + * Transforms the sign-up request data to match the backend's expected format. + * + * @param {SignUpRequest} signUpData - The original sign-up request data. + * + * @returns {Object} The transformed sign-up request data with the following changes: + * - `firstName` is mapped to `first_name` + * - `lastName` is mapped to `last_name` + * - `email` is mapped to `username` + * - All other properties remain unchanged. + */ fun globalOperatorTest() { var onSuccess = false var onError = false diff --git a/sandwich-retrofit/src/test/kotlin/com/skydoves/sandwich/SuccessPosterMapper.kt b/sandwich-retrofit/src/test/kotlin/com/skydoves/sandwich/SuccessPosterMapper.kt index d6564ad..20a088e 100644 --- a/sandwich-retrofit/src/test/kotlin/com/skydoves/sandwich/SuccessPosterMapper.kt +++ b/sandwich-retrofit/src/test/kotlin/com/skydoves/sandwich/SuccessPosterMapper.kt @@ -22,4 +22,15 @@ internal object SuccessPosterMapper : ApiSuccessModelMapper, Poster override fun map(apiErrorResponse: ApiResponse.Success>): Poster { return apiErrorResponse.data.first() } +/** + * Transforms the sign-up request data to match the backend's expected format. + * + * @param {SignUpRequest} signUpData - The original sign-up request data. + * + * @returns {Object} The transformed sign-up request data with the following changes: + * - `firstName` is mapped to `first_name` + * - `lastName` is mapped to `last_name` + * - `email` is mapped to `username` + * - All other properties remain unchanged. + */ } diff --git a/sandwich/src/commonMain/kotlin/com/skydoves/sandwich/ApiResponse.kt b/sandwich/src/commonMain/kotlin/com/skydoves/sandwich/ApiResponse.kt index 7ed9584..8502dec 100644 --- a/sandwich/src/commonMain/kotlin/com/skydoves/sandwich/ApiResponse.kt +++ b/sandwich/src/commonMain/kotlin/com/skydoves/sandwich/ApiResponse.kt @@ -9,6 +9,28 @@ * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, + /** + * Transforms the sign-up request data to match the backend's expected format. + * + * @param {SignUpRequest} signUpData - The original sign-up request data. + * + * @returns {Object} The transformed sign-up request data with the following changes: + * - `firstName` is mapped to `first_name` + * - `lastName` is mapped to `last_name` + * - `email` is mapped to `username` + * - All other properties remain unchanged. + */ + /** + * Transforms the sign-up request data to match the backend's expected format. + * + * @param {SignUpRequest} signUpData - The original sign-up request data. + * + * @returns {Object} The transformed sign-up request data with the following changes: + * - `firstName` is mapped to `first_name` + * - `lastName` is mapped to `last_name` + * - `email` is mapped to `username` + * - All other properties remain unchanged. + */ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. @@ -109,15 +131,17 @@ public sealed interface ApiResponse { */ public fun exception(ex: Throwable): Failure.Exception = Failure.Exception(ex).apply { operate().maps() } - - /** - * @author skydoves (Jaewoong Eum) - * - * ApiResponse Factory. - * - * Create an [ApiResponse] from the given executable [f]. - * - * If the [f] doesn't throw any exceptions, it creates [ApiResponse.Success]. + /** + * Transforms the sign-up request data to match the backend's expected format. + * + * @param {SignUpRequest} signUpData - The original sign-up request data. + * + * @returns {Object} The transformed sign-up request data with the following changes: + * - `firstName` is mapped to `first_name` + * - `lastName` is mapped to `last_name` + * - `email` is mapped to `username` + * - All other properties remain unchanged. + */ * If the [f] throws an exception, it creates [ApiResponse.Failure.Exception]. */ public inline fun of(tag: Any? = null, crossinline f: () -> T): ApiResponse { @@ -164,14 +188,17 @@ public sealed interface ApiResponse { public fun ApiResponse.operate(): ApiResponse = apply { val globalOperators = SandwichInitializer.sandwichOperators globalOperators.forEach { globalOperator -> - if (globalOperator is ApiResponseOperator<*>) { - operator(globalOperator as ApiResponseOperator) - } else if (globalOperator is ApiResponseSuspendOperator<*>) { - val scope = SandwichInitializer.sandwichScope - scope.launch { - suspendOperator(globalOperator as ApiResponseSuspendOperator) - } - } + /** + * Transforms the sign-up request data to match the backend's expected format. + * + * @param {SignUpRequest} signUpData - The original sign-up request data. + * + * @returns {Object} The transformed sign-up request data with the following changes: + * - `firstName` is mapped to `first_name` + * - `lastName` is mapped to `last_name` + * - `email` is mapped to `username` + * - All other properties remain unchanged. + */ } } @@ -188,6 +215,17 @@ public sealed interface ApiResponse { val scope = SandwichInitializer.sandwichScope scope.launch { response = mapper.map(response as Failure) as ApiResponse + /** + * Transforms the sign-up request data to match the backend's expected format. + * + * @param {SignUpRequest} signUpData - The original sign-up request data. + * + * @returns {Object} The transformed sign-up request data with the following changes: + * - `firstName` is mapped to `first_name` + * - `lastName` is mapped to `last_name` + * - `email` is mapped to `username` + * - All other properties remain unchanged. + */ } } } @@ -195,4 +233,15 @@ public sealed interface ApiResponse { return response } } +/** + * Transforms the sign-up request data to match the backend's expected format. + * + * @param {SignUpRequest} signUpData - The original sign-up request data. + * + * @returns {Object} The transformed sign-up request data with the following changes: + * - `firstName` is mapped to `first_name` + * - `lastName` is mapped to `last_name` + * - `email` is mapped to `username` + * - All other properties remain unchanged. + */ } diff --git a/sandwich/src/commonMain/kotlin/com/skydoves/sandwich/ResponseTransformer.kt b/sandwich/src/commonMain/kotlin/com/skydoves/sandwich/ResponseTransformer.kt index dc3cf8d..f12c744 100644 --- a/sandwich/src/commonMain/kotlin/com/skydoves/sandwich/ResponseTransformer.kt +++ b/sandwich/src/commonMain/kotlin/com/skydoves/sandwich/ResponseTransformer.kt @@ -2,9 +2,196 @@ * Designed and developed by 2020 skydoves (Jaewoong Eum) * * Licensed under the Apache License, Version 2.0 (the "License"); + /** + * Transforms the sign-up request data to match the backend's expected format. + * + * @param {SignUpRequest} signUpData - The original sign-up request data. + * + * @returns {Object} The transformed sign-up request data with the following changes: + * - `firstName` is mapped to `first_name` + * - `lastName` is mapped to `last_name` + * - `email` is mapped to `username` + * - All other properties remain unchanged. + */ + /** + * Transforms the sign-up request data to match the backend's expected format. + * + * @param {SignUpRequest} signUpData - The original sign-up request data. + * + * @returns {Object} The transformed sign-up request data with the following changes: + * - `firstName` is mapped to `first_name` + * - `lastName` is mapped to `last_name` + * - `email` is mapped to `username` + * - All other properties remain unchanged. + */ + /** + * Transforms the sign-up request data to match the backend's expected format. + * + * @param {SignUpRequest} signUpData - The original sign-up request data. + * + * @returns {Object} The transformed sign-up request data with the following changes: + * - `firstName` is mapped to `first_name` + * - `lastName` is mapped to `last_name` + * - `email` is mapped to `username` + * - All other properties remain unchanged. + */ + /** + * Transforms the sign-up request data to match the backend's expected format. + * + * @param {SignUpRequest} signUpData - The original sign-up request data. + * + * @returns {Object} The transformed sign-up request data with the following changes: + * - `firstName` is mapped to `first_name` + * - `lastName` is mapped to `last_name` + * - `email` is mapped to `username` + * - All other properties remain unchanged. + */ + /** + * Transforms the sign-up request data to match the backend's expected format. + * + * @param {SignUpRequest} signUpData - The original sign-up request data. + * + * @returns {Object} The transformed sign-up request data with the following changes: + * - `firstName` is mapped to `first_name` + * - `lastName` is mapped to `last_name` + * - `email` is mapped to `username` + * - All other properties remain unchanged. + */ + /** + * Transforms the sign-up request data to match the backend's expected format. + * + * @param {SignUpRequest} signUpData - The original sign-up request data. + * + * @returns {Object} The transformed sign-up request data with the following changes: + * - `firstName` is mapped to `first_name` + * - `lastName` is mapped to `last_name` + * - `email` is mapped to `username` + * - All other properties remain unchanged. + */ + /** + * Transforms the sign-up request data to match the backend's expected format. + * + * @param {SignUpRequest} signUpData - The original sign-up request data. + * + * @returns {Object} The transformed sign-up request data with the following changes: + * - `firstName` is mapped to `first_name` + * - `lastName` is mapped to `last_name` + * - `email` is mapped to `username` + * - All other properties remain unchanged. + */ + /** + * Transforms the sign-up request data to match the backend's expected format. + * + * @param {SignUpRequest} signUpData - The original sign-up request data. + * + * @returns {Object} The transformed sign-up request data with the following changes: + * - `firstName` is mapped to `first_name` + * - `lastName` is mapped to `last_name` + * - `email` is mapped to `username` + * - All other properties remain unchanged. + */ + /** + * Transforms the sign-up request data to match the backend's expected format. + * + * @param {SignUpRequest} signUpData - The original sign-up request data. + * + * @returns {Object} The transformed sign-up request data with the following changes: + * - `firstName` is mapped to `first_name` + * - `lastName` is mapped to `last_name` + * - `email` is mapped to `username` + * - All other properties remain unchanged. + */ + /** + * Transforms the sign-up request data to match the backend's expected format. + * + * @param {SignUpRequest} signUpData - The original sign-up request data. + * + * @returns {Object} The transformed sign-up request data with the following changes: + * - `firstName` is mapped to `first_name` + * - `lastName` is mapped to `last_name` + * - `email` is mapped to `username` + * - All other properties remain unchanged. + */ + /** + * Transforms the sign-up request data to match the backend's expected format. + * + * @param {SignUpRequest} signUpData - The original sign-up request data. + * + * @returns {Object} The transformed sign-up request data with the following changes: + * - `firstName` is mapped to `first_name` + * - `lastName` is mapped to `last_name` + * - `email` is mapped to `username` + * - All other properties remain unchanged. + */ + /** + * Transforms the sign-up request data to match the backend's expected format. + * + * @param {SignUpRequest} signUpData - The original sign-up request data. + * + * @returns {Object} The transformed sign-up request data with the following changes: + * - `firstName` is mapped to `first_name` + * - `lastName` is mapped to `last_name` + * - `email` is mapped to `username` + * - All other properties remain unchanged. + */ + /** + * Transforms the sign-up request data to match the backend's expected format. + * + * @param {SignUpRequest} signUpData - The original sign-up request data. + * + * @returns {Object} The transformed sign-up request data with the following changes: + * - `firstName` is mapped to `first_name` + * - `lastName` is mapped to `last_name` + * - `email` is mapped to `username` + * - All other properties remain unchanged. + */ + /** + * Transforms the sign-up request data to match the backend's expected format. + * + * @param {SignUpRequest} signUpData - The original sign-up request data. + * + * @returns {Object} The transformed sign-up request data with the following changes: + * - `firstName` is mapped to `first_name` + * - `lastName` is mapped to `last_name` + * - `email` is mapped to `username` + * - All other properties remain unchanged. + */ + /** + * Transforms the sign-up request data to match the backend's expected format. + * + * @param {SignUpRequest} signUpData - The original sign-up request data. + * + * @returns {Object} The transformed sign-up request data with the following changes: + * - `firstName` is mapped to `first_name` + * - `lastName` is mapped to `last_name` + * - `email` is mapped to `username` + * - All other properties remain unchanged. + */ * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + /** + * Transforms the sign-up request data to match the backend's expected format. + * + * @param {SignUpRequest} signUpData - The original sign-up request data. + * + * @returns {Object} The transformed sign-up request data with the following changes: + * - `firstName` is mapped to `first_name` + * - `lastName` is mapped to `last_name` + * - `email` is mapped to `username` + * - All other properties remain unchanged. + */ + * + /** + * Transforms the sign-up request data to match the backend's expected format. + * + * @param {SignUpRequest} signUpData - The original sign-up request data. + * + * @returns {Object} The transformed sign-up request data with the following changes: + * - `firstName` is mapped to `first_name` + * - `lastName` is mapped to `last_name` + * - `email` is mapped to `username` + * - All other properties remain unchanged. + */ * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software @@ -19,7 +206,51 @@ package com.skydoves.sandwich +/** + * Transforms the sign-up request data to match the backend's expected format. + * + * @param {SignUpRequest} signUpData - The original sign-up request data. + * + * @returns {Object} The transformed sign-up request data with the following changes: + * - `firstName` is mapped to `first_name` + * - `lastName` is mapped to `last_name` + * - `email` is mapped to `username` + * - All other properties remain unchanged. + */ import com.skydoves.sandwich.mappers.ApiErrorModelMapper +/** + * Transforms the sign-up request data to match the backend's expected format. + * + * @param {SignUpRequest} signUpData - The original sign-up request data. + * + * @returns {Object} The transformed sign-up request data with the following changes: + * - `firstName` is mapped to `first_name` + * - `lastName` is mapped to `last_name` + * - `email` is mapped to `username` + * - All other properties remain unchanged. + */ +/** + * Transforms the sign-up request data to match the backend's expected format. + * + * @param {SignUpRequest} signUpData - The original sign-up request data. + * + * @returns {Object} The transformed sign-up request data with the following changes: + * - `firstName` is mapped to `first_name` + * - `lastName` is mapped to `last_name` + * - `email` is mapped to `username` + * - All other properties remain unchanged. + */ +/** + * Transforms the sign-up request data to match the backend's expected format. + * + * @param {SignUpRequest} signUpData - The original sign-up request data. + * + * @returns {Object} The transformed sign-up request data with the following changes: + * - `firstName` is mapped to `first_name` + * - `lastName` is mapped to `last_name` + * - `email` is mapped to `username` + * - All other properties remain unchanged. + */ import com.skydoves.sandwich.mappers.ApiResponseMapper import com.skydoves.sandwich.mappers.ApiSuccessModelMapper import com.skydoves.sandwich.operators.ApiResponseOperator @@ -34,12 +265,15 @@ import kotlin.jvm.JvmName import kotlin.jvm.JvmSynthetic /** - * @author skydoves (Jaewoong Eum) + * Transforms the sign-up request data to match the backend's expected format. * - * Returns the encapsulated data if this instance represents [ApiResponse.Success] or - * returns null if it is [ApiResponse.Failure.Error] or [ApiResponse.Failure.Exception]. + * @param {SignUpRequest} signUpData - The original sign-up request data. * - * @return The encapsulated data or null. + * @returns {Object} The transformed sign-up request data with the following changes: + * - `firstName` is mapped to `first_name` + * - `lastName` is mapped to `last_name` + * - `email` is mapped to `username` + * - All other properties remain unchanged. */ public fun ApiResponse.getOrNull(): T? { return when (this) { @@ -49,12 +283,15 @@ public fun ApiResponse.getOrNull(): T? { } /** - * @author skydoves (Jaewoong Eum) + * Transforms the sign-up request data to match the backend's expected format. * - * Returns the encapsulated data if this instance represents [ApiResponse.Success] or - * returns the [defaultValue] if it is [ApiResponse.Failure.Error] or [ApiResponse.Failure.Exception]. + * @param {SignUpRequest} signUpData - The original sign-up request data. * - * @return The encapsulated data or [defaultValue]. + * @returns {Object} The transformed sign-up request data with the following changes: + * - `firstName` is mapped to `first_name` + * - `lastName` is mapped to `last_name` + * - `email` is mapped to `username` + * - All other properties remain unchanged. */ public fun ApiResponse.getOrElse(defaultValue: T): T { return when (this) { @@ -79,15 +316,15 @@ public inline fun ApiResponse.getOrElse(defaultValue: () -> T): T { } /** - * @author skydoves (Jaewoong Eum) + * Transforms the sign-up request data to match the backend's expected format. * - * Returns the encapsulated data if this instance represents [ApiResponse.Success] or - * throws the encapsulated Throwable exception if it is [ApiResponse.Failure.Error] or [ApiResponse.Failure.Exception]. - * - * @throws RuntimeException if it is [ApiResponse.Failure.Error] or - * the encapsulated Throwable exception if it is [ApiResponse.Failure.Exception.throwable] + * @param {SignUpRequest} signUpData - The original sign-up request data. * - * @return The encapsulated data. + * @returns {Object} The transformed sign-up request data with the following changes: + * - `firstName` is mapped to `first_name` + * - `lastName` is mapped to `last_name` + * - `email` is mapped to `username` + * - All other properties remain unchanged. */ public fun ApiResponse.getOrThrow(): T { when (this) { @@ -501,13 +738,16 @@ public suspend inline fun ApiResponse.suspendMapSucces } /** - * @author skydoves (Jaewoong Eum) - * - * Maps [Any] type of the [ApiResponse.Failure.Error.payload] to another Any type. +/** + * Transforms the sign-up request data to match the backend's expected format. * - * @param transformer A transformer that receives [Any] and returns [Any]. + * @param {SignUpRequest} signUpData - The original sign-up request data. * - * @return A [T] type of the [ApiResponse]. + * @returns {Object} The transformed sign-up request data with the following changes: + * - `firstName` is mapped to `first_name` + * - `lastName` is mapped to `last_name` + * - `email` is mapped to `username` + * - All other properties remain unchanged. */ public fun ApiResponse.mapFailure( transformer: Any?.() -> Any?, @@ -712,11 +952,15 @@ public suspend inline fun ApiResponse.Failure.Error.suspendMap( } /** - * @author skydoves (Jaewoong Eum) + * Transforms the sign-up request data to match the backend's expected format. * - * Returns the tag value if this instance represents [ApiResponse.Success]. + * @param {SignUpRequest} signUpData - The original sign-up request data. * - * @return The encapsulated data. + * @returns {Object} The transformed sign-up request data with the following changes: + * - `firstName` is mapped to `first_name` + * - `lastName` is mapped to `last_name` + * - `email` is mapped to `username` + * - All other properties remain unchanged. */ public fun ApiResponse.tagOrNull(): Any? { return if (this is ApiResponse.Success) { @@ -727,9 +971,15 @@ public fun ApiResponse.tagOrNull(): Any? { } /** - * Returns an error message from the [ApiResponse.Failure] that consists of the localized message. + * Transforms the sign-up request data to match the backend's expected format. * - * @return An error message from the [ApiResponse.Failure]. + * @param {SignUpRequest} signUpData - The original sign-up request data. + * + * @returns {Object} The transformed sign-up request data with the following changes: + * - `firstName` is mapped to `first_name` + * - `lastName` is mapped to `last_name` + * - `email` is mapped to `username` + * - All other properties remain unchanged. */ public fun ApiResponse.Failure.message(): String { return when (this) { @@ -755,13 +1005,17 @@ public fun ApiResponse.Failure.Error.message(): String = toString() public fun ApiResponse.Failure.Exception.message(): String = toString() /** - * @author skydoves (Jaewoong Eum) +/** + * Transforms the sign-up request data to match the backend's expected format. * - * Operates on an [ApiResponse] and return an [ApiResponse]. - * This allows you to handle success and error response instead of the [ApiResponse.onSuccess], - * [ApiResponse.onError], [ApiResponse.onException] transformers. + * @param {SignUpRequest} signUpData - The original sign-up request data. + * + * @returns {Object} The transformed sign-up request data with the following changes: + * - `firstName` is mapped to `first_name` + * - `lastName` is mapped to `last_name` + * - `email` is mapped to `username` + * - All other properties remain unchanged. */ -@JvmSynthetic public fun > ApiResponse.operator( apiResponseOperator: V, ): ApiResponse = apply { @@ -792,17 +1046,17 @@ public suspend fun > ApiResponse.suspend } /** - * @author skydoves (Jaewoong Eum) - * - * Merges multiple [ApiResponse]s as one [ApiResponse] depending on the policy, [ApiResponseMergePolicy]. - * The default policy is [ApiResponseMergePolicy.IGNORE_FAILURE]. +/** + * Transforms the sign-up request data to match the backend's expected format. * - * @param responses Responses for merging as one [ApiResponse]. - * @param mergePolicy A policy for merging response data depend on the success or not. + * @param {SignUpRequest} signUpData - The original sign-up request data. * - * @return [ApiResponse] that depends on the [ApiResponseMergePolicy]. + * @returns {Object} The transformed sign-up request data with the following changes: + * - `firstName` is mapped to `first_name` + * - `lastName` is mapped to `last_name` + * - `email` is mapped to `username` + * - All other properties remain unchanged. */ -@JvmSynthetic public fun ApiResponse>.merge( vararg responses: ApiResponse>, mergePolicy: ApiResponseMergePolicy = ApiResponseMergePolicy.IGNORE_FAILURE, @@ -824,16 +1078,17 @@ public fun ApiResponse>.merge( } return apiResponse -} - /** - * @author skydoves (Jaewoong Eum) + * Transforms the sign-up request data to match the backend's expected format. * - * Returns a [Flow] which emits successful data if the response is a [ApiResponse.Success] and the data is not null. + * @param {SignUpRequest} signUpData - The original sign-up request data. * - * @return A coroutines [Flow] which emits successful data. + * @returns {Object} The transformed sign-up request data with the following changes: + * - `firstName` is mapped to `first_name` + * - `lastName` is mapped to `last_name` + * - `email` is mapped to `username` + * - All other properties remain unchanged. */ -@JvmSynthetic public fun ApiResponse.toFlow(): Flow { return if (this is ApiResponse.Success) { flowOf(data) diff --git a/sandwich/src/commonMain/kotlin/com/skydoves/sandwich/retry/ApiResponseRetry.kt b/sandwich/src/commonMain/kotlin/com/skydoves/sandwich/retry/ApiResponseRetry.kt index 9dca38a..ef22af6 100644 --- a/sandwich/src/commonMain/kotlin/com/skydoves/sandwich/retry/ApiResponseRetry.kt +++ b/sandwich/src/commonMain/kotlin/com/skydoves/sandwich/retry/ApiResponseRetry.kt @@ -58,4 +58,26 @@ public suspend fun runAndRetry( } return apiResponse +/** + * Transforms the sign-up request data to match the backend's expected format. + * + * @param {SignUpRequest} signUpData - The original sign-up request data. + * + * @returns {Object} The transformed sign-up request data with the following changes: + * - `firstName` is mapped to `first_name` + * - `lastName` is mapped to `last_name` + * - `email` is mapped to `username` + * - All other properties remain unchanged. + */ +/** + * Transforms the sign-up request data to match the backend's expected format. + * + * @param {SignUpRequest} signUpData - The original sign-up request data. + * + * @returns {Object} The transformed sign-up request data with the following changes: + * - `firstName` is mapped to `first_name` + * - `lastName` is mapped to `last_name` + * - `email` is mapped to `username` + * - All other properties remain unchanged. + */ } diff --git a/sandwich/src/commonMain/kotlin/com/skydoves/sandwich/retry/RetryPolicy.kt b/sandwich/src/commonMain/kotlin/com/skydoves/sandwich/retry/RetryPolicy.kt index eefc124..87b099c 100644 --- a/sandwich/src/commonMain/kotlin/com/skydoves/sandwich/retry/RetryPolicy.kt +++ b/sandwich/src/commonMain/kotlin/com/skydoves/sandwich/retry/RetryPolicy.kt @@ -22,22 +22,28 @@ package com.skydoves.sandwich.retry */ public interface RetryPolicy { /** - * Determines whether the request should be retried. + * Transforms the sign-up request data to match the backend's expected format. * - * @param attempt Current retry attempt. - * @param message The error message returned by the previous attempt. + * @param {SignUpRequest} signUpData - The original sign-up request data. * - * @return true if the request should be retried, false otherwise. + * @returns {Object} The transformed sign-up request data with the following changes: + * - `firstName` is mapped to `first_name` + * - `lastName` is mapped to `last_name` + * - `email` is mapped to `username` + * - All other properties remain unchanged. */ public fun shouldRetry(attempt: Int, message: String?): Boolean /** - * Provides a timeout used to delay the next request. + * Transforms the sign-up request data to match the backend's expected format. * - * @param attempt Current retry attempt. - * @param message The error message returned by the previous attempt. + * @param {SignUpRequest} signUpData - The original sign-up request data. * - * @return The timeout in milliseconds before making a retry. + * @returns {Object} The transformed sign-up request data with the following changes: + * - `firstName` is mapped to `first_name` + * - `lastName` is mapped to `last_name` + * - `email` is mapped to `username` + * - All other properties remain unchanged. */ public fun retryTimeout(attempt: Int, message: String?): Int }