-
Notifications
You must be signed in to change notification settings - Fork 0
/
README.txt
76 lines (64 loc) · 2.84 KB
/
README.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
PyHuddle
========
PyHuddle is a module that attempts to abstract away the wire protocol. The problem with hard coded URI's is that they may change.
The only URI that you can rely on is the one you just got from the server. Huddle provides means of navigating between workspaces and folders and documents
by navigating the links that get returned in the folders structure. PyHuddle uses this navigation to work so no matter what changes on the backend
your front end application should still work. Furthermore PyHuddle does not depend on any HTTP library. Simply plug in your HTTP library of choice,
and create a HTTPAdapter by extending the Adapter class. Look at HTTPlib2Adapter which is an adapter for the HTTPlib2 library on an example of how
to do this
PyHuddle supports the following:
1. OAuth with OOB. The HandleAccessToken class will manage retriving, saving, and refreshing of your tokens.
2. Full access to the folder Api
3. Full access to the documents Api
4. Full access to the workspace Api
5. Full access to the user + actor Api
6. Full access to the workspace calandars api (Workspace Calandar)
7. Full access to the tasks Api
Setup
=====
Setup is simple.
Create your OAuth details by [contacting Huddle](https://code.google.com/p/huddle-apis/wiki/OauthIntegration#Registering_your_client)
Create a .ini File that looks like this
```
[OAUTH2]
redirectUri =
clientID =
clientSecret =
[OAUTH2ENDPOINT]
huddleAuthServer = http://login.huddle.net/
huddleAccessTokenServer = http://login.huddle.dev/net/
[API]
accept = application/vnd.huddle.data+json
huddleApiServer = http://api.huddle.net/
huddleCalandarServer = http://api.huddle.net/v2/calendar/workspaces/
huddleTaskServer = http://api.huddle.net/v2/calendar/events/
```
If you are not using OOB for OAuth this isn't much of a problem. You simply need to create your own getAccessToken function
and then when you instantiate the handleAccessToken class you can plug in your function there
Usage
====
```
adapter = AdapterHttpUrlLib() #your http library implementation
config = Config("filePath").config #reads your config file
tokenHandler = HandleAccessToken(adapter, config) #gets you an access token looks at file, if can't find grabs from web, looks to see if expired
client = HuddleClient(tokenHandler, adapter, config) #start our api and hit /entry/
#get your workspaces
workSpaceList = client.getWorkspaces()
#get the 1st folder in the 4th workspace
folder = workSpaceList.getWorkspaceEntry().getFolders()[0]
#get a document
document = folder.getDocuments[0]
```
```
#delete the folder
folder.deleteFolder()
#restore the folder
folder.restoreFolder()
#move the folder
folder.moveTo(folderB obj)
#download the document
document.download()
#upload a new version of the document
document.uploadNewVersion(fileObject)
```
you get the idea