diff --git a/main.go b/main.go index 74ef8cd..28b2c79 100644 --- a/main.go +++ b/main.go @@ -12,6 +12,7 @@ import ( "github.com/supanadit/geo-smart-system/model/tile38" "log" "net/http" + "strings" ) func main() { @@ -86,7 +87,8 @@ func main() { hookID := "HOOK-" + xid.New().String() fmt.Printf("Set HOOK with ID : %s \n", hookID) hookURL := "http://192.168.99.1:" + port + "/detection/call" - client.Do("SETHOOK", hookID, hookURL, "NEARBY", detection.Type, "FENCE", "DETECT", "enter", "COMMANDS", "set", "POINT", detection.Lat, detection.Lng) + trigger := strings.Join(detection.TriggerType, ",") + client.Do("SETHOOK", hookID, hookURL, "NEARBY", detection.Type, "FENCE", "DETECT", trigger, "COMMANDS", "set", "POINT", detection.Lat, detection.Lng) var status map[string]interface{} var httpStatus int if err != nil { diff --git a/model/detection.go b/model/detection.go index 8ac7395..e7f7d32 100644 --- a/model/detection.go +++ b/model/detection.go @@ -1,18 +1,17 @@ package model -type Trigger string - +// Trigger Type const ( - inside Trigger = "inside" // when an object is inside the specified area - outside Trigger = "outside" // when an object is outside the specified area - enter Trigger = "enter" // when an object that was not previously in the fence has entered the area - exit Trigger = "exit" // when an object that was previously in the fence has exited the area - cross Trigger = "cross" // when an object that was not previously in the fence has entered and exited the area + inside string = "inside" // when an object is inside the specified area + outside string = "outside" // when an object is outside the specified area + enter string = "enter" // when an object that was not previously in the fence has entered the area + exit string = "exit" // when an object that was previously in the fence has exited the area + cross string = "cross" // when an object that was not previously in the fence has entered and exited the area ) type Detection struct { - Type string `json:"type"` - Lat string `json:"lat"` - Lng string `json:"lng"` - TriggerType []Trigger `json:"trigger_type"` + Type string `json:"type"` + Lat string `json:"lat"` + Lng string `json:"lng"` + TriggerType []string `json:"trigger"` }