Skip to content

Instantly share code, notes, and snippets.

@ppicas
Created June 19, 2018 10:47
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ppicas/6db13c35ffa958ae4302225d2f416617 to your computer and use it in GitHub Desktop.
Save ppicas/6db13c35ffa958ae4302225d2f416617 to your computer and use it in GitHub Desktop.
interface StuartApi {
@GET("/v2/jobs/{id}")
fun getJob(@Path("id") jobId: String): Single<ApiJob>
@GET("/v2/jobs")
fun getJobs(
@Query("page") page: Int,
@Query("per_page") perPage: Int
): Single<List<ApiJob>>
}
class ApiJobRepository(private val api: StuartApi): JobRepository {
override fun getJob(jobId: String): Observable<Job> {
return api.getJob(jobId)
.map(ModelMapper::mapApiJob)
.toObservable()
}
override fun getJobs(page: Int): Single<List<Job>> {
return api.getJobs(page, JOBS_PER_PAGE)
.map({ it.map(ModelMapper::mapApiJob) })
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment