...
1 package types
2
3 type Target struct {
4 Projectid string `json:"projectid"`
5 Bannerid string `json:"bannerid"`
6 Storeid string `json:"storeid"`
7 Terminalid string `json:"terminalid"`
8 }
9
10 func (target Target) ProjectID() string { return target.Projectid }
11 func (target Target) BannerID() string { return target.Bannerid }
12 func (target Target) StoreID() string { return target.Storeid }
13 func (target Target) TerminalID() string { return target.Terminalid }
14
15 func (target *Target) validate() error {
16 var errs ValidationErr
17
18 if target.Projectid == "" {
19 errs = append(errs, userError{
20 errNilProjectID,
21 "Target missing project ID",
22 })
23 }
24 if target.Bannerid == "" {
25 errs = append(errs, userError{
26 errNilBannerID,
27 "Target missing Banner ID",
28 })
29 }
30 if target.Storeid == "" {
31 errs = append(errs, userError{
32 errNilStoreID,
33 "Target missing Store ID",
34 })
35 }
36 if target.Terminalid == "" {
37 errs = append(errs, userError{
38 errNilTerminalID,
39 "Target missing Terminal ID",
40 })
41 }
42
43 if len(errs) != 0 {
44 return errs
45 }
46 return nil
47 }
48
49 type AuthDetails struct {
50 DarkMode bool `json:"darkmode"`
51 }
52
View as plain text