/// <summary>
 /// Call the HV REST API to delete a task for the user.
 /// Deletes an action plan task of a user who is not signed in ("offline" scenario) if both personId and recordId are provided.
 /// Otherwise, this deletes an action plan task of the user who is actively signed into the application ("online" scenario).
 /// See Getting Started doc for more information on offline scenarios.
 /// </summary>
 private HealthServiceRestResponseData DeleteTask(Guid id, Guid?personId, Guid?recordId)
 {
     return(HealthServiceRestHelper.CallHeathServiceRest(
                personId,
                recordId,
                User.PersonInfo(),
                HttpMethod.Delete.ToString(),
                _baseTaskRestUrl + id));
 }
 /// <summary>
 /// Call the HV REST API to delete an objective for the user.
 /// Deletes an action plan objective of a user who is not signed in ("offline" scenario) if both personId and recordId are provided.
 /// Otherwise, this deletes an action plan objective of the user who is actively signed into the application ("online" scenario).
 /// See Getting Started doc for more information on offline scenarios.
 /// </summary>
 private HealthServiceRestResponseData DeleteObjective(Guid planId, Guid id, Guid?personId, Guid?recordId)
 {
     return(HealthServiceRestHelper.CallHeathServiceRest(
                personId,
                recordId,
                User.PersonInfo(),
                HttpMethod.Delete.ToString(),
                _basePlanRestUrl + planId + "/objectives/" + id));
 }
 /// <summary>
 /// Call the HV REST API to get the a plan for the user.
 /// Gets an action plan of a user who is not signed in ("offline" scenario) if both personId and recordId are provided.
 /// Otherwise, this gets an action plan of the user who is actively signed into the application ("online" scenario).
 /// See Getting Started doc for more information on offline scenarios.
 /// </summary>
 private HealthServiceRestResponseData GetPlan(Guid id, Guid?personId, Guid?recordId)
 {
     return(HealthServiceRestHelper.CallHeathServiceRest(
                personId,
                recordId,
                User.PersonInfo(),
                HttpMethod.Get.ToString(),
                _basePlanRestUrl + id));
 }
 /// <summary>
 /// Call the HV REST API to check how auto tracking matches a task against a HealthVault XML thing.
 /// As this API doesn't actually access HealthVault (all data is being passed in), we've only done this in an online manner.
 /// </summary>
 private HealthServiceRestResponseData ValidateTaskAutoTracking(TrackingValidation trackingValidation)
 {
     return(HealthServiceRestHelper.CallHeathServiceRest(
                null,
                null,
                User.PersonInfo(),
                HttpMethod.Post.ToString(),
                _baseTaskRestUrl + "ValidateTracking",
                null,
                JsonConvert.SerializeObject(trackingValidation)));
 }
 /// <summary>
 /// Call the HV REST API to partially edit the action plan task in a user's HealthVault record.
 /// Edits an action plan task of a user who is not signed in ("offline" scenario) if both personId and recordId are provided.
 /// Otherwise, this edits the action plan task of the user who is actively signed into the application ("online" scenario).
 /// See Getting Started doc for more information on offline scenarios.
 /// </summary>
 private HealthServiceRestResponseData PatchTask(ActionPlanTaskInstance task, Guid?personId, Guid?recordId)
 {
     return(HealthServiceRestHelper.CallHeathServiceRest(
                personId,
                recordId,
                User.PersonInfo(),
                "PATCH",
                _baseTaskRestUrl,
                null,
                JsonConvert.SerializeObject(task)));
 }
 /// <summary>
 /// Call the HV REST API to add the action plan task to a user's HealthVault record.
 /// Assigns an action plan task to a user who is not signed in ("offline" scenario) if both personId and recordId are provided.
 /// Otherwise, this assigns the action plan task to the user who is actively signed into the application ("online" scenario).
 /// See Getting Started doc for more information on offline scenarios.
 /// </summary>
 private HealthServiceRestResponseData CreateTask(ActionPlanTask task, Guid?personId, Guid?recordId)
 {
     return(HealthServiceRestHelper.CallHeathServiceRest(
                personId,
                recordId,
                User.PersonInfo(),
                HttpMethod.Post.ToString(),
                _baseTaskRestUrl,
                null,
                JsonConvert.SerializeObject(task)));
 }
        /// <summary>
        /// Call the HV REST API to get the plan adherence for the user.
        /// Gets the adherence of a user who is not signed in ("offline" scenario) if both personId and recordId are provided.
        /// Otherwise, this gets action plan adherence of the user who is actively signed into the application ("online" scenario).
        /// See Getting Started doc for more information on offline scenarios.
        /// </summary>
        private HealthServiceRestResponseData GetPlanAdherence(Guid id, DateTimeOffset startTime, DateTimeOffset endTime, Guid?personId, Guid?recordId)
        {
            var queryParameters = new NameValueCollection
            {
                { nameof(startTime), startTime.ToString("o", CultureInfo.InvariantCulture) },
                { nameof(endTime), endTime.ToString("o", CultureInfo.InvariantCulture) }
            };

            return(HealthServiceRestHelper.CallHeathServiceRest(
                       personId,
                       recordId,
                       User.PersonInfo(),
                       HttpMethod.Get.ToString(),
                       _basePlanRestUrl + id + "/Adherence",
                       queryParameters));
        }