-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathtypes.go
39 lines (33 loc) · 903 Bytes
/
types.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
package fluyt
import (
"strings"
"time"
)
type Person struct {
Email string `json:"email"`
Roaming string `json:"roaming"` // "" if signed in via Shibboleth
}
type Photo struct {
Small string `json:"small"`
Large string `json:"large"`
}
type Listing struct {
Permalink string `json:"key"`
Title string `json:"title"`
Body string `json:"body"`
Seller *Person `json:"seller,omitempty"`
Price float32 `json:"price"`
Categories []string `json:"categories"`
Approved bool `json:"approved"`
Sold bool `json:"sold"`
LastUpdate time.Time `json:"lastUpdate"`
Photos []Photo `json:"photos"`
}
func (l *Listing) Key() string {
return l.Permalink
}
func (l *Listing) Match(query string) bool {
q := strings.ToLower(query)
return (strings.Contains(strings.ToLower(l.Title), q) ||
strings.Contains(strings.ToLower(l.Body), q))
}