Search in sources :

Example 1 with EndpointProfileUser

use of com.amazonaws.mobileconnectors.pinpoint.targeting.endpointProfile.EndpointProfileUser in project aws-sdk-android by aws-amplify.

the class EndpointProfileIntegrationTest method testEndpointProfileUpdate.

@Test
public void testEndpointProfileUpdate() {
    TargetingClient targetingClient = pinpointManager.getTargetingClient();
    assertNotNull(targetingClient);
    targetingClient.updateEndpointProfile();
    EndpointProfile endpointProfile = targetingClient.currentEndpoint();
    assertNotNull(endpointProfile);
    assertNull(endpointProfile.getUser().getUserId());
    assertNull(endpointProfile.getUser().getUserAttributes());
    EndpointProfileUser user = new EndpointProfileUser();
    user.setUserId(credentialsProvider.getIdentityId());
    user.addUserAttribute("user-key", Collections.singletonList("user-value"));
    endpointProfile.setUser(user);
    targetingClient.updateEndpointProfile();
    endpointProfile = targetingClient.currentEndpoint();
    assertNotNull(endpointProfile);
    assertEquals(credentialsProvider.getIdentityId(), endpointProfile.getUser().getUserId());
    assertNotNull(endpointProfile.getUser().getUserAttributes());
    assertEquals(Collections.singletonMap("user-key", Collections.singletonList("user-value")), endpointProfile.getUser().getUserAttributes());
    endpointProfile.addAttribute("key", Collections.singletonList("value"));
    targetingClient.updateEndpointProfile();
    endpointProfile = targetingClient.currentEndpoint();
    assertNotNull(endpointProfile);
    assertEquals(credentialsProvider.getIdentityId(), endpointProfile.getUser().getUserId());
    assertEquals(Collections.singletonList("value"), endpointProfile.getAllAttributes().get("key"));
}
Also used : EndpointProfileUser(com.amazonaws.mobileconnectors.pinpoint.targeting.endpointProfile.EndpointProfileUser) EndpointProfile(com.amazonaws.mobileconnectors.pinpoint.targeting.endpointProfile.EndpointProfile) TargetingClient(com.amazonaws.mobileconnectors.pinpoint.targeting.TargetingClient) Test(org.junit.Test)

Example 2 with EndpointProfileUser

use of com.amazonaws.mobileconnectors.pinpoint.targeting.endpointProfile.EndpointProfileUser in project aws-sdk-android by aws-amplify.

the class TargetingClientTest method updateEndpointEmptyUserId.

@Test
public void updateEndpointEmptyUserId() {
    final ArgumentCaptor<UpdateEndpointRequest> requestArgumentCaptor = ArgumentCaptor.forClass(UpdateEndpointRequest.class);
    EndpointProfile endpointProfile = new EndpointProfile(mockContext);
    EndpointProfileUser user = new EndpointProfileUser();
    user.setUserId("");
    endpointProfile.setUser(user);
    targetingClient.updateEndpointProfile(endpointProfile);
    verifyAndRunExecutorService(1);
    verify(mockPinpointServiceClient, times(1)).updateEndpoint(requestArgumentCaptor.capture());
    for (final UpdateEndpointRequest request : requestArgumentCaptor.getAllValues()) {
        assertNotNull(request.getEndpointRequest().getUser());
        assertEquals(request.getEndpointRequest().getUser().getUserId(), "");
    }
}
Also used : EndpointProfileUser(com.amazonaws.mobileconnectors.pinpoint.targeting.endpointProfile.EndpointProfileUser) EndpointProfile(com.amazonaws.mobileconnectors.pinpoint.targeting.endpointProfile.EndpointProfile) UpdateEndpointRequest(com.amazonaws.services.pinpoint.model.UpdateEndpointRequest) Test(org.junit.Test)

Example 3 with EndpointProfileUser

use of com.amazonaws.mobileconnectors.pinpoint.targeting.endpointProfile.EndpointProfileUser in project amplify-android by aws-amplify.

the class AWSPinpointAnalyticsPlugin method identifyUser.

@Override
public void identifyUser(@NonNull String userId, @Nullable UserProfile userProfile) {
    Objects.requireNonNull(userId);
    EndpointProfile endpointProfile = targetingClient.currentEndpoint();
    // Assign userId to the endpoint.
    EndpointProfileUser user = new EndpointProfileUser();
    user.setUserId(userId);
    if (userProfile instanceof AWSPinpointUserProfile) {
        AWSPinpointUserProfile pinpointUserProfile = (AWSPinpointUserProfile) userProfile;
        if (pinpointUserProfile.getUserAttributes() != null) {
            addUserAttributes(user, pinpointUserProfile.getUserAttributes());
        }
    }
    endpointProfile.setUser(user);
    // Add user-specific data to the endpoint
    if (userProfile != null) {
        addUserProfileToEndpoint(endpointProfile, userProfile);
    }
    // update endpoint
    targetingClient.updateEndpointProfile(endpointProfile);
}
Also used : EndpointProfileUser(com.amazonaws.mobileconnectors.pinpoint.targeting.endpointProfile.EndpointProfileUser) EndpointProfile(com.amazonaws.mobileconnectors.pinpoint.targeting.endpointProfile.EndpointProfile) AWSPinpointUserProfile(com.amplifyframework.analytics.pinpoint.models.AWSPinpointUserProfile)

Aggregations

EndpointProfile (com.amazonaws.mobileconnectors.pinpoint.targeting.endpointProfile.EndpointProfile)3 EndpointProfileUser (com.amazonaws.mobileconnectors.pinpoint.targeting.endpointProfile.EndpointProfileUser)3 Test (org.junit.Test)2 TargetingClient (com.amazonaws.mobileconnectors.pinpoint.targeting.TargetingClient)1 UpdateEndpointRequest (com.amazonaws.services.pinpoint.model.UpdateEndpointRequest)1 AWSPinpointUserProfile (com.amplifyframework.analytics.pinpoint.models.AWSPinpointUserProfile)1