Ejemplo n.º 1
0
        /// <summary>
        /// Update a post.
        /// Documentation https://developers.google.com/blogger/v3/reference/posts/update
        /// Generation Note: This does not always build corectly.  Google needs to standardise things I need to figuer out which ones are wrong.
        /// </summary>
        /// <param name="service">Authenticated blogger service.</param>
        /// <param name="blogId">The ID of the Blog.</param>
        /// <param name="postId">The ID of the Post.</param>
        /// <param name="body">A valid blogger v3 body.</param>
        /// <param name="optional">Optional paramaters.</param>        /// <returns>PostResponse</returns>
        public static Post Update(bloggerService service, string blogId, string postId, Post body, PostsUpdateOptionalParms optional = null)
        {
            try
            {
                // Initial validation.
                if (service == null)
                {
                    throw new ArgumentNullException("service");
                }
                if (body == null)
                {
                    throw new ArgumentNullException("body");
                }
                if (blogId == null)
                {
                    throw new ArgumentNullException(blogId);
                }
                if (postId == null)
                {
                    throw new ArgumentNullException(postId);
                }

                // Building the initial request.
                var request = service.Posts.Update(body, blogId, postId);

                // Applying optional parameters to the request.
                request = (PostsResource.UpdateRequest)SampleHelpers.ApplyOptionalParms(request, optional);

                // Requesting data.
                return(request.Execute());
            }
            catch (Exception ex)
            {
                throw new Exception("Request Posts.Update failed.", ex);
            }
        }