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

Missing docs for the awesome scroll api #212

Open
AlmogCohen opened this issue May 20, 2019 · 2 comments
Open

Missing docs for the awesome scroll api #212

AlmogCohen opened this issue May 20, 2019 · 2 comments

Comments

@AlmogCohen
Copy link

It seems to be already part of the package, but is missing from the docs.

@PiAir
Copy link

PiAir commented May 4, 2020

Since it took me ages to figure it out, I thought I would give something back by sharing the code that I used to finally get it to work. I can successfully retrieve the data of 13,000+ users with this:

INTERCOM_API_TOKEN = "XXXXXXXX"
from intercom.client import Client
intercom_session = Client(personal_access_token=INTERCOM_API_TOKEN)

try:
    myscroll = intercom_session.users.scroll()
    i = 1
    for user in myscroll:
        print(str(i) + ' ' + user.name + ' ' + user.email)
        i += 1   
except:
    print("An exception occurred, could not get scroll")

(update: the next(myscroll) statement was not needed)

A few things I noted when I converted my users = intercom_session.users.find(order="desc", sort="last_request_at") code to the scroll() code:

  • before I would do myuser = users.users[i] and then myuser['user_id'] etc. that has changed to myser.user_id format.
  • myuser['created_at'] would then be returned as an integer, while now myuser.created_at is returned as a datetime object. With myuser.created_at.timestamp() I can get the Unix timestamp again.
  • if myuser.last_request_at is None then myuser.last_request_at.timestamp() returns an error.
  • myuser.created_at.strftime('%Y-%m-%d %H:%M:%S') returns nice readable format time.

@wagmiwiz
Copy link

Came here searching for page/scroll api issues (even though I know this SDK is not maintained) and found this. Thanks @PiAir 🙏🏻

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