-
Notifications
You must be signed in to change notification settings - Fork 1
/
dijnet_test.go
43 lines (40 loc) · 952 Bytes
/
dijnet_test.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
package dijnet
import (
"fmt"
"os"
"strings"
"testing"
"time"
)
func TestThings(t *testing.T) {
username := os.Getenv("DIJNET_USERNAME")
password := os.Getenv("DIJNET_PASSWORD")
srv := NewService()
err := srv.Login(username, password)
if err != nil {
t.Fatalf("Unexpected error: %v", err)
}
providers, err := srv.Providers()
if err != nil {
t.Fatalf("Unexpected error: %v", err)
}
fmt.Println(providers)
query := InvoicesQuery{
From: time.Date(2020, 3, 1, 0, 0, 0, 0, time.UTC),
To: time.Date(2020, 4, 1, 0, 0, 0, 0, time.UTC),
}
invoices, err := srv.Invoices(query)
if err != nil {
t.Fatalf("Unexpected error: %v", err)
}
fmt.Printf("%+v", invoices)
for _, i := range invoices {
err = srv.DownloadInvoice(i,
"invoices/"+strings.Replace(i.InvoiceID, "/", "_", -1)+".pdf",
"invoices/"+strings.Replace(i.InvoiceID, "/", "_", -1)+".xml",
)
if err != nil {
t.Errorf("Unexpected error: %v", err)
}
}
}