-
Notifications
You must be signed in to change notification settings - Fork 0
/
time_create.go
70 lines (52 loc) · 2.15 KB
/
time_create.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 gofastbill
import (
"errors"
)
type TimeCreate_Request struct {
CUSTOMER_ID string `xml:"CUSTOMER_ID,omitempty" json:"CUSTOMER_ID,omitempty"` // Required Eine bestimmte Kundennummer
PROJECT_ID string `xml:"PROJECT_ID,omitempty" json:"PROJECT_ID,omitempty"` // Required Eine bestimmte Projekt ID
DATE string `xml:"DATE,omitempty" json:"DATE,omitempty"` // Datum
TASK_ID string `xml:"TASK_ID,omitempty" json:"TASK_ID,omitempty"` // ID einer bestimmten Aufgabe
START_TIME string `xml:"START_TIME,omitempty" json:"START_TIME,omitempty"` // Required Startzeit
END_TIME string `xml:"END_TIME,omitempty" json:"END_TIME,omitempty"` // Endzeit
MINUTES string `xml:"MINUTES,omitempty" json:"MINUTES,omitempty"` // Minuten
BILLABLE_MINUTES string `xml:"BILLABLE_MINUTES,omitempty" json:"BILLABLE_MINUTES,omitempty"` // Abrechenbare Minuten
COMMENT string `xml:"COMMENT,omitempty" json:"COMMENT,omitempty"` // Bemerkung
}
//Create a new Time.
//FILTER => All fields from Struct: gofastbill.TimeCreate_Request
//Required: CUSTOMER_ID, PRJOJECT_ID, START_TIME
//RESPONSE:
//STATUS, TIME_ID
func (s *Initialization) Time_create(req TimeCreate_Request) (*FBAPI, error) {
var fastbillbody string
var r FBAPI
if req.CUSTOMER_ID == "" {
return nil, errors.New(s.Typ + ": Missing CUSTOMER_ID ")
}
if req.PROJECT_ID == "" {
return nil, errors.New(s.Typ + ": Missing PROJECT_ID ")
}
if req.START_TIME == "" {
return nil, errors.New(s.Typ + ": Missing START_TIME ")
}
r.SERVICE = "time.create"
r.DATA.CUSTOMER_ID = req.CUSTOMER_ID
r.DATA.PROJECT_ID = req.PROJECT_ID
r.DATA.DATE = req.DATE
r.DATA.TASK_ID = req.TASK_ID
r.DATA.START_TIME = req.START_TIME
r.DATA.END_TIME = req.END_TIME
r.DATA.MINUTES = req.MINUTES
r.DATA.BILLABLE_MINUTES = req.BILLABLE_MINUTES
r.DATA.COMMENT = req.COMMENT
fastbillbody, err := s.GenerateRequest(r)
if err != nil {
return nil, err
}
resp, err := s.FastbillRequest(fastbillbody)
if err != nil {
return nil, err
}
return resp, nil
}