Created
June 19, 2018 10:47
-
-
Save ppicas/6db13c35ffa958ae4302225d2f416617 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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