Skip to content

Instantly share code, notes, and snippets.

@marrek13
Created January 16, 2022 19:29
Show Gist options
  • Save marrek13/506fd4ed9d881a9ce9aab15db7a6f83f to your computer and use it in GitHub Desktop.
Save marrek13/506fd4ed9d881a9ce9aab15db7a6f83f to your computer and use it in GitHub Desktop.
@Service
class CatalogService(private val catalogClient: CatalogClient) {
suspend fun getAll(merchantCode: String): List<CategoryResponse> = catalogClient.getCategories(
merchantCode,
getSumupHeaders(),
)
.call()
.map { categoryResponse -> CategoryResponseFactory.create(categoryResponse) }
}
class CategoryResponseFactory {
companion object {
fun create(
categoryResponse: CategoryResponse,
) = CategoryResponse(
categoryId = categoryResponse.id,
name = categoryResponse.name,
)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment