public void Init()
        {
            ValidMeasurement = new GeneralMeasurementsPastModel
            {
                RestingHeartrate = 90
            };

            ValidMeasurementNew = new GeneralMeasurementsNewModel
            {
                Timestamp = DateTime.Now,
                RestingHeartrate = 90,
                PostToFacebook = null,
                PostToTwitter = null
            };
        }
 public string CreateMeasurement(GeneralMeasurementsNewModel measurementToCreate)
 {
     var request = PrepareMeasurementCreateRequest(measurementToCreate);
     return _tokenManager.ExecuteCreate(request);
 }
 public void CreateMeasurement(Action<string> success, Action<HealthGraphException> failure, GeneralMeasurementsNewModel measurementToCreate)
 {
     var request = PrepareMeasurementCreateRequest(measurementToCreate);
     _tokenManager.ExecuteCreateAsync(request, success, failure);
 }
        /// <summary>
        /// Prepares the request object to create a new model.
        /// </summary>
        /// <param name="measurementToCreate"></param>
        /// <returns></returns>
        private IRestRequest PrepareMeasurementCreateRequest(GeneralMeasurementsNewModel measurementToCreate)
        {
            var request = new RestRequest(Method.POST);
            request.Resource = _user.GeneralMeasurements;

            ValidateModel(measurementToCreate);

            //Add body to the request
            request.AddParameter(GeneralMeasurementsNewModel.ContentType, _tokenManager.DefaultJsonSerializer.Serialize(new
            {
                timestamp = measurementToCreate.Timestamp.ToUniversalTime(),
                blood_calcium = measurementToCreate.BloodCalcium,
                blood_chromium = measurementToCreate.BloodChromium,
                blood_folic_acid = measurementToCreate.BloodFolicAcid,
                blood_magnesium = measurementToCreate.BloodMagnesium,
                blood_potassium = measurementToCreate.BloodPotassium,
                blood_sodium = measurementToCreate.BloodSodium,
                blood_vitamin_b12 = measurementToCreate.BloodVitaminB12,
                blood_zinc = measurementToCreate.BloodZinc,
                creatine_kinase = measurementToCreate.CreatineKinase,
                crp = measurementToCreate.Crp,
                diastolic = measurementToCreate.Diastolic,
                ferritin = measurementToCreate.Ferritin,
                hdl = measurementToCreate.Hdl,
                hscrp = measurementToCreate.Hscrp,
                il6 = measurementToCreate.Il6,
                ldl = measurementToCreate.Ldl,
                resting_heartrate = measurementToCreate.RestingHeartrate,
                systolic = measurementToCreate.Systolic,
                testosterone = measurementToCreate.Testosterone,
                total_cholesterol = measurementToCreate.TotalCholesterol,
                tsh = measurementToCreate.Tsh,
                uric_acid = measurementToCreate.UricAcid,
                vitamin_d = measurementToCreate.VitaminD,
                white_cell_count = measurementToCreate.WhiteCellCount,
                post_to_twitter = measurementToCreate.PostToTwitter,
                post_to_facebook = measurementToCreate.PostToFacebook
            }), ParameterType.RequestBody);
            return request;
        }