Skip to content

Commit

Permalink
Include people example (#12)
Browse files Browse the repository at this point in the history
* Include people API examples - Thank you Jose!
  • Loading branch information
Jose Bogarín Solano authored and cmlccie committed Oct 3, 2016
1 parent 710aea8 commit 8a358e0
Showing 1 changed file with 36 additions and 0 deletions.
36 changes: 36 additions & 0 deletions examples/people.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
""" Script to demostrate the use of ciscosparkapi for the people API
The package natively retrieves your Spark access token from the
SPARK_ACCESS_TOKEN environment variable. You must have this environment
variable set to run this script.
"""


from __future__ import print_function
from ciscosparkapi import CiscoSparkAPI


try:
api = CiscoSparkAPI() # Create a CiscoSparkAPI connection object; uses your SPARK_ACCESS_TOKEN
except Exception as e:
print(e)


# Get my user information
print("Get my information ...")
me = api.people.me()
print(me)

# Get my user information using id
print("Get my information but using id ...")
me_by_id = api.people.get(me.id)
print(me_by_id)

# Get my user information using id
print("Get the list of people I know ...")
people = api.people.list(displayName="Jose") # Creates a generator container (iterable) that lists the people I know
for person in people:
print(person.displayName) # Return the displayName of every person found

0 comments on commit 8a358e0

Please sign in to comment.