Search in sources :

Example 1 with RequestUserProfileSetRepresentative

use of net.iGap.request.RequestUserProfileSetRepresentative in project iGap-Android by KianIranian-STDG.

the class UserProfileViewModel method setRequestSetReferral.

public void setRequestSetReferral(String phoneNumber) {
    new RequestUserProfileSetRepresentative().userProfileSetRepresentative(phoneNumber, new OnUserProfileSetRepresentative() {

        @Override
        public void onSetRepresentative(String phone) {
            G.handler.post(() -> {
                if (!hasError) {
                    referralEnableLiveData.postValue(false);
                    referralNumberObservableField.set("");
                    showEditIcon();
                    isEditProfile = false;
                }
            });
        }

        @Override
        public void onErrorSetRepresentative(int majorCode, int minorCode) {
            G.handler.post(() -> {
                showReferralErrorLiveData.set(true);
                hasError = true;
                switch(majorCode) {
                    case 10177:
                        if (minorCode == 2) {
                            referralError.set(R.string.referral_error_yourself);
                        } else {
                            referralError.set(R.string.phone_number_is_not_valid);
                        }
                        break;
                    case 10178:
                        if (minorCode == 2)
                            referralError.set(R.string.already_registered);
                        else
                            referralError.set(R.string.server_error);
                        break;
                }
                referralNumberObservableField.set("");
            });
        }
    });
}
Also used : OnUserProfileSetRepresentative(net.iGap.observers.interfaces.OnUserProfileSetRepresentative) HelperString(net.iGap.helper.HelperString) RequestUserProfileSetRepresentative(net.iGap.request.RequestUserProfileSetRepresentative)

Aggregations

HelperString (net.iGap.helper.HelperString)1 OnUserProfileSetRepresentative (net.iGap.observers.interfaces.OnUserProfileSetRepresentative)1 RequestUserProfileSetRepresentative (net.iGap.request.RequestUserProfileSetRepresentative)1