Search in sources :

Example 6 with ApiCallback

use of com.fitpay.android.api.callbacks.ApiCallback 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)6 DeviceOperationException (com.fitpay.android.paymentdevice.DeviceOperationException)3 UserStreamEvent (com.fitpay.android.api.models.UserStreamEvent)2 Collections (com.fitpay.android.api.models.collection.Collections)2 Device (com.fitpay.android.api.models.device.Device)2 UserEventStreamListener (com.fitpay.android.api.sse.UserEventStreamListener)2 SyncRequest (com.fitpay.android.paymentdevice.models.SyncRequest)2 Observable (rx.Observable)2 Activity (android.app.Activity)1 ApiManager (com.fitpay.android.api.ApiManager)1 SyncInitiator (com.fitpay.android.api.enums.SyncInitiator)1 CreditCard (com.fitpay.android.api.models.card.CreditCard)1 ECCKeyPair (com.fitpay.android.api.models.security.ECCKeyPair)1 User (com.fitpay.android.api.models.user.User)1 UserEventStreamManager (com.fitpay.android.api.sse.UserEventStreamManager)1 DeviceService (com.fitpay.android.paymentdevice.DeviceService)1 NotificationSyncRequest (com.fitpay.android.paymentdevice.events.NotificationSyncRequest)1 MockPaymentDeviceConnector (com.fitpay.android.paymentdevice.impl.mock.MockPaymentDeviceConnector)1 SyncInfo (com.fitpay.android.paymentdevice.models.SyncInfo)1 Command (com.fitpay.android.utils.Command)1