-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmonzo.go
52 lines (43 loc) · 939 Bytes
/
monzo.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
package main
import "fmt"
// Transaction created from Monzo
type Transaction struct {
Type string
Data Data
}
// Data of the transaction
type Data struct {
Amount int
Currency string
Description string
Category string
Merchant Merchant
}
// Merchant info
type Merchant struct {
Name string
}
func (t Transaction) description() string {
return t.Data.Description
}
func (t Transaction) amount() float64 {
return float64(t.Data.Amount) / float64(100)
}
func (t Transaction) currency() string {
return t.Data.Currency
}
func (t Transaction) category() string {
return t.Data.Category
}
func (t Transaction) merchantName() string {
return t.Data.Merchant.Name
}
func (t Transaction) String() string {
return fmt.Sprintf("\nType: %s\nDescription: %s\nMerchant: %s\nAmount: %.2f\nCurrency: %s\nCategory: %s\n",
t.Type,
t.description(),
t.merchantName(),
t.amount(),
t.currency(),
t.category())
}