|
1
|
|
|
package model |
|
2
|
|
|
|
|
3
|
|
|
import "fmt" |
|
4
|
|
|
|
|
5
|
|
|
type ShowResponse struct { |
|
6
|
|
|
ID int64 `json:"id"` |
|
7
|
|
|
Name string `json:"name"` |
|
8
|
|
|
} |
|
9
|
|
|
|
|
10
|
|
|
type ShowListResponse struct { |
|
11
|
|
|
Response []ShowResponse `json:"response"` |
|
12
|
|
|
} |
|
13
|
|
|
|
|
14
|
|
|
func (s *ShowListResponse) ShowListResponseValidate() error { |
|
15
|
|
|
if len(s.Response) == 0 { |
|
16
|
|
|
return fmt.Errorf("empty response") |
|
17
|
|
|
} |
|
18
|
|
|
if s.Response[0].ID == 0 { |
|
19
|
|
|
return fmt.Errorf("%w: id", ErrRequired) |
|
|
|
|
|
|
20
|
|
|
} |
|
21
|
|
|
if s.Response[0].Name == "" { |
|
22
|
|
|
return fmt.Errorf("%w: name", ErrRequired) |
|
|
|
|
|
|
23
|
|
|
} |
|
24
|
|
|
return nil |
|
25
|
|
|
} |
|
26
|
|
|
|
|
27
|
|
|
type EventResponse struct { |
|
28
|
|
|
ID int64 `json:"id"` |
|
29
|
|
|
ShowID int64 `json:"showId"` |
|
30
|
|
|
Date string `json:"date"` |
|
31
|
|
|
} |
|
32
|
|
|
|
|
33
|
|
|
type EventListResponse struct { |
|
34
|
|
|
Response []EventResponse `json:"response"` |
|
35
|
|
|
} |
|
36
|
|
|
|
|
37
|
|
|
func (e *EventListResponse) EventListResponseValidate() error { |
|
38
|
|
|
if len(e.Response) == 0 { |
|
39
|
|
|
return fmt.Errorf("empty response") |
|
40
|
|
|
} |
|
41
|
|
|
if e.Response[0].ID == 0 { |
|
42
|
|
|
return fmt.Errorf("%w: id", ErrRequired) |
|
|
|
|
|
|
43
|
|
|
} |
|
44
|
|
|
if e.Response[0].ShowID == 0 { |
|
45
|
|
|
return fmt.Errorf("%w: showId", ErrRequired) |
|
|
|
|
|
|
46
|
|
|
} |
|
47
|
|
|
if e.Response[0].Date == "" { |
|
48
|
|
|
return fmt.Errorf("%w: date", ErrRequired) |
|
|
|
|
|
|
49
|
|
|
} |
|
50
|
|
|
return nil |
|
51
|
|
|
} |
|
52
|
|
|
|
|
53
|
|
|
type PlaceResponse struct { |
|
54
|
|
|
ID int64 `json:"id"` |
|
55
|
|
|
X float64 `json:"x"` |
|
56
|
|
|
Y float64 `json:"y"` |
|
57
|
|
|
Width float64 `json:"width"` |
|
58
|
|
|
Height float64 `json:"height"` |
|
59
|
|
|
IsAvailable bool `json:"is_available"` // nolint: tagliatelle |
|
60
|
|
|
} |
|
61
|
|
|
|
|
62
|
|
|
type PlaceListResponse struct { |
|
63
|
|
|
Response []PlaceResponse `json:"response"` |
|
64
|
|
|
} |
|
65
|
|
|
|
|
66
|
|
|
func (p *PlaceListResponse) PlaceListResponseValidate() error { |
|
67
|
|
|
if len(p.Response) == 0 { |
|
68
|
|
|
return fmt.Errorf("empty response") |
|
69
|
|
|
} |
|
70
|
|
|
if p.Response[0].ID == 0 { |
|
71
|
|
|
return fmt.Errorf("%w: id", ErrRequired) |
|
|
|
|
|
|
72
|
|
|
} |
|
73
|
|
|
if p.Response[0].X < 0 { |
|
74
|
|
|
return fmt.Errorf("%w: x", ErrNegative) |
|
|
|
|
|
|
75
|
|
|
} |
|
76
|
|
|
if p.Response[0].Y < 0 { |
|
77
|
|
|
return fmt.Errorf("%w: y", ErrNegative) |
|
|
|
|
|
|
78
|
|
|
} |
|
79
|
|
|
if p.Response[0].Width < 0 { |
|
80
|
|
|
return fmt.Errorf("%w: width", ErrNegative) |
|
|
|
|
|
|
81
|
|
|
} |
|
82
|
|
|
if p.Response[0].Height < 0 { |
|
83
|
|
|
return fmt.Errorf("%w: height", ErrNegative) |
|
|
|
|
|
|
84
|
|
|
} |
|
85
|
|
|
return nil |
|
86
|
|
|
} |
|
87
|
|
|
|