Retrofit2 | #1
Зависимости для build.gradle: implementation “com.squareup.retrofit2:retrofit:2.9.0″implementation “com.squareup.retrofit2:converter-gson:2.9.0” Product.kt data class Product( val id: Int, val title: String, val description: String, val price: Int, val discountPercentage: Float, val rating: Float, val stock: Int, val brand: String, val category: String, val thumbnail: String, val images: List<String>) ProductApi.kt import retrofit2.http.GETimport retrofit2.http.Pathinterface ProductApi { @GET(“products/{id}”) suspend fun getProductById(@Path(“id”) id: Int): Product} Разрешение в манифест: <uses-permission android:name=”android.permission.INTERNET”/> activity_main.kt <?xml version=”1.0″ encoding=”utf-8″?><androidx.constraintlayout.widget.ConstraintLayout xmlns:android=”http://schemas.android.com/apk/res/android” xmlns:app=”http://schemas.android.com/apk/res-auto” xmlns:tools=”http://schemas.android.com/tools” android:layout_width=”match_parent” android:layout_height=”match_parent”… Подробнее »Retrofit2 | #1