public void CreateWeightAsync(Action<string> success, Action<HealthGraphException> failure, WeightNewModel weightToCreate) { var request = PrepareWeightCreateRequest(weightToCreate); _tokenManager.ExecuteCreateAsync(request, success, failure); }
/// <summary> /// Prepares the request object to create a new model. /// </summary> /// <param name="weightToCreate"></param> /// <returns></returns> private IRestRequest PrepareWeightCreateRequest(WeightNewModel weightToCreate) { var request = new RestRequest(Method.POST); request.Resource = _user.Weight; ValidateModel(weightToCreate); //Add body to the request request.AddParameter(WeightNewModel.ContentType, _tokenManager.DefaultJsonSerializer.Serialize(new { timestamp = weightToCreate.Timestamp.ToUniversalTime(), bmi = weightToCreate.Bmi, fat_percent = weightToCreate.FatPercent, free_mass = weightToCreate.FreeMass, mass_weight = weightToCreate.MassWeight, weight = weightToCreate.Weight, post_to_twitter = weightToCreate.PostToTwitter, post_to_facebook = weightToCreate.PostToFacebook }), ParameterType.RequestBody); return request; }
public string CreateWeight(WeightNewModel weightToCreate) { var request = PrepareWeightCreateRequest(weightToCreate); return _tokenManager.ExecuteCreate(request); }
public void Init() { ValidWeight = new WeightPastModel { Weight = 10 }; ValidWeightNew = new WeightNewModel { Timestamp = DateTime.Now, Weight = 10, PostToFacebook = null, PostToTwitter = null }; }