001package com.gigya.android.sdk.interruption; 002 003import android.support.annotation.NonNull; 004 005import com.gigya.android.sdk.GigyaCallback; 006import com.gigya.android.sdk.GigyaDefinitions; 007import com.gigya.android.sdk.GigyaLoginCallback; 008import com.gigya.android.sdk.account.models.GigyaAccount; 009import com.gigya.android.sdk.api.GigyaApiResponse; 010import com.gigya.android.sdk.api.IBusinessApiService; 011import com.gigya.android.sdk.network.GigyaError; 012import com.gigya.android.sdk.network.adapter.RestAdapter; 013 014import java.util.Map; 015 016/** 017 * Helper class used to resolve flows that get interrupted with error "Account Pending Registration" (206001). 018 * Missing registration field will appear in the interruption "errorDetails" field. 019 * In order to resolve the flow you will need to set the missing account fields using the setAccount method. 020 * 021 * @param <A> Account scheme. 022 */ 023public class PendingRegistrationResolver<A extends GigyaAccount> extends Resolver<A> implements IPendingRegistrationResolver { 024 025 public PendingRegistrationResolver(GigyaLoginCallback<A> loginCallback, 026 GigyaApiResponse interruption, 027 IBusinessApiService<A> businessApiService) { 028 super(loginCallback, interruption, businessApiService); 029 } 030 031 @Override 032 public void setAccount(@NonNull Map<String, Object> missingAccountFields) { 033 // Reg token field is mandatory in order to resolve this issue. 034 missingAccountFields.put("regToken", getRegToken()); 035 // Using "send" method in order to avoid flow constraints in the regular "setAccount" BA. 036 _businessApiService.send( 037 GigyaDefinitions.API.API_SET_ACCOUNT_INFO, 038 missingAccountFields, 039 RestAdapter.POST, 040 GigyaApiResponse.class, 041 new GigyaCallback<GigyaApiResponse>() { 042 @Override 043 public void onSuccess(GigyaApiResponse obj) { 044 finalizeRegistration(null); 045 } 046 047 @Override 048 public void onError(GigyaError error) { 049 _loginCallback.onError(error); 050 } 051 }); 052 } 053}