/// <summary>
        /// Create an LtiRequestViewModel that contains a ContentItemPlacementResponse.
        /// </summary>
        /// <param name="url">The content_item_return_url from the content-item message.</param>
        /// <param name="consumerKey">The OAuth consumer key to use to sign the request.</param>
        /// <param name="consumerSecret">The OAuth consumer secret to use to sign the request.</param>
        /// <param name="contentItems">The ContentItemPlacementResponse to send.</param>
        /// <param name="data">The data received in the original content-item message.</param>
        /// <param name="ltiErrorLog">Optional plain text error message to be logged by the Tool Consumer.</param>
        /// <param name="ltiErrorMsg">Optional plain text error message to be displayed by the Tool Consumer.</param>
        /// <param name="ltiLog">Optional plain text message to be logged by the Tool Consumer.</param>
        /// <param name="ltiMsg">Optional plain text message to be displayed by the Tool Consumer.</param>
        /// <returns>The LtiRequestViewModel which contains a signed version of the response.</returns>
        public static LtiRequestViewModel CreateContentItemSelectionResponseViewModel(
            string url, string consumerKey, string consumerSecret,
            ContentItemPlacementResponse contentItems, string data,
            string ltiErrorLog, string ltiErrorMsg, string ltiLog, string ltiMsg)
        {
            var ltiRequest = (IContentItemSelectionResponse) new LtiRequest(LtiConstants.ContentItemSelectionResponseLtiMessageType)
            {
                Url          = new Uri(url),
                ConsumerKey  = consumerKey,
                ContentItems = JsonConvert.SerializeObject(contentItems, Formatting.None, new JsonSerializerSettings {
                    NullValueHandling = NullValueHandling.Ignore
                }),
                Data        = data,
                LtiErrorLog = ltiErrorLog,
                LtiErrorMsg = ltiErrorMsg,
                LtiLog      = ltiLog,
                LtiMsg      = ltiMsg
            };

            return(ltiRequest.GetLtiRequestViewModel(consumerSecret));
        }
        /// <summary>
        /// Send content-item response to Tool Consumer content-item service. This is experimental.
        /// </summary>
        /// <param name="url">The content-item service URL (from content-item message).</param>
        /// <param name="consumerKey">The OAuth consumer key to use to sign the request.</param>
        /// <param name="consumerSecret">The OAuth consumer secret to use to sign the request.</param>
        /// <param name="contentItems">The ContentItemPlacementResponse to POST.</param>
        /// <param name="data">The data received in the original content-item message.</param>
        /// <returns>Return True if the POST request is successful.</returns>
        public static bool PostContentItems(
            string url, string consumerKey, string consumerSecret,
            ContentItemPlacementResponse contentItems, string data)
        {
            var serviceResponse = new ContentItemsServiceResponse
            {
                ContentItems = contentItems,
                Data         = data
            };

            try
            {
                var webRequest = CreateContentItemsRequest(url, consumerKey, consumerSecret, serviceResponse);
                using (var webResponse = webRequest.GetResponse() as HttpWebResponse)
                {
                    return(webResponse != null && webResponse.StatusCode == HttpStatusCode.OK);
                }
            }
            catch (Exception)
            {
                return(false);
            }
        }
 /// <summary>
 /// Create an LtiRequestViewModel that contains a ContentItemPlacementResponse.
 /// </summary>
 /// <param name="url">The content_item_return_url from the content-item message.</param>
 /// <param name="consumerKey">The OAuth consumer key to use to sign the request.</param>
 /// <param name="consumerSecret">The OAuth consumer secret to use to sign the request.</param>
 /// <param name="contentItems">The ContentItemPlacementResponse to send.</param>
 /// <param name="data">The data received in the original content-item message.</param>
 /// <returns>The LtiRequestViewModel which contains a signed version of the response.</returns>
 public static LtiRequestViewModel CreateContentItemSelectionResponseViewModel(
     string url, string consumerKey, string consumerSecret,
     ContentItemPlacementResponse contentItems, string data)
 {
     return(CreateContentItemSelectionResponseViewModel(url, consumerKey, consumerSecret, contentItems, data, null, null, null, null));
 }