package statuscake
import (
+ "strconv"
"strings"
)
Error string `json:"Error"`
}
+type contactGroupDetailResponse struct {
+ ID int `json:"ID"`
+ Name string `json:"Name"`
+ Email string `json:"Email"`
+}
+
type detailResponse struct {
- Method string `json:"Method"`
- TestID int `json:"TestID"`
- TestType string `json:"TestType"`
- Paused bool `json:"Paused"`
- WebsiteName string `json:"WebsiteName"`
- URI string `json:"URI"`
- ContactID int `json:"ContactID"`
- Status string `json:"Status"`
- Uptime float64 `json:"Uptime"`
- CustomHeader string `json:"CustomHeader"`
- UserAgent string `json:"UserAgent"`
- CheckRate int `json:"CheckRate"`
- Timeout int `json:"Timeout"`
- LogoImage string `json:"LogoImage"`
- Confirmation int `json:"Confirmation,string"`
- WebsiteHost string `json:"WebsiteHost"`
- NodeLocations []string `json:"NodeLocations"`
- FindString string `json:"FindString"`
- DoNotFind bool `json:"DoNotFind"`
- LastTested string `json:"LastTested"`
- NextLocation string `json:"NextLocation"`
- Port int `json:"Port"`
- Processing bool `json:"Processing"`
- ProcessingState string `json:"ProcessingState"`
- ProcessingOn string `json:"ProcessingOn"`
- DownTimes int `json:"DownTimes,string"`
- Sensitive bool `json:"Sensitive"`
- TriggerRate int `json:"TriggerRate,string"`
- UseJar int `json:"UseJar"`
- PostRaw string `json:"PostRaw"`
- FinalEndpoint string `json:"FinalEndpoint"`
- FollowRedirect bool `json:"FollowRedirect"`
- StatusCodes []string `json:"StatusCodes"`
+ Method string `json:"Method"`
+ TestID int `json:"TestID"`
+ TestType string `json:"TestType"`
+ Paused bool `json:"Paused"`
+ WebsiteName string `json:"WebsiteName"`
+ URI string `json:"URI"`
+ ContactID int `json:"ContactID"`
+ ContactGroups []contactGroupDetailResponse `json:"ContactGroups"`
+ Status string `json:"Status"`
+ Uptime float64 `json:"Uptime"`
+ CustomHeader string `json:"CustomHeader"`
+ UserAgent string `json:"UserAgent"`
+ CheckRate int `json:"CheckRate"`
+ Timeout int `json:"Timeout"`
+ LogoImage string `json:"LogoImage"`
+ Confirmation int `json:"Confirmation,string"`
+ WebsiteHost string `json:"WebsiteHost"`
+ NodeLocations []string `json:"NodeLocations"`
+ FindString string `json:"FindString"`
+ DoNotFind bool `json:"DoNotFind"`
+ LastTested string `json:"LastTested"`
+ NextLocation string `json:"NextLocation"`
+ Port int `json:"Port"`
+ Processing bool `json:"Processing"`
+ ProcessingState string `json:"ProcessingState"`
+ ProcessingOn string `json:"ProcessingOn"`
+ DownTimes int `json:"DownTimes,string"`
+ Sensitive bool `json:"Sensitive"`
+ TriggerRate int `json:"TriggerRate,string"`
+ UseJar int `json:"UseJar"`
+ PostRaw string `json:"PostRaw"`
+ FinalEndpoint string `json:"FinalEndpoint"`
+ FollowRedirect bool `json:"FollowRedirect"`
+ StatusCodes []string `json:"StatusCodes"`
}
func (d *detailResponse) test() *Test {
+ contactGroupIds := make([]string, len(d.ContactGroups))
+ for i, v := range d.ContactGroups {
+ contactGroupIds[i] = strconv.Itoa(v.ID)
+ }
+
return &Test{
TestID: d.TestID,
TestType: d.TestType,
CustomHeader: d.CustomHeader,
UserAgent: d.UserAgent,
ContactID: d.ContactID,
+ ContactGroup: contactGroupIds,
Status: d.Status,
Uptime: d.Uptime,
CheckRate: d.CheckRate,
// Test represents a statuscake Test
type Test struct {
- // ThiTestID is an int, use this to get more details about this test. If not provided will insert a new check, else will update
+ // TestID is an int, use this to get more details about this test. If not provided will insert a new check, else will update
TestID int `json:"TestID" querystring:"TestID" querystringoptions:"omitempty"`
// Sent tfalse To Unpause and true To Pause.
// A Port to use on TCP Tests
Port int `json:"Port" querystring:"Port"`
- // Contact group ID - will return int of contact group used else 0
- ContactID int `json:"ContactID" querystring:"ContactGroup"`
+ // Contact group ID - deprecated in favor of ContactGroup but still provided in the API detail response
+ ContactID int `json:"ContactID"`
+
+ // Contact group IDs - will return list of ints or empty if not provided
+ ContactGroup []string `json:"ContactGroup" querystring:"ContactGroup"`
// Current status at last test
Status string `json:"Status"`
TriggerRate int `json:"TriggerRate" querystring:"TriggerRate"`
// Tags should be seperated by a comma - no spacing between tags (this,is,a set,of,tags)
- TestTags string `json:"TestTags" querystring:"TestTags"`
+ TestTags []string `json:"TestTags" querystring:"TestTags"`
// Comma Seperated List of StatusCodes to Trigger Error on (on Update will replace, so send full list each time)
StatusCodes string `json:"StatusCodes" querystring:"StatusCodes"`
}
if !ur.Success {
- return nil, &updateError{Issues: ur.Issues}
+ return nil, &updateError{Issues: ur.Issues, Message: ur.Message}
}
t2 := *t