-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmain-model.go
48 lines (41 loc) · 1.61 KB
/
main-model.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 main
import "google.golang.org/genproto/googleapis/type/latlng"
type Conference struct {
Name string `firestore:"name"`
Location string `firestore:"location"`
PictureUrl string `firestore:"picture_url"`
Flag string `firestore:"flag"`
Continent string `firestore:"continent"`
Coords *latlng.LatLng `firestore:"coords"`
StartDate string `firestore:"start_date"`
EndDate string `firestore:"end_date"`
Tz string `firestore:"tz"`
Url string `firestore:"url"`
SponsoredFrom string `firestore:"sponsored_from"`
SponsoredTo string `firestore:"sponsored_to"`
SponsoredType SponsoredType `firestore:"sponsored_type"`
PromoCode string `firestore:"promo_code"`
PromoCodeDiscount string `firestore:"promo_code_discount"`
}
type SponsoredType string
const (
SponsoredTypeCardFrame SponsoredType = "card_frame"
SponsoredTypeCardTop SponsoredType = "card_top"
SponsoredTypeNone SponsoredType = "" // For null or no match
)
func (c Conference) IsSponsoredTop() bool {
return c.SponsoredType == SponsoredTypeCardTop
}
func (c Conference) IsPromoted() bool {
return c.PromoCode != ""
}
func ParseSponsoredType(value string) SponsoredType {
switch value {
case string(SponsoredTypeCardFrame):
return SponsoredTypeCardFrame
case string(SponsoredTypeCardTop):
return SponsoredTypeCardTop
default:
return SponsoredTypeNone // If the value doesn't match, return null equivalent
}
}