-
Notifications
You must be signed in to change notification settings - Fork 0
/
timeslip.go
70 lines (58 loc) · 1.54 KB
/
timeslip.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
69
70
package freeagent
import (
"log"
"time"
)
type Timer struct {
Running bool `json:"running"`
StartFrom string `json:"start_from"`
}
type Timeslip struct {
URL string `json:"url,omitempty"`
Task string `json:"task"`
User string `json:"user"`
Project string `json:"project"`
DatedOn string `json:"dated_on"`
Hours string `json:"hours"`
Comment string `json:"comment"`
BilledOnInvoice string `json:"billed_on_invoice"`
CreatedAt string `json:"created_at"`
UpdatedAt string `json:"updated_at"`
Timer *Timer `json:"timer"`
}
type timeslipDTO struct {
Timeslip *Timeslip `json:"timeslip"`
}
func (c *Client) PostTimeslip(timeslip *Timeslip) (*Timeslip, error) {
request := ×lipDTO{timeslip}
response := ×lipDTO{}
err := c.post("/timeslips", request, response)
if err != nil {
return nil, err
}
return response.Timeslip, nil
}
func (c *Client) GetTimeslip(id string) (*Timeslip, error) {
result := ×lipDTO{}
err := c.get("/timeslips/"+id, result)
if err != nil {
return nil, err
}
return result.Timeslip, nil
}
type TimeslipView string
const (
TimeslipViewAll TimeslipView = "all"
TimeslipViewUnbilled TimeslipView = "unbilled"
TimeslipViewRunning TimeslipView = "running"
)
type TimeslipQuery struct {
FromDate time.Time
ToDate time.Time
UpdatedSince time.Time
View TimeslipView
}
func (c *Client) GetTimeslips(q *TimeslipQuery) ([]*Timeslip, error) {
log.Fatal("Not implemented")
return nil, nil
}