Skip to content

Instantly share code, notes, and snippets.

View brettkelly's full-sized avatar

Brett Kelly brettkelly

View GitHub Profile
@brettkelly
brettkelly / example.py
Created February 25, 2013 19:21
findNotesMetadata example
filter = NoteStore.NoteFilter()
filter.ascending = False
spec = NoteStore.NotesMetadataResultSpec()
spec.includeTitle = True
ourNoteList = noteStore.findNotesMetadata(authToken, filter, 0, 100, spec)
tell application "System Events"
set _app to item 1 of (every process whose frontmost is true)
display dialog (name of _app as text)
end tell
# get list of notebooks linked to this account
linkedNotebooks = noteStore.listLinkedNotebooks(authToken)
bizLinkedNotebook = None
# grab the first business notebook for use in this example
for lnb in linkedNotebooks:
if hasattr(lnb, 'businessId'):
# this links a business notebook to our user's account
bizLinkedNotebook = lnb
print "Choosing notebook: %s" % bizLinkedNotebook.shareName
break
@brettkelly
brettkelly / example.py
Last active December 12, 2015 08:08
Creating an Evernote Business notebook and immediately linking it to the creator's account.
# Create the local notebook object
bizNotebook = Types.Notebook()
# Give it a name
bizNotebook.name = 'Example Business Notebook'
# Create the notebook using the business NoteStore
bizNotebook = bNoteStore.createNotebook(bAuthToken, bizNotebook)
# First, get the SharedNotebook instance for the notebook we just made
sharedBizNotebook = bizNotebook.sharedNotebooks[0]
# Create a LinkedNotebook instance
linkedBizNotebook = Types.LinkedNotebook()
# Get a list of all linked notebooks from the non-business
# NoteStore to which our user has access.
lNotebooks = noteStore.listLinkedNotebooks(authToken)
# compile a list of business notebooks from linked
# notebook list
bNotebooks = []
for (lnb in lNotebooks):
# all business notebooks will have `businessId` set
if hasattr(lnb, 'businessId'):
# First, get the SharedNotebook instance for the notebook we just made
# this represents our access to the notebook we just created
sharedBizNotebook = bizNotebook.sharedNotebooks[0]
# Create a LinkedNotebook instance
linkedBizNotebook = Types.LinkedNotebook()
# Assign it the share key and name of our business notebook
linkedBizNotebook.shareKey = sharedBizNotebook.shareKey
linkedBizNotebook.shareName = bizNotebook.name
# Assign the user who owns the notebook
linkedBizNotebook.username = bAuthResult.user.username
# Create the local notebook object
bizNotebook = Types.Notebook()
# Give it a name
bizNotebook.name = 'Sample Business Notebook'
# Create the notebook
bizNotebook = bNoteStore.createNotebook(bAuthToken, bizNotebook)
# Update the notebook with a BusinessNotebook member
bizNotebook.businessNotebook = Types.BusinessNotebook()
# Provide a description which will appear in the library
bizNotebook.businessNotebook.notebookDescription = "My Awesome Sample Business Notebook"
linkedNotebooks = noteStore.listLinkedNotebooks(authToken)
for lnb in linkedNotebooks:
op = lnb.shareName
if hasattr(lnb, 'businessId'):
op += " -- Business"
print op
bSharedNotebooks = bNoteStore.listSharedNotebooks(bAuthToken)
print "You have access to %d shared notebooks in this business account." % len(bSharedNotebooks)
bAuthToken = bAuthResult.authenticationToken
bNoteStore = getNoteStoreInstance(bAuthToken, userStore) # function defined earlier
bSharedNotebooks = bNoteStore.listSharedNotebooks(bAuthToken)
print "There are %d shared notebooks in this business account." % len(bSharedNotebooks)