This repository was archived by the owner on Dec 9, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathexamples_test.go
More file actions
100 lines (82 loc) · 2.08 KB
/
examples_test.go
File metadata and controls
100 lines (82 loc) · 2.08 KB
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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
package form3api_test
import (
"context"
"fmt"
"github.com/screwyprof/form3api"
)
func ExampleClient_CreateAccount() {
c := form3api.NewClient(nil, "http://localhost:8080/v1")
accountID := "51646a03-a52e-4e51-b405-cf2b8078c1a8"
acc, err := c.CreateAccount(context.Background(), form3api.CreateAccount{
AccountData: form3api.AccountData{
ID: accountID,
OrganisationID: "eb0bd6f5-c3f5-44b2-b677-acd23cdde73c",
Type: "accounts",
Attributes: &form3api.AccountAttributes{
AccountNumber: "10000004",
BankID: "400302",
BankIDCode: "GBDSC",
Country: "GB",
Currency: "GBP",
CustomerID: "234",
IBAN: "GB28NWBK40030212764204",
BIC: "NWBKGB42",
ConfirmationOfPayee: &form3api.ConfirmationOfPayee{
AccountClassification: "Personal",
},
},
},
})
if err != nil {
fmt.Println(err)
return
}
fmt.Printf("Account created: %v\n", acc)
}
func ExampleClient_FetchAccount() {
c := form3api.NewClient(nil, "http://localhost:8080/v1")
r := form3api.FetchAccount{
AccountID: "51646a03-a52e-4e51-b405-cf2b8078c1a8",
}
acc, err := c.FetchAccount(context.Background(), r)
if err != nil {
fmt.Println(err)
return
}
fmt.Printf("Account fetched: %v\n", acc)
}
func ExampleClient_DeleteAccount() {
c := form3api.NewClient(nil, "http://localhost:8080/v1")
r := form3api.DeleteAccount{
AccountID: "51646a03-a52e-4e51-b405-cf2b8078c1a8",
}
err := c.DeleteAccount(context.Background(), r)
if err != nil {
fmt.Println(err)
return
}
fmt.Println("Account deleted")
}
func ExampleClient_ListAccounts() {
c := form3api.NewClient(nil, "http://localhost:8080/v1")
r := form3api.ListAccounts{
Page: form3api.Page{Size: 2},
}
var accounts []form3api.AccountData
for {
res, err := c.ListAccounts(context.Background(), r)
if err != nil {
return
}
accounts = append(accounts, res.AccountData...)
if res.Links.Next == "" {
break
}
num, err := res.Links.NextPageNum()
if err != nil {
return
}
r.Page.Number = num
}
fmt.Printf("Accounts: %v\n", accounts)
}