forked from ggordan/go-onedrive
-
Notifications
You must be signed in to change notification settings - Fork 0
/
onedrive.go
47 lines (41 loc) · 999 Bytes
/
onedrive.go
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
package onedrive
import (
"net/http"
"time"
)
const (
version = "0.1"
baseURL = "https://api.onedrive.com/v1.0"
)
// OneDrive is the entry point for the client. It manages the communication with
// Microsoft OneDrive API
type OneDrive struct {
Client *http.Client
// When debug is set to true, the JSON response is formatted for better readability
Debug bool
BaseURL string
// Services
Drives *DriveService
Items *ItemService
SearchService SearchService
Sites SiteService
// Private
throttle time.Time
}
// New returns a new OneDrive client to enable you to communicate with
// the API
func New(c *http.Client) *OneDrive {
drive := OneDrive{
Client: c,
BaseURL: baseURL,
throttle: time.Now(),
}
drive.Drives = &DriveService{&drive}
drive.Items = &ItemService{&drive}
drive.SearchService = searchService{&drive}
drive.Sites = siteService{&drive}
return &drive
}
func (od *OneDrive) throttleRequest(time time.Time) {
od.throttle = time
}