-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathparticipant.go
51 lines (44 loc) · 1.8 KB
/
participant.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
49
50
51
package amiando
import "fmt"
type Participant struct {
Event *Event `json:"-"`
PaymentID ID `json:"-"`
PaymentUserID ID `json:"buyerId"` // payment
PaymentStatus PaymentStatus `json:"status"` // payment
InvoiceNumber string `json:"identifier"` // payment
CreatedDate string `json:"creationTime"` // payment
ModifiedDate string `json:"lastModified"` // payment
UserData []UserData `json:"userData"` // payment & ticket
TicketID ID `json:"-"`
FirstName string `json:"firstName"` // ticket
LastName string `json:"lastName"` // ticket
Email string `json:"email"` // ticket
CheckedDate string `json:"lastChecked"` // ticket
CancelledDate string `json:"cancelled"` // ticket
TicketType TicketType `json:"ticketType"` // ticket
RegistrationNumber string `json:"displayIdentifier"` // ticket
}
// Returns nil if no UserData with title is found
func (self *Participant) FindUserData(title string, restrictToTypes ...UserDataType) (userData *UserData, found bool) {
for _, u := range self.UserData {
if u.Title == title {
if len(restrictToTypes) == 0 {
return &u, true
} else {
for _, restrictToType := range restrictToTypes {
if u.Type == restrictToType {
return &u, true
}
}
}
}
}
return nil, false
}
func (self *Participant) FindRequiredUserData(title string, restrictToTypes ...UserDataType) (userData *UserData, err error) {
userData, found := self.FindUserData(title, restrictToTypes...)
if !found {
return nil, fmt.Errorf("Required UserData \"%s\" of participant \"%s %s\"<%s> not found", title, self.FirstName, self.LastName, self.Email)
}
return userData, nil
}