Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Erroneous documentation: finding a User by email doesn't work as expected #257

Open
ndemengel opened this issue Jun 7, 2019 · 2 comments

Comments

@ndemengel
Copy link

ndemengel commented Jun 7, 2019

Hi Intercom team!

The documentation is misleading regarding how to find a User by email.

Version info

  • intercom-java version: 2.8.0
  • Java version: 8

Expected behavior

According to the documentation, User.find(ImmutableMap.of("email", someEmail)) should return data for an existing User, or null if no User is found, in the same way as User.find(ImmutableMap.of("user_id", someId)) does.

Actual behavior

User.find(ImmutableMap.of("email", someEmail)) returns a User object containing no data. When debugging, we can observe the the result returned by the API is a collection of users rather than a single user, and that the attempt made by the library to map this collection onto a User.class logically fails.

Workaround for the impatient

    UserCollection result = User.list(ImmutableMap.of("email", userEmail));
    List<User> page = result.getPage();
    if (page.size() > 1) {
        log.warn("Several users found for email {}", userEmail);
    }
    User user = page.isEmpty() ? null : page.get(0);
    // do something with user

I thank you in advance if you can find some time to fix either the library or the documentation.

Regards,
Nicolas

@Khyme
Copy link

Khyme commented Nov 13, 2019

Same problem, a fix would b e much appreciated

@rickerbh
Copy link

I pinged Intercom about this specific issue - they confirmed to me that the SDK (and API) don't work as advertised. The API behaviour is correct, and the SDK/documentation needs to be updated to remove this. The workaround they suggested to me was to the same as Nicolas'.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants