I have Implemented RAAS(Registration as a service) with gigya for Hybris eCommerce platform. There are other source of registration as well so wanted to get details fro user profile via email id.
Below are code snippet.
import com.fasterxml.jackson.databind.DeserializationFeature
import com.fasterxml.jackson.databind.ObjectMapper
import com.gigya.socialize.GSObject
import com.gigya.socialize.GSResponse
import de.hybris.platform.cms2.model.site.CMSSiteModel
import de.hybris.platform.gigya.gigyaservices.api.exception.GigyaApiException
import de.hybris.platform.gigya.gigyaservices.constants.GigyaservicesConstants
import de.hybris.platform.gigya.gigyaservices.utils.GigyaUtils
import de.hybris.platform.store.BaseStoreModel
import de.hybris.platform.util.Config
def gigyaLoginService = spring.getBean('gigyaLoginService')
def baseStoreService = spring.getBean('baseStoreService')
def gigyaService = spring.getBean('gigyaService')
BaseStoreModel baseStoreModel = baseStoreService.getBaseStoreForUid('electronics');
CMSSiteModel cmsSiteModel = baseStoreModel.getCmsSites().stream().findFirst().get()
final ObjectMapper mapper = new ObjectMapper();
mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
mapper.configure(DeserializationFeature.ACCEPT_SINGLE_VALUE_AS_ARRAY, true);
final Map<String, Object> params = new LinkedHashMap<>();
params.put("profile.email", "[email protected]");
params.put("extraProfileFields", Config.getString("gigya.extra.fields","languages,address,phones,education,honors,publications,patents,certifications,professionalHeadline,bio,industry,specialties,work,skills,religion,politicalView,interestedIn,relationshipStatus,hometown,favorites,followersCount,followingCount,username,locale,verified,timezone,likes"));
params.put("include",Config.getString("gigya.basic.include", "loginIDs,emails,profile,data,preferences,groups"));
// Add environment details to getAccountInfo call
params.put("environment", GigyaUtils.getEnvironmentDetails());
final GSObject gigyaParams = convertMapToGsObject(mapper, params);
println("Gigya profile search parameters:: "+gigyaParams);
final GSResponse res = gigyaService.callRawGigyaApiWithConfigAndObject("accounts.search", gigyaParams,
cmsSiteModel.getGigyaConfig(), GigyaservicesConstants.MAX_RETRIES, GigyaservicesConstants.TRY_NUM);
println(res)
def GSObject convertMapToGsObject(final ObjectMapper mapper, final Map<String, Object> parms)
{
GSObject gigyaParams = new GSObject();
try
{
gigyaParams = new GSObject(mapper.writeValueAsString(parms));
}
catch (final Exception e)
{
final String msg = "Error creating gigya request parmeters";
println(e)
throw new GigyaApiException(msg);
}
return gigyaParams;
}
But getting exception below.
Script execution has failed [reason: de.hybris.platform.gigya.gigyaservices.api.exception.GigyaApiException: Invalid parameter value]
I don't find any reference to get user profile details via email id.
You can make a
accounts.search
REST call to get the profile details. This link also has a Java code sample and its child link has many examples of the query. In your case, yourwhere
condition will be like this:I hope you already use the application key and secret or a bearer token when sending requests. Remember that each REST API request must contain identification and authorization parameters.