Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/kotlin/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android Kotlin翻新查询注释参数_Android_Kotlin_Retrofit - Fatal编程技术网

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)
    ....