// Path: app/src/main/java/apidez/com/databinding/model/api/IPurchaseApi.java
// public interface IPurchaseApi {
//     Observable<Boolean> submitPurchase(String creditCard, String email);
// }
// 
// Path: app/src/main/java/apidez/com/databinding/utils/NumericUtils.java
// public class NumericUtils {
//     /**
//      * Check if a string is Integer
//      */
//     public static boolean isNumeric(String number) {
//         return number.matches("-?\\d+(\\.\\d+)?");
//     }
// 
//     /**
//      * Check if a string is Integer
//      */
//     public static boolean isNumeric(CharSequence number) {
//         return isNumeric(number.toString());
//     }
// }
// 
// Path: app/src/main/java/apidez/com/databinding/utils/StringUtils.java
// public class StringUtils {
// 
//     /**
//      * Generate random string
//      */
//     public static String generateString(String characters, int length) {
//         Random rand = new Random();
//         char[] text = new char[length];
//         for (int i = 0; i < length; i++) {
//             text[i] = characters.charAt(rand.nextInt(characters.length()));
//         }
//         return new String(text);
//     }
// 
//     /**
//      * Check empty string
//      */
//     public static boolean isEmpty(String string) {
//         return string == null || string.isEmpty();
//     }
// }


import android.databinding.BaseObservable;
import android.databinding.ObservableBoolean;
import android.databinding.ObservableInt;
import android.support.annotation.NonNull;
import java.util.concurrent.TimeUnit;
import apidez.com.databinding.R;
import apidez.com.databinding.model.api.IPurchaseApi;
import apidez.com.databinding.utils.NumericUtils;
import apidez.com.databinding.utils.StringUtils;
    public PurchaseViewModel(@NonNull IPurchaseApi purchaseApi) {
        mPurchaseApi = purchaseApi;
    }

    @Override
    public ObservableInt creditCardError() {
        return mCreditCardError;
    }

    @Override
    public ObservableInt emailError() {
        return mEmailError;
    }

    @Override
    public ObservableBoolean canSubmit() {
        return mCanSubmit;
    }

    @Override
    public void setCreditCard(String newCreditCard) {
        if (StringUtils.isEmpty(newCreditCard)) return;
        mCreditCard = newCreditCard;
        mCreditCardValid = newCreditCard.length() == 12 && NumericUtils.isNumeric(newCreditCard);
        mCreditCardError.set(mCreditCardValid ? R.string.empty : R.string.error_credit_card);
        updateCanSubmit();
    }

    @Override
    public void setEmail(String newEmail) {
// Path: app/src/main/java/apidez/com/databinding/model/api/IPurchaseApi.java
// public interface IPurchaseApi {
//     Observable<Boolean> submitPurchase(String creditCard, String email);
// }
// 
// Path: app/src/main/java/apidez/com/databinding/utils/NumericUtils.java
// public class NumericUtils {
//     /**
//      * Check if a string is Integer
//      */
//     public static boolean isNumeric(String number) {
//         return number.matches("-?\\d+(\\.\\d+)?");
//     }
// 
//     /**
//      * Check if a string is Integer
//      */
//     public static boolean isNumeric(CharSequence number) {
//         return isNumeric(number.toString());
//     }
// }
// 
// Path: app/src/main/java/apidez/com/databinding/utils/StringUtils.java
// public class StringUtils {
// 
//     /**
//      * Generate random string
//      */
//     public static String generateString(String characters, int length) {
//         Random rand = new Random();
//         char[] text = new char[length];
//         for (int i = 0; i < length; i++) {
//             text[i] = characters.charAt(rand.nextInt(characters.length()));
//         }
//         return new String(text);
//     }
// 
//     /**
//      * Check empty string
//      */
//     public static boolean isEmpty(String string) {
//         return string == null || string.isEmpty();
//     }
// }


// Path: app/src/main/java/apidez/com/databinding/viewmodel/PurchaseViewModel.java
import android.databinding.BaseObservable;
import android.databinding.ObservableBoolean;
import android.databinding.ObservableInt;
import android.support.annotation.NonNull;
import java.util.concurrent.TimeUnit;
import apidez.com.databinding.R;
import apidez.com.databinding.model.api.IPurchaseApi;
import apidez.com.databinding.utils.NumericUtils;
import apidez.com.databinding.utils.StringUtils;

    public PurchaseViewModel(@NonNull IPurchaseApi purchaseApi) {
        mPurchaseApi = purchaseApi;
    }

    @Override
    public ObservableInt creditCardError() {
        return mCreditCardError;
    }

    @Override
    public ObservableInt emailError() {
        return mEmailError;
    }

    @Override
    public ObservableBoolean canSubmit() {
        return mCanSubmit;
    }

    @Override
    public void setCreditCard(String newCreditCard) {
        if (StringUtils.isEmpty(newCreditCard)) return;
        mCreditCard = newCreditCard;
        mCreditCardValid = newCreditCard.length() == 12 && NumericUtils.isNumeric(newCreditCard);
        mCreditCardError.set(mCreditCardValid ? R.string.empty : R.string.error_credit_card);
        updateCanSubmit();
    }

    @Override
    public void setEmail(String newEmail) {
        if (StringUtils.isEmpty(newEmail)) return;