Exemple #1
0
        /// <summary>
        /// Adds new post to group
        /// </summary>
        /// <param name="options">Value containing post's details</param>
        /// <returns>Request result</returns>
        /// <exception cref="LinkedInMissingParameterException">Thrown when any of post's required parameters is null or empty string</exception>
        public LinkedInResponse <bool> AddPost(LinkedInGroupPostOptions options)
        {
            options.GroupId = Id;
            if (string.IsNullOrEmpty(options.Title))
            {
                throw new LinkedInMissingParameterException("Post title cannot be empty", "Title");
            }
            if (string.IsNullOrEmpty(options.Summary))
            {
                throw new LinkedInMissingParameterException("Post summary cannot be empty", "Summary");
            }
            var contentPresented = Utils.IsAnyString(options.ContentTitle, options.ContentText, options.SubmittedUrl,
                                                     options.SubmittedImageUrl);

            if (contentPresented && string.IsNullOrEmpty(options.ContentTitle))
            {
                throw new LinkedInMissingParameterException("Post content title cannot be empty", "ContentTitle");
            }
            if (contentPresented && string.IsNullOrEmpty(options.ContentText))
            {
                throw new LinkedInMissingParameterException("Post content text cannot be empty", "ContentText");
            }
            if (contentPresented && string.IsNullOrEmpty(options.SubmittedUrl))
            {
                throw new LinkedInMissingParameterException("Submitted URL cannot be empty", "SubmittedUrl");
            }
            if (contentPresented && string.IsNullOrEmpty(options.SubmittedImageUrl))
            {
                throw new LinkedInMissingParameterException("Submitted image URL cannot be empty", "SubmittedImageUrl");
            }

            return(RequestRunner.AddGroupPost(options));
        }