This repository was archived by the owner on Mar 17, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 8
Expand file tree
/
Copy pathtclient.go
More file actions
45 lines (41 loc) · 1.34 KB
/
tclient.go
File metadata and controls
45 lines (41 loc) · 1.34 KB
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
package gtoggl
import (
"github.com/dougEfresh/gtoggl-api/gtclient"
"github.com/dougEfresh/gtoggl-api/gthttp"
"github.com/dougEfresh/gtoggl-api/gtproject"
"github.com/dougEfresh/gtoggl-api/gttimentry"
"github.com/dougEfresh/gtoggl-api/gtuser"
"github.com/dougEfresh/gtoggl-api/gtworkspace"
)
// Client is an Toggl REST client. Created by calling NewClient.
type TogglClient struct {
TogglHttpClient *gthttp.TogglHttpClient
WorkspaceClient *gtworkspace.WorkspaceClient
ProjectClient *gtproject.ProjectClient
TClient *gtclient.TClient
UserClient *gtuser.UserClient
TimeentryClient *gttimeentry.TimeEntryClient
}
// Return a new TogglHttpClient . An error is also returned when some configuration option is invalid
// tc,err := gtoggl.NewClient("token")
func NewClient(key string, options ...gthttp.ClientOptionFunc) (*TogglClient, error) {
// Set up the client
c, err := gthttp.NewClient(key, options...)
if err != nil {
return nil, err
}
th := &TogglClient{TogglHttpClient: c,
WorkspaceClient: gtworkspace.NewClient(c),
UserClient: gtuser.NewClient(c),
ProjectClient: gtproject.NewClient(c),
TClient: gtclient.NewClient(c),
TimeentryClient: gttimeentry.NewClient(c),
}
// Run the options on it
for _, option := range options {
if err := option(c); err != nil {
return nil, err
}
}
return th, nil
}