-
Notifications
You must be signed in to change notification settings - Fork 1
/
multasgt.go
46 lines (39 loc) · 1.04 KB
/
multasgt.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
package multasgt
import (
"regexp"
"strings"
"golang.org/x/net/html"
)
var cleanStringsRegex = regexp.MustCompile(`[\t\n\r]`)
// Ticket represents the information related to the ticket.
type Ticket struct {
ID string `json:"id"`
Entity string `json:"entity"`
Date string `json:"date"`
Amount string `json:"amount"`
Discount string `json:"discount"`
Total string `json:"total"`
Location string `json:"location"`
Info string `json:"info"`
Photo string `json:"photo"`
}
// TicketChecker is the interface that all checkers must implement.
type TicketChecker interface {
Check(plateType, plateNumber string) ([]Ticket, error)
}
// GetAttribute gets an attribute from an HTML node.
func GetAttribute(attrName string, n *html.Node) string {
if n == nil {
return ""
}
for i, a := range n.Attr {
if a.Key == attrName {
return n.Attr[i].Val
}
}
return ""
}
// CleanStrings removes any white unnecessary whitespace
func CleanStrings(s string) string {
return cleanStringsRegex.ReplaceAllString(strings.TrimSpace(s), "")
}