-
Notifications
You must be signed in to change notification settings - Fork 10
/
freshbooks.go
68 lines (56 loc) · 1.38 KB
/
freshbooks.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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
package main
import (
"fmt"
"github.com/toggl/go-freshbooks"
"os"
)
type FreshbooksService struct {
workspaceID int
AccountID int
AccessToken string
}
func (s *FreshbooksService) Name() string {
return "freshbooks"
}
func (s *FreshbooksService) WorkspaceID() int {
return s.workspaceID
}
func (s *FreshbooksService) keyFor(objectType string) string {
return fmt.Sprintf("freshbooks:%s", objectType)
}
func (s *FreshbooksService) setAuthData(a *Authorization) {
}
func (s *FreshbooksService) setAccount(accountID int) {
s.AccountID = accountID
}
func (s *FreshbooksService) Accounts() ([]*Account, error) {
return nil, nil
}
func (s *FreshbooksService) Users() ([]*User, error) {
account := os.Getenv("FRESHBOOKS_ACCOUNT")
token := os.Getenv("FRESHBOOKS_TOKEN")
apiClient := freshbooks.NewApi(account, token)
foreignObjects, err := apiClient.Users()
if err != nil {
return nil, err
}
var users []*User
for _, object := range foreignObjects {
user := User{
ForeignID: object.UserId,
Name: fmt.Sprintf("%s %s", object.FirstName, object.LastName),
Email: object.Email,
}
users = append(users, &user)
}
return users, nil
}
func (s *FreshbooksService) Projects() ([]*Project, error) {
return nil, nil
}
func (s *FreshbooksService) TodoLists() ([]*Task, error) {
return nil, nil
}
func (s *FreshbooksService) Tasks() ([]*Task, error) {
return nil, nil
}