package client import ( "errors" "fmt" "strconv" ) func (c *YatsClient) PositionList(source string, from int64, to int64) string { if from == 0 { panic("From is empty") } var body string if to == 0 { body = "{\"source\": \"" + source + "\", \"from\":" + strconv.FormatInt(from, 10) + " }" } else { body = "{\"source\": \"" + source + "\", \"from\":" + strconv.FormatInt(from, 10) + ",\"to\":" + strconv.FormatInt(to, 10) + " }" } //fmt.Printf("request: [%s]\n", body) return c.ApiPost(c.Config.Endpoint+"/position/search", body) } func (c *YatsClient) PositionSave(positionName string, lat float64, lon float64, ptime int64) (string, error) { if positionName == "" { //fmt.Println("Metric Name is empty") return "", errors.New("position name is empty") } if lat == 0 && lon == 0 { //fmt.Println("Metric Name is empty") return "", errors.New("Lat/Lon was 0,0") } var body string if ptime == 0 { body = "{ \"name\":\"" + positionName + "\", \"lat\": " + strconv.FormatFloat(lat, 'f', -1, 64) + ", \"lon\":" + strconv.FormatFloat(lon, 'f', -1, 64) + " }" } else { body = "{ \"name\":\"" + positionName + ", \"lat\": " + strconv.FormatFloat(lat, 'f', -1, 64) + ", \"lon\":" + strconv.FormatFloat(lon, 'f', -1, 64) + ", \"ptime\":\"" + strconv.FormatInt(ptime, 10) + "\" }" } fmt.Printf("payload: [%s]\n", body) return c.ApiPost(c.Config.Endpoint+"/position", body), nil }