Skip to content

Instantly share code, notes, and snippets.

@andijakl
Created January 24, 2019 21:07
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save andijakl/efc94fa3bdddd458c58f3ed12f926686 to your computer and use it in GitHub Desktop.
Save andijakl/efc94fa3bdddd458c58f3ed12f926686 to your computer and use it in GitHub Desktop.
Interface for a REST web service using Kotlin Coroutines for Retrofit
package com.andresjakl.partslist
import kotlinx.coroutines.Deferred
import retrofit2.Response
import retrofit2.http.*
interface PartsApiClient {
@GET("parts") fun getPartsAsync(): Deferred<Response<List<PartData>>>
@POST("parts") fun addPartAsync(@Body newPart : PartData): Deferred<Response<Void>>
@DELETE("parts/{id}") fun deletePartAsync(@Path("id") id: Long) : Deferred<Response<Void>>
@PUT("parts/{id}") fun updatePartAsync(@Path("id") id: Long, @Body newPart: PartData) : Deferred<Response<Void>>
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment