Ejemplo n.º 1
0
        /// <summary>
        /// Categorizes current post
        /// </summary>
        /// <param name="flag">Value indicating how the current post should be categorized</param>
        /// <returns>Request result</returns>
        /// <exception cref="LinkedInInvalidOperationException">Thrown when user attempts to categorize the post which is not marked as available for this action</exception>
        public LinkedInResponse <bool> Categorize(LinkedInGroupPostFlag flag)
        {
            if (!AvailableAction[LinkedInGroupPostAction.CategorizeAsPromotion] && flag == LinkedInGroupPostFlag.Promotion)
            {
                throw new LinkedInInvalidOperationException("Specifying promotion flag is not available for current post");
            }
            if (!AvailableAction[LinkedInGroupPostAction.CategorizeAsJob] && flag == LinkedInGroupPostFlag.Job)
            {
                throw new LinkedInInvalidOperationException("Specifying job flag is not available for current post");
            }

            return(RequestRunner.CategorizePost(Id, flag));
        }
Ejemplo n.º 2
0
        internal static LinkedInResponse<bool> CategorizePost(string postId, LinkedInGroupPostFlag flag)
        {
            try
            {
                var sb = new StringBuilder(Utils.POSTS_FLAG_URL.Replace("{POST_ID}", postId));
                sb.Append("?oauth2_access_token=");
                sb.Append(Singleton.Instance.AccessToken);
                var body = flag == LinkedInGroupPostFlag.Promotion ? "<code>promotion</code>" : "<code>job</code>";

                var statusCode = HttpStatusCode.OK;
                Utils.MakeRequest(sb.ToString(), "PUT", ref statusCode, body);
                return new LinkedInResponse<bool>(statusCode == HttpStatusCode.NoContent, LinkedInResponseStatus.OK, null);
            }
            catch (WebException wex)
            {
                return Utils.GetResponse(false, wex, null);
            }
            catch (Exception ex)
            {
                return new LinkedInResponse<bool>(false, LinkedInResponseStatus.OtherException, null, ex);
            }
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Categorizes current post
        /// </summary>
        /// <param name="flag">Value indicating how the current post should be categorized</param>
        /// <returns>Request result</returns>
        /// <exception cref="LinkedInInvalidOperationException">Thrown when user attempts to categorize the post which is not marked as available for this action</exception>
        public LinkedInResponse<bool> Categorize(LinkedInGroupPostFlag flag)
        {
            if (!AvailableAction[LinkedInGroupPostAction.CategorizeAsPromotion] && flag == LinkedInGroupPostFlag.Promotion)
                throw new LinkedInInvalidOperationException("Specifying promotion flag is not available for current post");
            if (!AvailableAction[LinkedInGroupPostAction.CategorizeAsJob] && flag == LinkedInGroupPostFlag.Job)
                throw new LinkedInInvalidOperationException("Specifying job flag is not available for current post");

            return RequestRunner.CategorizePost(Id, flag);
        }