public void Init() { ValidMeasurement = new DiabetesMeasurementsPastModel { Insulin = 100 }; ValidMeasurementNew = new DiabetesMeasurementsNewModel { Timestamp = DateTime.Now, Insulin = 10, PostToFacebook = null, PostToTwitter = null }; }
/// <summary> /// Prepares the request object to create a new model. /// </summary> /// <param name="measurementToCreate"></param> /// <returns></returns> private IRestRequest PrepareMeasurementCreateRequest(DiabetesMeasurementsNewModel measurementToCreate) { var request = new RestRequest(Method.POST); request.Resource = _user.Diabetes; ValidateModel(measurementToCreate); //Add body to the request request.AddParameter(DiabetesMeasurementsNewModel.ContentType, _tokenManager.DefaultJsonSerializer.Serialize(new { timestamp = measurementToCreate.Timestamp.ToUniversalTime(), c_peptide = measurementToCreate.CPeptide, fasting_plasma_glucose_test = measurementToCreate.FastingPlasmaGlucoseTest, hemoglobin_a1c = measurementToCreate.HemoglobinA1c, insulin = measurementToCreate.Insulin, oral_glucose_tolerance_test = measurementToCreate.OralGlucoseToleranceTest, random_plasma_glucose_test = measurementToCreate.RandomPlasmaGlucoseTest, triglyceride = measurementToCreate.Triglyceride, post_to_twitter = measurementToCreate.PostToTwitter, post_to_facebook = measurementToCreate.PostToFacebook }), ParameterType.RequestBody); return(request); }
public void CreateMeasurementAsync(Action<string> success, Action<HealthGraphException> failure, DiabetesMeasurementsNewModel measurementToCreate) { var request = PrepareMeasurementCreateRequest(measurementToCreate); _tokenManager.ExecuteCreateAsync(request, success, failure); }
public string CreateMeasurement(DiabetesMeasurementsNewModel measurementToCreate) { var request = PrepareMeasurementCreateRequest(measurementToCreate); return _tokenManager.ExecuteCreate(request); }
/// <summary> /// Prepares the request object to create a new model. /// </summary> /// <param name="measurementToCreate"></param> /// <returns></returns> private IRestRequest PrepareMeasurementCreateRequest(DiabetesMeasurementsNewModel measurementToCreate) { var request = new RestRequest(Method.POST); request.Resource = _user.Diabetes; ValidateModel(measurementToCreate); //Add body to the request request.AddParameter(DiabetesMeasurementsNewModel.ContentType, _tokenManager.DefaultJsonSerializer.Serialize(new { timestamp = measurementToCreate.Timestamp.ToUniversalTime(), c_peptide = measurementToCreate.CPeptide, fasting_plasma_glucose_test = measurementToCreate.FastingPlasmaGlucoseTest, hemoglobin_a1c = measurementToCreate.HemoglobinA1c, insulin = measurementToCreate.Insulin, oral_glucose_tolerance_test = measurementToCreate.OralGlucoseToleranceTest, random_plasma_glucose_test = measurementToCreate.RandomPlasmaGlucoseTest, triglyceride = measurementToCreate.Triglyceride, post_to_twitter = measurementToCreate.PostToTwitter, post_to_facebook = measurementToCreate.PostToFacebook }), ParameterType.RequestBody); return request; }
public void CreateMeasurementAsync(Action <string> success, Action <HealthGraphException> failure, DiabetesMeasurementsNewModel measurementToCreate) { var request = PrepareMeasurementCreateRequest(measurementToCreate); _tokenManager.ExecuteCreateAsync(request, success, failure); }
public string CreateMeasurement(DiabetesMeasurementsNewModel measurementToCreate) { var request = PrepareMeasurementCreateRequest(measurementToCreate); return(_tokenManager.ExecuteCreate(request)); }