/test

Primary LanguageKotlin

N26 Coding Challenge

In this challenge you are required to build part of one of our widgets from N26 Insights feature.

Installation Requirements

  • Latest Android Studio stable release version (Ladybug 2024.2.1)
  • JDK 17

Top 4 Categories

Shows the list of top 4 categories where the user spent most money on.

Insights

The task

You're given a scaffold project with the following Retrofit API

@GET("/insights/transactions")
fun fetchTransactions(): List<TransactionDto>

Where transactions and categories are defined by the following data transfer objects (DTO)

@Serializable
data class TransactionDto(
    val id: Int,
    val category: CategoryDto,
    @Contextual val amount: BigDecimal
)


@Serializable
data class CategoryDto(
    val id: Int,
    val name: String
)

Build an app that will fetch data from this api and render those items. In N26 we use NXD (our own design system library), so you don't need to worry about layouts, just use the TopCategoryViewEntity data class

data class TopCategoryViewEntity(
    val name: String,
    val amount: String,
    @DrawableRes val icon: Int
) : NxdViewEntity

and pass the items to MainActivity.kt using the function below

fun render(items: List<TopCategoryViewEntity>) {
    adapter.submit(items)
}