Пример #1
0
        private RequestBodyBuilder PopulateRequestParameters(KnowledgebaseArticleRequest knowledgebaseArticleRequest, RequestTypes requestType)
        {
            knowledgebaseArticleRequest.EnsureValidData(requestType);

            RequestBodyBuilder parameters = new RequestBodyBuilder();

            parameters.AppendRequestDataNonEmptyString("subject", knowledgebaseArticleRequest.Subject);
            parameters.AppendRequestDataNonEmptyString("contents", knowledgebaseArticleRequest.Contents);

            if (requestType == RequestTypes.Create && knowledgebaseArticleRequest.CreatorId.HasValue)
            {
                parameters.AppendRequestDataNonNegativeInt("creatorid", knowledgebaseArticleRequest.CreatorId.Value);
            }

            if (knowledgebaseArticleRequest.ArticleStatus.HasValue)
            {
                parameters.AppendRequestData("articlestatus", EnumUtility.ToApiString(knowledgebaseArticleRequest.ArticleStatus.Value));
            }

            parameters.AppendRequestDataBool("isfeatured", knowledgebaseArticleRequest.IsFeatured);
            parameters.AppendRequestDataBool("allowcomments", knowledgebaseArticleRequest.AllowComments);
            parameters.AppendRequestDataArrayCommaSeparated("categoryid", knowledgebaseArticleRequest.CategoryIds);

            if (requestType == RequestTypes.Update && knowledgebaseArticleRequest.EditedStaffId.HasValue)
            {
                parameters.AppendRequestDataNonNegativeInt("editedstaffid", knowledgebaseArticleRequest.EditedStaffId.Value);
            }

            return(parameters);
        }
        private RequestBodyBuilder PopulateRequestParameters(TroubleshooterCategoryRequest troubleshooterCategoryRequest, RequestTypes requestType)
        {
            troubleshooterCategoryRequest.EnsureValidData(requestType);

            var parameters = new RequestBodyBuilder();

            parameters.AppendRequestDataNonEmptyString("title", troubleshooterCategoryRequest.Title);
            parameters.AppendRequestData("categorytype", EnumUtility.ToApiString(troubleshooterCategoryRequest.CategoryType));

            if (requestType == RequestTypes.Create)
            {
                parameters.AppendRequestDataNonNegativeInt("staffid", troubleshooterCategoryRequest.StaffId);
            }

            if (troubleshooterCategoryRequest.DisplayOrder.HasValue)
            {
                parameters.AppendRequestDataNonNegativeInt("displayorder", troubleshooterCategoryRequest.DisplayOrder.Value);
            }

            parameters.AppendRequestDataNonEmptyString("description", troubleshooterCategoryRequest.Description);
            parameters.AppendRequestDataBool("uservisibilitycustom", troubleshooterCategoryRequest.UserVisibilityCustom);
            parameters.AppendRequestDataArrayCommaSeparated("usergroupidlist", troubleshooterCategoryRequest.UserGroupIdList);
            parameters.AppendRequestDataBool("staffvisibilitycustom", troubleshooterCategoryRequest.StaffVisibilityCustom);
            parameters.AppendRequestDataArrayCommaSeparated("staffgroupidlist", troubleshooterCategoryRequest.StaffGroupIdList);

            return(parameters);
        }
        private RequestBodyBuilder PopulateRequestParameters(TroubleshooterStepRequest troubleshooterStepRequest, RequestTypes requestType)
        {
            troubleshooterStepRequest.EnsureValidData(requestType);

            var parameters = new RequestBodyBuilder();

            if (requestType == RequestTypes.Create)
            {
                parameters.AppendRequestData("categoryid", troubleshooterStepRequest.CategoryId);
            }

            parameters.AppendRequestDataNonEmptyString("subject", troubleshooterStepRequest.Subject);
            parameters.AppendRequestDataNonEmptyString("contents", troubleshooterStepRequest.Contents);

            parameters.AppendRequestDataNonNegativeInt(requestType == RequestTypes.Create ? "staffid" : "editedstaffid",
                                                       troubleshooterStepRequest.StaffId);

            if (troubleshooterStepRequest.DisplayOrder.HasValue)
            {
                parameters.AppendRequestDataNonNegativeInt("displayorder", troubleshooterStepRequest.DisplayOrder.Value);
            }

            parameters.AppendRequestDataBool("allowcomments", troubleshooterStepRequest.AllowComments);
            parameters.AppendRequestDataBool("enableticketredirection", troubleshooterStepRequest.EnableTicketRedirection);

            if (troubleshooterStepRequest.RedirectDepartmentId.HasValue)
            {
                parameters.AppendRequestDataNonNegativeInt("redirectdepartmentid", troubleshooterStepRequest.RedirectDepartmentId.Value);
            }

            if (troubleshooterStepRequest.TicketTypeId.HasValue)
            {
                parameters.AppendRequestDataNonNegativeInt("tickettypeid", troubleshooterStepRequest.TicketTypeId.Value);
            }

            if (troubleshooterStepRequest.TicketPriorityId.HasValue)
            {
                parameters.AppendRequestDataNonNegativeInt("ticketpriorityid", troubleshooterStepRequest.TicketPriorityId.Value);
            }

            parameters.AppendRequestDataNonEmptyString("ticketsubject", troubleshooterStepRequest.TicketSubject);

            if (troubleshooterStepRequest.StepStatus.HasValue)
            {
                parameters.AppendRequestData("stepstatus", EnumUtility.ToApiString(troubleshooterStepRequest.StepStatus.Value));
            }

            parameters.AppendRequestDataArrayCommaSeparated("parentstepidlist", troubleshooterStepRequest.ParentStepIdList);

            return(parameters);
        }
Пример #4
0
        private RequestBodyBuilder PopulateRequestParameters(KnowledgebaseCategoryRequest knowledgebaseCategoryRequest, RequestTypes requestType)
        {
            knowledgebaseCategoryRequest.EnsureValidData(requestType);

            RequestBodyBuilder parameters = new RequestBodyBuilder();

            parameters.AppendRequestDataNonEmptyString("title", knowledgebaseCategoryRequest.Title);

            if (knowledgebaseCategoryRequest.CategoryType.HasValue)
            {
                parameters.AppendRequestData("categorytype",
                                             EnumUtility.ToApiString(knowledgebaseCategoryRequest.CategoryType.Value));
            }

            if (knowledgebaseCategoryRequest.ParentCategoryId.HasValue)
            {
                parameters.AppendRequestData("parentcategoryid", knowledgebaseCategoryRequest.ParentCategoryId.Value);
            }

            if (knowledgebaseCategoryRequest.DisplayOrder.HasValue)
            {
                parameters.AppendRequestDataNonNegativeInt("displayorder", knowledgebaseCategoryRequest.DisplayOrder.Value);
            }

            if (knowledgebaseCategoryRequest.ArticleSortOrder.HasValue)
            {
                parameters.AppendRequestData("articlesortorder",
                                             EnumUtility.ToApiString(knowledgebaseCategoryRequest.ArticleSortOrder.Value));
            }

            parameters.AppendRequestDataBool("allowcomments", knowledgebaseCategoryRequest.AllowComments);
            parameters.AppendRequestDataBool("allowrating", knowledgebaseCategoryRequest.AllowRating);
            parameters.AppendRequestDataBool("ispublished", knowledgebaseCategoryRequest.IsPublished);
            parameters.AppendRequestDataBool("uservisibilitycustom", knowledgebaseCategoryRequest.UserVisibilityCustom);
            parameters.AppendRequestDataArrayCommaSeparated("usergroupidlist", knowledgebaseCategoryRequest.UserGroupIdList);
            parameters.AppendRequestDataBool("staffvisibilitycustom", knowledgebaseCategoryRequest.StaffVisibilityCustom);
            parameters.AppendRequestDataArrayCommaSeparated("staffgroupidlist", knowledgebaseCategoryRequest.StaffGroupIdList);

            if (requestType == RequestTypes.Create && knowledgebaseCategoryRequest.StaffId.HasValue)
            {
                parameters.AppendRequestDataNonNegativeInt("staffid", knowledgebaseCategoryRequest.StaffId.Value);
            }

            return(parameters);
        }
Пример #5
0
        private static RequestBodyBuilder PopulateRequestParameters(NewsItemRequest newsItem, RequestTypes requestType)
        {
            newsItem.EnsureValidData(requestType);

            RequestBodyBuilder parameters = new RequestBodyBuilder();

            parameters.AppendRequestDataNonEmptyString("subject", newsItem.Subject);
            parameters.AppendRequestDataNonEmptyString("contents", newsItem.Contents);

            if (requestType == RequestTypes.Create)
            {
                parameters.AppendRequestDataNonNegativeInt("staffid", newsItem.StaffId);
            }
            else
            {
                parameters.AppendRequestDataNonNegativeInt("editedstaffid", newsItem.StaffId);
            }

            if (requestType == RequestTypes.Create && newsItem.NewsItemType.HasValue)
            {
                parameters.AppendRequestData("newstype", EnumUtility.ToApiString(newsItem.NewsItemType));
            }

            if (newsItem.NewsItemStatus.HasValue)
            {
                parameters.AppendRequestData("newsstatus", EnumUtility.ToApiString(newsItem.NewsItemStatus));
            }

            parameters.AppendRequestDataNonEmptyString("fromname", newsItem.FromName);
            parameters.AppendRequestDataNonEmptyString("email", newsItem.Email);
            parameters.AppendRequestDataNonEmptyString("customemailsubject", newsItem.CustomEmailSubject);
            parameters.AppendRequestDataBool("sendemail", newsItem.SendEmail);
            parameters.AppendRequestDataBool("allowcomments", newsItem.AllowComments);
            parameters.AppendRequestDataBool("uservisibilitycustom", newsItem.UserVisibilityCustom);
            parameters.AppendRequestDataArrayCommaSeparated("usergroupidlist", newsItem.UserGroupIdList);
            parameters.AppendRequestDataBool("staffvisibilitycustom", newsItem.StaffVisibilityCustom);
            parameters.AppendRequestDataArrayCommaSeparated("staffgroupidlist", newsItem.StaffGroupIdList);
            parameters.AppendRequestData("expiry", newsItem.Expiry.DateTime.ToString("M/d/yyyy"));
            parameters.AppendRequestDataArrayCommaSeparated("newscategoryidlist", newsItem.Categories);

            return(parameters);
        }
Пример #6
0
        private RequestBodyBuilder PopulateRequestParameters(NewsSubscriberRequest newsSubscriberRequest, RequestTypes requestTypes)
        {
            newsSubscriberRequest.EnsureValidData(requestTypes);

            var requestBodyBuilder = new RequestBodyBuilder();

            requestBodyBuilder.AppendRequestDataNonEmptyString("email", newsSubscriberRequest.Email);

            if (requestTypes == RequestTypes.Create)
            {
                requestBodyBuilder.AppendRequestDataBool("isvalidated", newsSubscriberRequest.IsValidated);
            }

            return(requestBodyBuilder);
        }
        /// <summary>
        /// Add a new post to an existing ticket.. Only <paramref name="userid"/> or <paramref name="staffid"/> should be set.
        /// <remarks>
        /// See - http://wiki.kayako.com/display/DEV/REST+-+TicketPost#REST-TicketPost-POST%2FTickets%2FTicketPost
        /// </remarks>
        /// </summary>
        /// <param name="ticketid">The unique numeric identifier of the ticket</param>
        /// <param name="subject">The ticket post subject.</param>
        /// <param name="contents">The ticket post contents</param>
        /// <param name="userid">The User Id, if the ticket post is to be created as a user</param>
        /// <param name="staffid">The Staff Id, if the ticket post is to be created as a staff.</param>
        /// <returns></returns>
        public TicketPost AddTicketPost(TicketPostRequest request)
        {
            string apiMethod = "/Tickets/TicketPost";

            request.EnsureValidData(RequestTypes.Create);

            RequestBodyBuilder parameters = new RequestBodyBuilder();

            parameters.AppendRequestData("ticketid", request.TicketId);
            parameters.AppendRequestData("subject", request.Subject);
            parameters.AppendRequestData("contents", request.Contents);

            if (request.UserId == null && request.StaffId == null)
            {
                throw new ArgumentException("Neither UserId nor StaffId are set, one of these fields are required field and cannot be null.");
            }

            if (request.UserId != null && request.StaffId != null)
            {
                throw new ArgumentException("UserId are StaffId are both set, only one of these fields must be set.");
            }

            if (request.UserId != null)
            {
                parameters.AppendRequestData("userid", request.UserId.Value);
            }

            if (request.StaffId != null)
            {
                parameters.AppendRequestData("staffid", request.StaffId.Value);

                if (request.IsPrivate != null)
                {
                    parameters.AppendRequestDataBool("isprivate", request.IsPrivate.Value);
                }
            }

            TicketPostCollection posts = Connector.ExecutePost <TicketPostCollection>(apiMethod, parameters.ToString());

            if (posts.Count > 0)
            {
                return(posts[0]);
            }

            return(null);
        }
		private RequestBodyBuilder PopulateRequestParameters(TroubleshooterStepRequest troubleshooterStepRequest, RequestTypes requestType)
		{
			troubleshooterStepRequest.EnsureValidData(requestType);

			RequestBodyBuilder parameters = new RequestBodyBuilder();

			if (requestType == RequestTypes.Create)
			{
				parameters.AppendRequestData("categoryid", troubleshooterStepRequest.CategoryId);
			}

			parameters.AppendRequestDataNonEmptyString("subject", troubleshooterStepRequest.Subject);
			parameters.AppendRequestDataNonEmptyString("contents", troubleshooterStepRequest.Contents);

			parameters.AppendRequestDataNonNegativeInt(requestType == RequestTypes.Create ? "staffid" : "editedstaffid",
			                                           troubleshooterStepRequest.StaffId);

			if (troubleshooterStepRequest.DisplayOrder.HasValue)
			{
				parameters.AppendRequestDataNonNegativeInt("displayorder", troubleshooterStepRequest.DisplayOrder.Value);
			}

			parameters.AppendRequestDataBool("allowcomments", troubleshooterStepRequest.AllowComments);
			parameters.AppendRequestDataBool("enableticketredirection", troubleshooterStepRequest.EnableTicketRedirection);

			if (troubleshooterStepRequest.RedirectDepartmentId.HasValue)
			{
				parameters.AppendRequestDataNonNegativeInt("redirectdepartmentid", troubleshooterStepRequest.RedirectDepartmentId.Value);
			}

			if (troubleshooterStepRequest.TicketTypeId.HasValue)
			{
				parameters.AppendRequestDataNonNegativeInt("tickettypeid", troubleshooterStepRequest.TicketTypeId.Value);
			}

			if(troubleshooterStepRequest.TicketPriorityId.HasValue)
			{
				parameters.AppendRequestDataNonNegativeInt("ticketpriorityid", troubleshooterStepRequest.TicketPriorityId.Value);
			}

			parameters.AppendRequestDataNonEmptyString("ticketsubject", troubleshooterStepRequest.TicketSubject);
			
			if (troubleshooterStepRequest.StepStatus.HasValue)
			{
				parameters.AppendRequestData("stepstatus", EnumUtility.ToApiString(troubleshooterStepRequest.StepStatus.Value));
			}

			parameters.AppendRequestDataArrayCommaSeparated("parentstepidlist", troubleshooterStepRequest.ParentStepIdList);

			return parameters;
		}
		private RequestBodyBuilder PopulateRequestParameters(TroubleshooterCategoryRequest troubleshooterCategoryRequest, RequestTypes requestType)
		{
			troubleshooterCategoryRequest.EnsureValidData(requestType);

			RequestBodyBuilder parameters = new RequestBodyBuilder();
			parameters.AppendRequestDataNonEmptyString("title", troubleshooterCategoryRequest.Title);
			parameters.AppendRequestData("categorytype", EnumUtility.ToApiString(troubleshooterCategoryRequest.CategoryType));

			if (requestType == RequestTypes.Create)
			{
				parameters.AppendRequestDataNonNegativeInt("staffid", troubleshooterCategoryRequest.StaffId);
			}

			if (troubleshooterCategoryRequest.DisplayOrder.HasValue)
			{
				parameters.AppendRequestDataNonNegativeInt("displayorder", troubleshooterCategoryRequest.DisplayOrder.Value);
			}

			parameters.AppendRequestDataNonEmptyString("description", troubleshooterCategoryRequest.Description);
			parameters.AppendRequestDataBool("uservisibilitycustom", troubleshooterCategoryRequest.UserVisibilityCustom);
			parameters.AppendRequestDataArrayCommaSeparated("usergroupidlist", troubleshooterCategoryRequest.UserGroupIdList);
			parameters.AppendRequestDataBool("staffvisibilitycustom", troubleshooterCategoryRequest.StaffVisibilityCustom);
			parameters.AppendRequestDataArrayCommaSeparated("staffgroupidlist", troubleshooterCategoryRequest.StaffGroupIdList);

			return parameters;
		}
		private RequestBodyBuilder PopulateRequestParameters(KnowledgebaseArticleRequest knowledgebaseArticleRequest, RequestTypes requestType)
		{
			knowledgebaseArticleRequest.EnsureValidData(requestType);

			RequestBodyBuilder parameters = new RequestBodyBuilder();
			parameters.AppendRequestDataNonEmptyString("subject", knowledgebaseArticleRequest.Subject);
			parameters.AppendRequestDataNonEmptyString("contents", knowledgebaseArticleRequest.Contents);

			if (requestType == RequestTypes.Create && knowledgebaseArticleRequest.CreatorId.HasValue)
			{
				parameters.AppendRequestDataNonNegativeInt("creatorid", knowledgebaseArticleRequest.CreatorId.Value);
			}

			if (knowledgebaseArticleRequest.ArticleStatus.HasValue)
			{
				parameters.AppendRequestData("articlestatus", EnumUtility.ToApiString(knowledgebaseArticleRequest.ArticleStatus.Value));
			}

			parameters.AppendRequestDataBool("isfeatured", knowledgebaseArticleRequest.IsFeatured);
			parameters.AppendRequestDataBool("allowcomments", knowledgebaseArticleRequest.AllowComments);
			parameters.AppendRequestDataArrayCommaSeparated("categoryid", knowledgebaseArticleRequest.CategoryIds);

			if (requestType == RequestTypes.Update && knowledgebaseArticleRequest.EditedStaffId.HasValue)
			{
				parameters.AppendRequestDataNonNegativeInt("editedstaffid", knowledgebaseArticleRequest.EditedStaffId.Value);
			}

			return parameters;
		}
		private RequestBodyBuilder PopulateRequestParameters(KnowledgebaseCategoryRequest knowledgebaseCategoryRequest, RequestTypes requestType)
		{
			knowledgebaseCategoryRequest.EnsureValidData(requestType);

			RequestBodyBuilder parameters = new RequestBodyBuilder();
			parameters.AppendRequestDataNonEmptyString("title", knowledgebaseCategoryRequest.Title);

			if (knowledgebaseCategoryRequest.CategoryType.HasValue)
			{
				parameters.AppendRequestData("categorytype",
				                             EnumUtility.ToApiString(knowledgebaseCategoryRequest.CategoryType.Value));
			}

			if (knowledgebaseCategoryRequest.ParentCategoryId.HasValue)
			{
				parameters.AppendRequestData("parentcategoryid", knowledgebaseCategoryRequest.ParentCategoryId.Value);
			}

			if (knowledgebaseCategoryRequest.DisplayOrder.HasValue)
			{
				parameters.AppendRequestDataNonNegativeInt("displayorder", knowledgebaseCategoryRequest.DisplayOrder.Value);
			}

			if (knowledgebaseCategoryRequest.ArticleSortOrder.HasValue)
			{
				parameters.AppendRequestData("articlesortorder",
				                             EnumUtility.ToApiString(knowledgebaseCategoryRequest.ArticleSortOrder.Value));
			}

			parameters.AppendRequestDataBool("allowcomments", knowledgebaseCategoryRequest.AllowComments);
			parameters.AppendRequestDataBool("allowrating", knowledgebaseCategoryRequest.AllowRating);
			parameters.AppendRequestDataBool("ispublished", knowledgebaseCategoryRequest.IsPublished);
			parameters.AppendRequestDataBool("uservisibilitycustom", knowledgebaseCategoryRequest.UserVisibilityCustom);
			parameters.AppendRequestDataArrayCommaSeparated("usergroupidlist", knowledgebaseCategoryRequest.UserGroupIdList);
			parameters.AppendRequestDataBool("staffvisibilitycustom", knowledgebaseCategoryRequest.StaffVisibilityCustom);
			parameters.AppendRequestDataArrayCommaSeparated("staffgroupidlist", knowledgebaseCategoryRequest.StaffGroupIdList);

			if (requestType == RequestTypes.Create && knowledgebaseCategoryRequest.StaffId.HasValue)
			{
				parameters.AppendRequestDataNonNegativeInt("staffid", knowledgebaseCategoryRequest.StaffId.Value);
			}

			return parameters;
		}
Пример #12
0
		private RequestBodyBuilder PopulateRequestParameters(NewsSubscriberRequest newsSubscriberRequest, RequestTypes requestTypes)
		{
			newsSubscriberRequest.EnsureValidData(requestTypes);

			var requestBodyBuilder = new RequestBodyBuilder();
			requestBodyBuilder.AppendRequestDataNonEmptyString("email", newsSubscriberRequest.Email);

			if (requestTypes == RequestTypes.Create)
			{
				requestBodyBuilder.AppendRequestDataBool("isvalidated", newsSubscriberRequest.IsValidated);
			}

			return requestBodyBuilder;
		}
Пример #13
0
		private static RequestBodyBuilder PopulateRequestParameters(NewsItemRequest newsItem, RequestTypes requestType)
		{
			newsItem.EnsureValidData(requestType);

			RequestBodyBuilder parameters = new RequestBodyBuilder();
			parameters.AppendRequestDataNonEmptyString("subject", newsItem.Subject);
			parameters.AppendRequestDataNonEmptyString("contents", newsItem.Contents);

			if (requestType == RequestTypes.Create)
			{
				parameters.AppendRequestDataNonNegativeInt("staffid", newsItem.StaffId);
			}
			else
			{
				parameters.AppendRequestDataNonNegativeInt("editedstaffid", newsItem.StaffId);
			}

			if (requestType == RequestTypes.Create && newsItem.NewsItemType.HasValue)
			{
				parameters.AppendRequestData("newstype", EnumUtility.ToApiString(newsItem.NewsItemType));
			}

			if (newsItem.NewsItemStatus.HasValue)
			{
				parameters.AppendRequestData("newsstatus", EnumUtility.ToApiString(newsItem.NewsItemStatus));
			}

			parameters.AppendRequestDataNonEmptyString("fromname", newsItem.FromName);
			parameters.AppendRequestDataNonEmptyString("email", newsItem.Email);
			parameters.AppendRequestDataNonEmptyString("customemailsubject", newsItem.CustomEmailSubject);
			parameters.AppendRequestDataBool("sendemail", newsItem.SendEmail);
			parameters.AppendRequestDataBool("allowcomments", newsItem.AllowComments);
			parameters.AppendRequestDataBool("uservisibilitycustom", newsItem.UserVisibilityCustom);
			parameters.AppendRequestDataArrayCommaSeparated("usergroupidlist", newsItem.UserGroupIdList);
			parameters.AppendRequestDataBool("staffvisibilitycustom", newsItem.StaffVisibilityCustom);
			parameters.AppendRequestDataArrayCommaSeparated("staffgroupidlist", newsItem.StaffGroupIdList);
			parameters.AppendRequestData("expiry", newsItem.Expiry.DateTime.ToString("M/d/yyyy"));
			parameters.AppendRequestDataArrayCommaSeparated("newscategoryidlist", newsItem.Categories);
			
			return parameters;
		}
        /// <summary>
		/// Add a new post to an existing ticket.. Only <paramref name="userid"/> or <paramref name="staffid"/> should be set.
		/// <remarks>
		/// See - http://wiki.kayako.com/display/DEV/REST+-+TicketPost#REST-TicketPost-POST%2FTickets%2FTicketPost
		/// </remarks>
		/// </summary>
		/// <param name="ticketid">The unique numeric identifier of the ticket</param>
		/// <param name="subject">The ticket post subject.</param>
		/// <param name="contents">The ticket post contents</param>
		/// <param name="userid">The User Id, if the ticket post is to be created as a user</param>
		/// <param name="staffid">The Staff Id, if the ticket post is to be created as a staff.</param>
		/// <returns></returns>
		public TicketPost AddTicketPost(TicketPostRequest request)
		{
            string apiMethod = "/Tickets/TicketPost";

            request.EnsureValidData(RequestTypes.Create);

			RequestBodyBuilder parameters = new RequestBodyBuilder();

            parameters.AppendRequestData("ticketid", request.TicketId);
            parameters.AppendRequestData("subject", request.Subject);
            parameters.AppendRequestData("contents", request.Contents);

            if (request.UserId == null && request.StaffId == null)
			{
				throw new ArgumentException("Neither UserId nor StaffId are set, one of these fields are required field and cannot be null.");
			}

            if (request.UserId != null && request.StaffId != null)
			{
				throw new ArgumentException("UserId are StaffId are both set, only one of these fields must be set.");
			}

            if (request.UserId != null)
			{
                parameters.AppendRequestData("userid", request.UserId.Value);
			}

            if (request.StaffId != null)
			{
                parameters.AppendRequestData("staffid", request.StaffId.Value);

				if (request.IsPrivate != null)
				{
					parameters.AppendRequestDataBool("isprivate", request.IsPrivate.Value);
				}
			}

			TicketPostCollection posts = Connector.ExecutePost<TicketPostCollection>(apiMethod, parameters.ToString());

			if (posts.Count > 0)
			{
				return posts[0];
			}

			return null;
		}