-
Notifications
You must be signed in to change notification settings - Fork 0
/
invoice.go
48 lines (38 loc) · 960 Bytes
/
invoice.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
package smartcharge
import (
"net/http"
"strconv"
)
type InvoiceService struct {
client *Client
}
type InvoiceResult struct {
Result Data `json:"Result"`
}
type Data struct {
Data InvoiceData `json:"datas"`
Success bool `json:"sucess"`
}
type InvoiceData struct {
Invoices []Invoice
}
type Invoice struct {
Id int `json:"PK_InvoiceID"`
TotalPrice float64 `json:"TotalPrice"`
TotalVAT float64 `json:"TotalVAT"`
DateIssued string `json:"DateIssued"`
TotalKWH float64 `json:"TotalKWH"`
}
func (i *InvoiceService) GetInvoices(customerId int) (*InvoiceResult, *http.Response, error) {
reqUrl := "v2/Invoices/GetInvoicesByCustomer/" + strconv.Itoa(customerId)
req, err := i.client.NewRequest("GET", reqUrl, nil)
if err != nil {
return nil, nil, err
}
invoiceResult := &InvoiceResult{}
resp, err := i.client.Do(req, invoiceResult)
if err != nil {
return nil, resp, err
}
return invoiceResult, resp, err
}