fun getProductById()

in app/src/main/java/co/elastic/apm/opbeans/app/data/source/product/RemoteProductSource.kt [45:62]


    fun getProductById(id: Int, callback: (Result<ProductDetail>) -> Unit) {
        opBeansService.getProductById(id).enqueue(object : Callback<RemoteProductDetail> {
            override fun onResponse(
                call: Call<RemoteProductDetail>,
                response: Response<RemoteProductDetail>
            ) {
                if (response.isSuccessful) {
                    callback.invoke(Result.success(remoteToProductDetail(response.body()!!)))
                } else {
                    callback.invoke(Result.failure(HttpException(response)))
                }
            }

            override fun onFailure(call: Call<RemoteProductDetail>, t: Throwable) {
                callback.invoke(Result.failure(t))
            }
        })
    }