Search in sources :

Example 1 with DeviceOperationException

use of com.fitpay.android.paymentdevice.DeviceOperationException in project fitpay-android-sdk by fitpay.

the class Device method getAllCommits.

/**
 * Retrieves 'all' events that should be committed to this device.
 *
 * @param lastCommitId last commit id
 * @return observable
 */
public Observable<Collections.CommitsCollection> getAllCommits(final String lastCommitId) {
    return Observable.create(new Observable.OnSubscribe<Collections.CommitsCollection>() {

        @Override
        public void call(Subscriber<? super Collections.CommitsCollection> subscriber) {
            getAllCommits(lastCommitId, new ApiCallback<Collections.CommitsCollection>() {

                @Override
                public void onSuccess(Collections.CommitsCollection result) {
                    if (result == null) {
                        subscriber.onError(new Exception("commits result is null"));
                        return;
                    }
                    subscriber.onNext(result);
                    subscriber.onCompleted();
                }

                @Override
                public void onFailure(@ResultCode.Code int errorCode, String errorMessage) {
                    subscriber.onError(new DeviceOperationException(errorMessage, errorCode));
                }
            });
        }
    });
}
Also used : ApiCallback(com.fitpay.android.api.callbacks.ApiCallback) Collections(com.fitpay.android.api.models.collection.Collections) Observable(rx.Observable) DeviceOperationException(com.fitpay.android.paymentdevice.DeviceOperationException) DeviceOperationException(com.fitpay.android.paymentdevice.DeviceOperationException)

Example 2 with DeviceOperationException

use of com.fitpay.android.paymentdevice.DeviceOperationException in project fitpay-android-sdk by fitpay.

the class Device method getLastAckCommit.

/**
 * Retrieves last event that was committed to this device.
 *
 * @return observable
 */
public Observable<Commit> getLastAckCommit() {
    return Observable.create(subscriber -> getLastAckCommit(new ApiCallback<Commit>() {

        @Override
        public void onSuccess(Commit result) {
            subscriber.onNext(result);
            subscriber.onCompleted();
        }

        @Override
        public void onFailure(@ResultCode.Code int errorCode, String errorMessage) {
            subscriber.onError(new DeviceOperationException(errorMessage, errorCode));
        }
    }));
}
Also used : ApiCallback(com.fitpay.android.api.callbacks.ApiCallback) DeviceOperationException(com.fitpay.android.paymentdevice.DeviceOperationException)

Example 3 with DeviceOperationException

use of com.fitpay.android.paymentdevice.DeviceOperationException in project fitpay-android-sdk by fitpay.

the class User method getAllCreditCards.

/**
 * Retrieves 'all' credit cards
 *
 * @return observable
 */
public Observable<Collections.CreditCardCollection> getAllCreditCards() {
    return Observable.create(new Observable.OnSubscribe<Collections.CreditCardCollection>() {

        @Override
        public void call(Subscriber<? super Collections.CreditCardCollection> subscriber) {
            getAllCreditCards(new ApiCallback<Collections.CreditCardCollection>() {

                @Override
                public void onSuccess(Collections.CreditCardCollection result) {
                    if (result == null) {
                        subscriber.onError(new Exception("cards result is null"));
                        return;
                    }
                    subscriber.onNext(result);
                    subscriber.onCompleted();
                }

                @Override
                public void onFailure(@ResultCode.Code int errorCode, String errorMessage) {
                    subscriber.onError(new DeviceOperationException(errorMessage, errorCode));
                }
            });
        }
    });
}
Also used : ApiCallback(com.fitpay.android.api.callbacks.ApiCallback) Collections(com.fitpay.android.api.models.collection.Collections) Observable(rx.Observable) DeviceOperationException(com.fitpay.android.paymentdevice.DeviceOperationException) DeviceOperationException(com.fitpay.android.paymentdevice.DeviceOperationException)

Aggregations

ApiCallback (com.fitpay.android.api.callbacks.ApiCallback)3 DeviceOperationException (com.fitpay.android.paymentdevice.DeviceOperationException)3 Collections (com.fitpay.android.api.models.collection.Collections)2 Observable (rx.Observable)2