-
Notifications
You must be signed in to change notification settings - Fork 1
/
account.go
68 lines (56 loc) · 1.5 KB
/
account.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 toshl
import (
"net/url"
"strconv"
"time"
)
// Account represents a Toshl account
type Account struct {
ID string `json:"id"`
Name string `json:"name"`
Balance float64 `json:"balance"`
InitialBalance float64 `json:"initial_balance"`
Currency Currency `json:"currency"`
Median Median `json:"median"`
Status string `json:"status"`
Order int `json:"order"`
Modified string `json:"modified"`
Goal Goal `json:"goal"`
}
// AccountQueryParams represents a struct of parameters usable
// to List Accounts
type AccountQueryParams struct {
Page int
PerPage int
Since time.Time
Status string
IncludeDeleted bool
}
func (a *AccountQueryParams) getQueryString() string {
v := url.Values{}
if a.Page > 0 {
v.Set("page", strconv.Itoa(a.Page))
}
if a.PerPage > 0 {
v.Set("per_page", strconv.Itoa(a.PerPage))
}
if !a.Since.IsZero() {
v.Set("since", a.Since.Format("2006-01-02T15:04:05Z"))
}
if a.Status != "" {
v.Set("status", a.Status)
}
if a.IncludeDeleted {
v.Set("include_deleted", strconv.FormatBool(a.IncludeDeleted))
}
return v.Encode()
}
// AccountsOrderParams describes the order we want for the accounts
type AccountsOrderParams struct {
Order []string `json:"order"`
}
// AccountsMergeParams describes how we want to merge the accounts
type AccountsMergeParams struct {
Accounts []string `json:"accounts"`
Account string `json:"account"`
}