Skip to content

Instantly share code, notes, and snippets.

@ClaudeHangui
Created May 23, 2021 12:37
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 ClaudeHangui/a0d5aa035d6bc885dd564bf2f2f632b8 to your computer and use it in GitHub Desktop.
Save ClaudeHangui/a0d5aa035d6bc885dd564bf2f2f632b8 to your computer and use it in GitHub Desktop.
Repository which provides the various payment methods used by financial service companies
package com.changui.payoneerhomeexercise.data;
import com.changui.payoneerhomeexercise.domain.PaymentMethodUIModel;
import com.changui.payoneerhomeexercise.domain.PaymentMethodRepository;
import com.changui.payoneerhomeexercise.domain.SchedulersFacade;
import java.util.List;
import javax.inject.Inject;
import io.reactivex.Single;
public class PaymentMethodRepositoryImpl implements PaymentMethodRepository {
private final ApiService apiService;
private final GetPaymentMethodsMapper paymentMethodsMapper;
private final SchedulersFacade schedulersFacade;
@Inject
public PaymentMethodRepositoryImpl(ApiService apiService, GetPaymentMethodsMapper mapper, SchedulersFacade facade) {
this.apiService = apiService;
this.paymentMethodsMapper = mapper;
this.schedulersFacade = facade;
}
@Override
public Single<List<PaymentMethodUIModel>> getPaymentMethods() {
return apiService.getPaymentMethods()
.map(paymentMethodsMapper::mapToUI)
.subscribeOn(schedulersFacade.provideIO())
.observeOn(schedulersFacade.provideUIThread());
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment