Thursday, June 10, 2021

【ANDROID STUDIO】 Create Data Classes Retrofit With Kotlin Coroutines

 package com.example.myapplication


import retrofit2.Response
import retrofit2.http.GET

interface AlbumService {
@GET("/albums")
suspend fun getAlbums() : Response<Albums>

}
package com.example.myapplication


import com.google.gson.annotations.SerializedName

class Albums : ArrayList<AlbumsItem>()

package com.example.myapplication


import com.google.gson.annotations.SerializedName

data class AlbumsItem(
@SerializedName("id")
val id: Int,
@SerializedName("title")
val title: String,
@SerializedName("userId")
val userId: Int
)

No comments:

Post a Comment