public async Task <PublicData> Get(LocationBoundry boundry) { string url = string.Format( "{0}?access_token={1}&lat_ne={2}&lon_ne={3}&lat_sw={4}&lon_sw={5}&filter={6}", _uri, _authenticationToken.Token, boundry.NorthEast.Latitude, boundry.NorthEast.Longitude, boundry.SouthWest.Latitude, boundry.SouthWest.Longitude, false); Trace.WriteLine("NE:" + boundry.NorthEast); Trace.WriteLine("SW:" + boundry.SouthWest); try { var result = await _httpWrapper.ReadGet <PublicDataResponse>(url); return(Map(result)); } catch (Exception ex) { Trace.WriteLine("Url: " + url); throw new Exception("Error getting public data.", ex); } }
public async Task <List <SensorMeasurement> > Get(string deviceId, Module module) { string type = GetMeasurementType(module); string scale = "max"; string url = string.Format( "{0}?access_token={1}&device_id={2}&module_id={3}&type={4}&scale={5}", _uri, _authenticationToken.Token, deviceId, module.Id, type, scale); // Optional. long dateBegin = DateTime.UtcNow.AddHours(-4).ToUnixTicks(); url += string.Format("&date_begin={0}", dateBegin); // Optional //long dateEnd = 1347556500; //url += string.Format("&date_end={0}", dateEnd); var measureResponse = await _httpWrapper.ReadGet <MeasureResponse>(url); return(Map(measureResponse.body, type)); }
public async Task <PublicData> Get(LocationBoundry boundry) { string url = string.Format(CultureInfo.InvariantCulture, "{0}?access_token={1}&lat_ne={2}&lon_ne={3}&lat_sw={4}&lon_sw={5}&filter={6}", _uri, _authenticationToken.Token, boundry.NorthEast.Latitude, boundry.NorthEast.Longitude, boundry.SouthWest.Latitude, boundry.SouthWest.Longitude, false); Trace.WriteLine("NE:" + boundry.NorthEast); Trace.WriteLine("SW:" + boundry.SouthWest); return(await _httpWrapper .ReadGet <PublicDataResponse>(url) .ContinueWith(result => { if (result.IsCompleted && !result.IsFaulted) { return Map(result.Result); } Trace.WriteLine("Url: " + url); throw new Exception("Error getting public data.", result.Exception); })); }
public async Task <User> Get() { string url = string.Format("{0}?access_token={1}", _uri, _authenticationToken.Token); var userResponse = await _httpWrapper.ReadGet <UserResponse>(url); return(UserResponseMapper.Map(userResponse)); }
public async Task <StationDevices> Get() { string url = string.Format("{0}?access_token={1}&app_type=app_station", _uri, _authenticationToken.Token); var deviceListResponce = await _httpWrapper.ReadGet <DeviceListResponse>(url); //var client = new HttpClient(); //HttpResponseMessage response = client.GetAsync(url).Result; //if (!response.IsSuccessStatusCode) //{ // Trace.WriteLine("DevicesList Failed!"); // throw new NetatmoReadException("Failed to read devices. Status code: " + response.StatusCode); //} //var deviceListResponce = response.Content.ReadAsAsync<DeviceListResponse>().Result; return(DeviceMapper.Map(deviceListResponce.body)); }