package ch.pizzalemon.android.model.cart;

import java.io.Serializable;
import java.util.ArrayList;

import ch.pizzalemon.android.api.ApiConstants;

/**
 * Created by cimenmus on 05/10/2017.
 */

public class CartInfoModel implements Serializable {

    private ArrayList<CartProductModel> products;
    private ArrayList<CartTotalModel> totals;
    private boolean isPizzaPassCampaignUsed;

    public ArrayList<CartProductModel> getProducts() {
        return products;
    }

    public void setProducts(ArrayList<CartProductModel> products) {
        this.products = products;
    }

    /*
    public ArrayList<CartTotalModel> getTotals() {
        return totals;
    }

    public void setTotals(ArrayList<CartTotalModel> totals) {
        this.totals = totals;
    }
    */

    public CartTotalModel getCartTotalModel(){
        CartTotalModel cartTotalModel = null;
        for(CartTotalModel crtTtl : totals){
            if(crtTtl.getTitle().toLowerCase().equals(ApiConstants.CART_TOTAL)){
                cartTotalModel = crtTtl;
                break;
            }
        }
        if(cartTotalModel == null){
            cartTotalModel = totals.get(0);
        }
        return cartTotalModel;
    }

    public ArrayList<CartTotalModel> getTotalsList() {
        return totals;
    }

    public void checkNull(){
        if(products == null){
            products = new ArrayList<>();
        }
        if(totals == null){
            totals = new ArrayList<>();
        }
        CartProductModel.checkNull(products);

    }

    public boolean isPizzaPassCampaignUsed() {
        return isPizzaPassCampaignUsed;
    }

    public void setPizzaPassCampaignUsed(boolean pizzaPassCampaignUsed) {
        isPizzaPassCampaignUsed = pizzaPassCampaignUsed;
    }
}
