]>
Commit | Line | Data |
---|---|---|
9b12e4fe JC |
1 | package statuscake |
2 | ||
a88e9b9b | 3 | import ( |
ccc9fb69 | 4 | "strconv" |
a88e9b9b AG |
5 | "strings" |
6 | ) | |
7 | ||
9b12e4fe JC |
8 | type autheticationErrorResponse struct { |
9 | ErrNo int | |
10 | Error string | |
11 | } | |
12 | ||
13 | type updateResponse struct { | |
14 | Issues interface{} `json:"Issues"` | |
15 | Success bool `json:"Success"` | |
16 | Message string `json:"Message"` | |
17 | InsertID int `json:"InsertID"` | |
18 | } | |
19 | ||
20 | type deleteResponse struct { | |
21 | Success bool `json:"Success"` | |
22 | Error string `json:"Error"` | |
23 | } | |
24 | ||
ccc9fb69 MS |
25 | type contactGroupDetailResponse struct { |
26 | ID int `json:"ID"` | |
27 | Name string `json:"Name"` | |
28 | Email string `json:"Email"` | |
29 | } | |
30 | ||
9b12e4fe | 31 | type detailResponse struct { |
ccc9fb69 MS |
32 | Method string `json:"Method"` |
33 | TestID int `json:"TestID"` | |
34 | TestType string `json:"TestType"` | |
35 | Paused bool `json:"Paused"` | |
36 | WebsiteName string `json:"WebsiteName"` | |
37 | URI string `json:"URI"` | |
38 | ContactID int `json:"ContactID"` | |
39 | ContactGroups []contactGroupDetailResponse `json:"ContactGroups"` | |
40 | Status string `json:"Status"` | |
41 | Uptime float64 `json:"Uptime"` | |
42 | CustomHeader string `json:"CustomHeader"` | |
43 | UserAgent string `json:"UserAgent"` | |
44 | CheckRate int `json:"CheckRate"` | |
45 | Timeout int `json:"Timeout"` | |
46 | LogoImage string `json:"LogoImage"` | |
47 | Confirmation int `json:"Confirmation,string"` | |
48 | WebsiteHost string `json:"WebsiteHost"` | |
49 | NodeLocations []string `json:"NodeLocations"` | |
50 | FindString string `json:"FindString"` | |
51 | DoNotFind bool `json:"DoNotFind"` | |
52 | LastTested string `json:"LastTested"` | |
53 | NextLocation string `json:"NextLocation"` | |
54 | Port int `json:"Port"` | |
55 | Processing bool `json:"Processing"` | |
56 | ProcessingState string `json:"ProcessingState"` | |
57 | ProcessingOn string `json:"ProcessingOn"` | |
58 | DownTimes int `json:"DownTimes,string"` | |
59 | Sensitive bool `json:"Sensitive"` | |
60 | TriggerRate int `json:"TriggerRate,string"` | |
61 | UseJar int `json:"UseJar"` | |
62 | PostRaw string `json:"PostRaw"` | |
63 | FinalEndpoint string `json:"FinalEndpoint"` | |
64 | FollowRedirect bool `json:"FollowRedirect"` | |
65 | StatusCodes []string `json:"StatusCodes"` | |
9b12e4fe JC |
66 | } |
67 | ||
68 | func (d *detailResponse) test() *Test { | |
ccc9fb69 MS |
69 | contactGroupIds := make([]string, len(d.ContactGroups)) |
70 | for i, v := range d.ContactGroups { | |
71 | contactGroupIds[i] = strconv.Itoa(v.ID) | |
72 | } | |
73 | ||
9b12e4fe | 74 | return &Test{ |
a88e9b9b AG |
75 | TestID: d.TestID, |
76 | TestType: d.TestType, | |
77 | Paused: d.Paused, | |
78 | WebsiteName: d.WebsiteName, | |
79 | WebsiteURL: d.URI, | |
80 | CustomHeader: d.CustomHeader, | |
81 | UserAgent: d.UserAgent, | |
82 | ContactID: d.ContactID, | |
ccc9fb69 | 83 | ContactGroup: contactGroupIds, |
a88e9b9b AG |
84 | Status: d.Status, |
85 | Uptime: d.Uptime, | |
86 | CheckRate: d.CheckRate, | |
87 | Timeout: d.Timeout, | |
88 | LogoImage: d.LogoImage, | |
89 | Confirmation: d.Confirmation, | |
90 | WebsiteHost: d.WebsiteHost, | |
91 | NodeLocations: d.NodeLocations, | |
92 | FindString: d.FindString, | |
93 | DoNotFind: d.DoNotFind, | |
94 | Port: d.Port, | |
95 | TriggerRate: d.TriggerRate, | |
96 | UseJar: d.UseJar, | |
97 | PostRaw: d.PostRaw, | |
98 | FinalEndpoint: d.FinalEndpoint, | |
99 | FollowRedirect: d.FollowRedirect, | |
100 | StatusCodes: strings.Join(d.StatusCodes[:], ","), | |
9b12e4fe JC |
101 | } |
102 | } |