Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 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) })
- }
- }
Add Comment
Please, Sign In to add comment