func (l *Lights) GetLight(light_id int) Light { url := fmt.Sprintf(get_light_url, l.Hostname, l.Username, light_id) response := util.HttpGet(url) var light Light json.Unmarshal(response, &light) light.Id = light_id return light }
func (g *Groups) GetGroup(group_number int) GroupState { url := fmt.Sprintf(get_group_url, g.Hostname, g.Username, group_number) response := util.HttpGet(url) var gg GroupState gg.Id = group_number json.Unmarshal(response, &gg) return gg }
func (l *Lights) GetAllLights() []Light { url := fmt.Sprintf(get_all_lights_url, l.Hostname, l.Username) response := util.HttpGet(url) lights_map := map[string]Light{} json.Unmarshal(response, &lights_map) lights := make([]Light, 0, len(lights_map)) for light_id, light := range lights_map { light.Id, _ = strconv.Atoi(light_id) lights = append(lights, light) } return lights }
func (g *Groups) GetGroups() []Group { url := fmt.Sprintf(get_groups_url, g.Hostname, g.Username) response := util.HttpGet(url) groups_map := map[string]Group{} json.Unmarshal(response, &groups_map) groups := make([]Group, 0, len(groups_map)) for group_id, group := range groups_map { group.Id, _ = strconv.Atoi(group_id) groups = append(groups, group) } return groups }
func GetPortal() []Portal { response := util.HttpGet(portal_url) var api_response []Portal json.Unmarshal(response, &api_response) return api_response }