Android Kotlin翻新查询注释参数
因此,我有一个用于Android Kotlin翻新查询注释参数,android,kotlin,retrofit,Android,Kotlin,Retrofit,因此,我有一个用于NetworkConfig.kt类的接口: interface getProductList { @GET("stock") fun getProducts(@Query("outcode") stkOutcode: String): Call<OutletListPOJODataClasses> } 我对使用这个图书馆是个新手。我想知道的是在上面的.getProducts()函数中应该传递什么?如果有什么不清楚的,请告诉我 应该是 Network
NetworkConfig.kt
类的接口:
interface getProductList {
@GET("stock")
fun getProducts(@Query("outcode") stkOutcode: String): Call<OutletListPOJODataClasses>
}
我对使用这个图书馆是个新手。我想知道的是在上面的.getProducts()
函数中应该传递什么?如果有什么不清楚的,请告诉我 应该是
NetworkConfig().getProductListService()
.getProducts(stkOutcode = stkOutcodeValue)
....
其中,stkOutcodeValue
(字符串类型)应该是已知的,或者可以使用默认值(如果适用)
多亏了@sonnet,本例中的端点是
https://example.com/api/stock?outcode=stkOutcodeValue
您应该在url中传递outcode
的值。示例:https://example.com/api/stock?outcode=value_here
您应该传递outcode
的查询参数。见
data class ProductListPOJODataClassesDataItem(
@field:SerializedName("stk_prodcode")
val stkProdcode: String? = null,
@field:SerializedName("stk_allqty")
val stkAllqty: Int? = null,
@field:SerializedName("pro_saleprice")
val proSaleprice: Int? = null,
@field:SerializedName("skt_lastupdate")
val sktLastupdate: String? = null,
@field:SerializedName("stk_outcode")
val stkOutcode: String? = null,
@field:SerializedName("pro_name")
val proName: String? = null
)
NetworkConfig().getProductListService()
.getProducts(stkOutcode = stkOutcodeValue)
....