All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.firstdata.clovergo.domain.usecase.GetInventory Maven / Gradle / Ivy

package com.firstdata.clovergo.domain.usecase;

import com.firstdata.clovergo.domain.model.Catalog;
import com.firstdata.clovergo.domain.model.EmployeeMerchant;
import com.firstdata.clovergo.domain.model.Error;
import com.firstdata.clovergo.domain.model.UseCaseConstants;
import com.firstdata.clovergo.domain.repository.MerchantRepository;

import javax.inject.Inject;

import io.reactivex.Observable;

import static com.firstdata.clovergo.domain.utils.DomainConstants.ERROR_CODE_NO_EMPLOYEE_LOGGED_IN;
import static com.firstdata.clovergo.domain.utils.DomainConstants.ERROR_MESSAGE_NO_EMPLOYEE_LOGGED_IN;


/**
 * Created by Arjun Chinya on 6/20/16.
 */

public class GetInventory extends UseCase {
    @Inject
    public GetInventory(MerchantRepository repository) {
        super(repository);
    }

    public Observable getObservable(boolean forceRefresh) {
        repository.log("get inventory");
        final EmployeeMerchant employeeMerchant = repository.retrieveFromCache(UseCaseConstants.EMPLOYEE_MERCHANT);

        if (employeeMerchant == null) {
            return Observable.error(new Error(ERROR_CODE_NO_EMPLOYEE_LOGGED_IN, ERROR_MESSAGE_NO_EMPLOYEE_LOGGED_IN));
        } else {
            return repository.getInventory(employeeMerchant.getEmployee().getId(), employeeMerchant.getMerchant().getId(), employeeMerchant.getEmployee().getSessionToken(),forceRefresh);
        }
    }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy