Exemplo n.º 1
0
 public WaterLog LogWater(DateTime date, WaterLog log)
 {
     return LogWater(date, log, string.Empty);
 }
Exemplo n.º 2
0
        public WaterLog LogWater(DateTime date, WaterLog log, string userId)
        {
            string userSignifier = "-"; // used for current user
            if (!string.IsNullOrWhiteSpace(userId))
            {
                userSignifier = userId;
            }

            string endPoint = string.Format("/1/user/{0}/foods/log/water.json", userSignifier);
            RestRequest request = new RestRequest(endPoint, Method.POST);
            request.RootElement = "waterLog";
            AddPostParameter(request, "amount", log.Amount);
            AddPostParameter(request, "date", date.ToString("yyyy-MM-dd"));

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

            HandleResponse(response);

            return response.Data;
        }
Exemplo n.º 3
0
        public void Log_Single_Water_For_User_On_Date()
        {
            var logDate = new DateTime(2014, 11, 17);  //the date for which the sample waterlog will be added
            WaterLog log = new WaterLog
            {
                LogId = -1,
                Amount = 300
            };


            WaterLog response = client.LogWater(logDate, log, Configuration.FitbitUserId);

            Assert.IsNotNull(response);
            Assert.AreEqual(log.Amount, response.Amount);
            Assert.AreNotEqual(-1, response.LogId);
            Assert.IsTrue(response.LogId > 0);
        }