예제 #1
0
        /// <summary>
        /// Retrieves a list of posts, possibly filtered.
        /// Documentation https://developers.google.com/blogger/v2/reference/posts/list
        /// 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">ID of the blog to fetch posts from.</param>
        /// <param name="optional">Optional paramaters.</param>        /// <returns>PostListResponse</returns>
        public static PostList List(bloggerService service, string blogId, PostsListOptionalParms optional = null)
        {
            try
            {
                // Initial validation.
                if (service == null)
                {
                    throw new ArgumentNullException("service");
                }
                if (blogId == null)
                {
                    throw new ArgumentNullException(blogId);
                }

                // Building the initial request.
                var request = service.Posts.List(blogId);

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

                // Requesting data.
                return(request.Execute());
            }
            catch (Exception ex)
            {
                throw new Exception("Request Posts.List failed.", ex);
            }
        }
예제 #2
0
        /// <summary>
        /// Get a post by id.
        /// Documentation https://developers.google.com/blogger/v2/reference/posts/get
        /// 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">ID of the blog to fetch the post from.</param>
        /// <param name="postId">The ID of the post</param>
        /// <returns>PostResponse</returns>
        public static Post Get(bloggerService service, string blogId, string postId)
        {
            try
            {
                // Initial validation.
                if (service == null)
                {
                    throw new ArgumentNullException("service");
                }
                if (blogId == null)
                {
                    throw new ArgumentNullException(blogId);
                }
                if (postId == null)
                {
                    throw new ArgumentNullException(postId);
                }

                // Make the request.
                return(service.Posts.Get(blogId, postId).Execute());
            }
            catch (Exception ex)
            {
                throw new Exception("Request Posts.Get failed.", ex);
            }
        }
예제 #3
0
        /// <summary>
        /// Delete a page by ID.
        /// Documentation https://developers.google.com/blogger/v3/reference/pages/delete
        /// 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="pageId">The ID of the Page.</param>
        public static void Delete(bloggerService service, string blogId, string pageId)
        {
            try
            {
                // Initial validation.
                if (service == null)
                {
                    throw new ArgumentNullException("service");
                }
                if (blogId == null)
                {
                    throw new ArgumentNullException(blogId);
                }
                if (pageId == null)
                {
                    throw new ArgumentNullException(pageId);
                }

                // Make the request.
                return(service.Pages.Delete(blogId, pageId).Execute());
            }
            catch (Exception ex)
            {
                throw new Exception("Request Pages.Delete failed.", ex);
            }
        }
        /// <summary>
        /// Marks a comment as not spam.
        /// Documentation https://developers.google.com/blogger/v3/reference/comments/approve
        /// 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="commentId">The ID of the comment to mark as not spam.</param>
        /// <returns>CommentResponse</returns>
        public static Comment Approve(bloggerService service, string blogId, string postId, string commentId)
        {
            try
            {
                // Initial validation.
                if (service == null)
                {
                    throw new ArgumentNullException("service");
                }
                if (blogId == null)
                {
                    throw new ArgumentNullException(blogId);
                }
                if (postId == null)
                {
                    throw new ArgumentNullException(postId);
                }
                if (commentId == null)
                {
                    throw new ArgumentNullException(commentId);
                }

                // Make the request.
                return(service.Comments.Approve(blogId, postId, commentId).Execute());
            }
            catch (Exception ex)
            {
                throw new Exception("Request Comments.Approve failed.", ex);
            }
        }
예제 #5
0
        /// <summary>
        /// Retrieve a Blog by URL.
        /// Documentation https://developers.google.com/blogger/v3/reference/blogs/getByUrl
        /// 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="url">The URL of the blog to retrieve.</param>
        /// <param name="optional">Optional paramaters.</param>        /// <returns>BlogResponse</returns>
        public static Blog GetByUrl(bloggerService service, string url, BlogsGetByUrlOptionalParms optional = null)
        {
            try
            {
                // Initial validation.
                if (service == null)
                {
                    throw new ArgumentNullException("service");
                }
                if (url == null)
                {
                    throw new ArgumentNullException(url);
                }

                // Building the initial request.
                var request = service.Blogs.GetByUrl(url);

                // Applying optional parameters to the request.
                request = (BlogsResource.GetByUrlRequest)SampleHelpers.ApplyOptionalParms(request, optional);

                // Requesting data.
                return(request.Execute());
            }
            catch (Exception ex)
            {
                throw new Exception("Request Blogs.GetByUrl failed.", ex);
            }
        }
예제 #6
0
        /// <summary>
        /// Retrieves a list of blogs, possibly filtered.
        /// Documentation https://developers.google.com/blogger/v2/reference/blogs/list
        /// 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="userId">ID of the user whose blogs are to be fetched. Either the word 'self' (sans quote marks) or the user's profile identifier.</param>
        /// <returns>BlogListResponse</returns>
        public static BlogList List(bloggerService service, string userId)
        {
            try
            {
                // Initial validation.
                if (service == null)
                {
                    throw new ArgumentNullException("service");
                }
                if (userId == null)
                {
                    throw new ArgumentNullException(userId);
                }

                // Make the request.
                return(service.Blogs.List(userId).Execute());
            }
            catch (Exception ex)
            {
                throw new Exception("Request Blogs.List failed.", ex);
            }
        }
예제 #7
0
        /// <summary>
        /// Update a page.
        /// Documentation https://developers.google.com/blogger/v3/reference/pages/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="pageId">The ID of the Page.</param>
        /// <param name="body">A valid blogger v3 body.</param>
        /// <param name="optional">Optional paramaters.</param>        /// <returns>PageResponse</returns>
        public static Page Update(bloggerService service, string blogId, string pageId, Page body, PagesUpdateOptionalParms 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 (pageId == null)
                {
                    throw new ArgumentNullException(pageId);
                }

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

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

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