This repository has been archived by the owner on Mar 21, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
transactions.go
47 lines (40 loc) · 1.61 KB
/
transactions.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
package dbapi
import (
"fmt"
"net/http"
)
// The TransactionsService binds to the HTTP endpoints which belong to
// the transactions resource.
type TransactionsService struct {
client *Client
}
// Transactions are the users transactions.
type Transactions []struct {
OriginIBAN string `json:"originIban,omitempty"`
Amount float64 `json:"amount,omitempty"`
CounterPartyName string `json:"counterPartyName,omitempty"`
CounterPartyIBAN string `json:"counterPartyIban,omitempty"`
Usage string `json:"usage,omitempty"`
BookingDate string `json:"bookingDate,omitempty"`
}
// GetAll reads all transactions of all accounts of the current user. It is
// not apparent who issued a transaction, only whether the user gained or lost
// money by it (based on whether the amount is positive or negative
// respectively).
func (s *TransactionsService) GetAll() (*Transactions, *Response, error) {
u := "/transactions"
r := new(Transactions)
resp, err := s.client.Call(http.MethodGet, u, nil, r)
return r, resp, err
}
// Get all transactions for a specific account of the current user. If given
// IBAN is not valid or does not represent an account of the current user, an
// empty result is returned. It is not apparent who issued a transaction, only
// whether the user gained or lost money by it (based on whether the amount is
// positive or negative respectively).
func (s *TransactionsService) Get(iban string) (*Transactions, *Response, error) {
u := fmt.Sprintf("/transactions?iban=%s", iban)
r := new(Transactions)
resp, err := s.client.Call(http.MethodGet, u, nil, r)
return r, resp, err
}