Create a Retrofit API interface and wire it up.
Creates a Retrofit API interface with DTOs and Hilt DI wiring. Use when adding new network endpoints to your Android app.
/plugin marketplace add ggz23/android-interview-plugin/plugin install ggz23-android-interview@ggz23/android-interview-pluginCreate a Retrofit API interface and wire it up.
$ARGUMENTS - API description (e.g., "ProductApi with GET /products")
Explore Project Structure
data/remote/)Create API interface:
interface {Name}Api {
@GET("endpoint")
suspend fun getItems(): List<{Name}Dto>
@GET("endpoint/{id}")
suspend fun getItem(@Path("id") id: String): {Name}Dto
@POST("endpoint")
suspend fun createItem(@Body item: {Name}Dto): {Name}Dto
}
@Serializable:@Serializable
data class {Name}Dto(
val id: String,
// fields matching API response
)
@Provides
@Singleton
fun provide{Name}Api(retrofit: Retrofit): {Name}Api =
retrofit.create({Name}Api::class.java)