public void CreateSleepAsync(Action<string> success, Action<HealthGraphException> failure, SleepNewModel sleepToCreate)
 {
     var request = PrepareSleepCreateRequest(sleepToCreate);
     _tokenManager.ExecuteCreateAsync(request, success, failure);
 }
        /// <summary>
        /// Prepares the request object to create a new model.
        /// </summary>
        /// <param name="sleepToCreate"></param>
        /// <returns></returns>
        private IRestRequest PrepareSleepCreateRequest(SleepNewModel sleepToCreate)
        {
            var request = new RestRequest(Method.POST);
            request.Resource = _user.Sleep;

            ValidateModel(sleepToCreate);

            //Add body to the request
            request.AddParameter(SleepNewModel.ContentType, _tokenManager.DefaultJsonSerializer.Serialize(new
            {
                timestamp = sleepToCreate.Timestamp.ToUniversalTime(),
                awake = sleepToCreate.Awake,
                deep = sleepToCreate.Deep,
                light = sleepToCreate.Light,
                rem = sleepToCreate.Rem,
                times_woken = sleepToCreate.TimesWoken,
                total_sleep = sleepToCreate.TotalSleep,
                post_to_twitter = sleepToCreate.PostToTwitter,
                post_to_facebook = sleepToCreate.PostToFacebook
            }), ParameterType.RequestBody);
            return request;
        }
 public string CreateSleep(SleepNewModel sleepToCreate)
 {
     var request = PrepareSleepCreateRequest(sleepToCreate);
     return _tokenManager.ExecuteCreate(request);
 }
        public void Init()
        {
            ValidSleep = new SleepPastModel
            {
                TotalSleep = 60
            };

            ValidSleepNew = new SleepNewModel
            {
                Timestamp = DateTime.Now,
                TotalSleep = 60,
                PostToFacebook = null,
                PostToTwitter = null
            };
        }