Guest User

Untitled

a guest
Jun 20th, 2018
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.65 KB | None | 0 0
  1. interface StuartApi {
  2.  
  3. @GET("/v2/jobs/{id}")
  4. fun getJob(@Path("id") jobId: String): Single<ApiJob>
  5.  
  6. @GET("/v2/jobs")
  7. fun getJobs(
  8. @Query("page") page: Int,
  9. @Query("per_page") perPage: Int
  10. ): Single<List<ApiJob>>
  11.  
  12. }
  13.  
  14. class ApiJobRepository(private val api: StuartApi): JobRepository {
  15.  
  16. override fun getJob(jobId: String): Observable<Job> {
  17. return api.getJob(jobId)
  18. .map(ModelMapper::mapApiJob)
  19. .toObservable()
  20. }
  21.  
  22. override fun getJobs(page: Int): Single<List<Job>> {
  23. return api.getJobs(page, JOBS_PER_PAGE)
  24. .map({ it.map(ModelMapper::mapApiJob) })
  25. }
  26.  
  27. }
Add Comment
Please, Sign In to add comment