Пример #1
0
        public HeartRateLog LogHeartRate(HeartRateLog log, string userId = null)
        {
            string userSignifier = "-"; // used for current user
            if (!string.IsNullOrWhiteSpace(userId))
            {
                userSignifier = userId;
            }

            string endPoint = string.Format("/1/user/{0}/heart.xml", userSignifier);
            RestRequest request = new RestRequest(endPoint, Method.POST);
            request.RootElement = "heartLog";

            AddPostParameter(request, "tracker", log.Tracker);
            AddPostParameter(request, "heartRate", log.HeartRate);
            AddPostParameter(request, "date", log.Time.ToString("yyyy-MM-dd"));
            AddPostParameter(request, "time", log.Time.ToString("HH:mm"));

            var response = restClient.Execute<HeartRateLog>(request);

            HandleResponse(response);

            return response.Data;
        }
Пример #2
0
        public void Log_Single_Heart_Rate_Today()
        {
            HeartRateLog log = new HeartRateLog
            {
                LogId = -1,
                HeartRate = 99,
                Time = DateTime.Now,
                Tracker = "Resting Heart Rate"
            };

            var expectedTime = new DateTime(log.Time.Year, log.Time.Month, log.Time.Day, log.Time.Hour, log.Time.Minute, 0);

            HeartRateLog response = client.LogHeartRate(log, null);
            Assert.AreEqual(log.HeartRate, response.HeartRate);
            Assert.AreNotEqual(-1, response.LogId);
            Assert.AreEqual(expectedTime, response.Time);
            Assert.AreEqual(log.Tracker, response.Tracker);
        }