forked from joefitzgerald/forecast
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathaggregate.go
66 lines (56 loc) · 2.32 KB
/
aggregate.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
package forecast
import "fmt"
type remainingBudgetedHoursContainer struct {
RemainingBudgetedHours RemainingBudgetedHours `json:"remaining_budgeted_hours"`
}
// RemainingBudgetedHours is a list of remaining budgeted hours items
type RemainingBudgetedHours []RemainingBudgetedHoursItem
// RemainingBudgetedHoursItem is an aggregate representing the remaining budgeted
// hours for the given Forecast project
type RemainingBudgetedHoursItem struct {
ProjectID int `json:"project_id"`
BudgetBy string `json:"budget_by"`
Hours float64 `json:"hours"`
ResponseCode int `json:"response_code"`
}
// RemainingBudgetedHours returns the remaining budgeted hours for all
// Forecast projects
func (api *API) RemainingBudgetedHours() (RemainingBudgetedHours, error) {
var container remainingBudgetedHoursContainer
err := api.do("aggregate/remaining_budgeted_hours", &container)
if err != nil {
return nil, err
}
return container.RemainingBudgetedHours, nil
}
type futureScheduledHoursContainer struct {
FutureScheduledHours FutureScheduledHours `json:"future_scheduled_hours"`
}
// FutureScheduledHours is a list of future scheduled hours items
type FutureScheduledHours []FutureScheduledHoursItem
// FutureScheduledHoursItem is a representation of the future scheduled hours for a project
type FutureScheduledHoursItem struct {
ProjectID int `json:"project_id"`
PersonID int `json:"person_id"`
Allocation float64 `json:"allocation"`
}
// FutureScheduledHours returns all future scheduled hours using the supplied
// date as the starting point
func (api *API) FutureScheduledHours(from string) (FutureScheduledHours, error) {
var container futureScheduledHoursContainer
err := api.do(fmt.Sprintf("aggregate/future_scheduled_hours/%s", from), &container)
if err != nil {
return nil, err
}
return container.FutureScheduledHours, nil
}
// FutureScheduledHoursForProject returns all future scheduled hours for the
// given project using the supplied date as the starting point
func (api *API) FutureScheduledHoursForProject(from string, projectid int) (FutureScheduledHours, error) {
var container futureScheduledHoursContainer
err := api.do(fmt.Sprintf("aggregate/future_scheduled_hours/%s?project_id=%v", from, projectid), &container)
if err != nil {
return nil, err
}
return container.FutureScheduledHours, nil
}