public Ticket CreateTicket(TicketRequest ticketRequest) { const string apiMethod = "/Tickets/Ticket"; ticketRequest.EnsureValidData(RequestTypes.Create); var parameters = new RequestBodyBuilder(); parameters.AppendRequestData("subject", ticketRequest.Subject); parameters.AppendRequestData("fullname", ticketRequest.FullName); parameters.AppendRequestData("email", ticketRequest.Email); parameters.AppendRequestData("contents", ticketRequest.Contents); parameters.AppendRequestData("departmentid", ticketRequest.DepartmentId); parameters.AppendRequestData("ticketstatusid", ticketRequest.TicketStatusId); parameters.AppendRequestData("ticketpriorityid", ticketRequest.TicketPriorityId); parameters.AppendRequestData("tickettypeid", ticketRequest.TicketTypeId); if (ticketRequest.AutoUserId != null) { parameters.AppendRequestData("autouserid", Convert.ToInt32(ticketRequest.AutoUserId)); } else if (ticketRequest.UserId != null) { parameters.AppendRequestData("userid", ticketRequest.UserId); } else if (ticketRequest.StaffId != null) { parameters.AppendRequestData("staffid", ticketRequest.StaffId); } if (ticketRequest.OwnerStaffId != null) { parameters.AppendRequestData("ownerstaffid", ticketRequest.OwnerStaffId); } if (ticketRequest.TemplateGroupId != null) { parameters.AppendRequestData("templategroup", ticketRequest.TemplateGroupId); } else if (!string.IsNullOrEmpty(ticketRequest.TemplateGroupName)) { parameters.AppendRequestData("templategroup", ticketRequest.TemplateGroupName); } if (ticketRequest.IgnoreAutoResponder != null) { parameters.AppendRequestData("ignoreautoresponder", Convert.ToInt32(ticketRequest.IgnoreAutoResponder)); } if (ticketRequest.CreationType != null) { parameters.AppendRequestData("type", EnumUtility.ToApiString(ticketRequest.CreationType)); } var tickets = this.Connector.ExecutePost <TicketCollection>(apiMethod, parameters.ToString()); return(tickets.Count > 0 ? tickets[0] : null); }
public void CreateDepartment() { var departmentRequest = new DepartmentRequest { Title = "Title", DisplayOrder = 2, Type = DepartmentType.Public }; var departments = new DepartmentCollection { new Department { Title = "Title", DisplayOrder = 2, Type = DepartmentType.Public} }; var parameters = new RequestBodyBuilder(); parameters.AppendRequestData("title", departmentRequest.Title); parameters.AppendRequestData("type", EnumUtility.ToApiString(departmentRequest.Type)); parameters.AppendRequestData("module", EnumUtility.ToApiString(departmentRequest.Module)); parameters.AppendRequestData("displayorder", departmentRequest.DisplayOrder); parameters.AppendRequestData("uservisibilitycustom", 0); _kayakoApiRequest.Setup(x => x.ExecutePost<DepartmentCollection>(ApiBaseMethods.Departments, parameters.ToString())).Returns(departments); var departmentCreated = _departmentController.CreateDepartment(departmentRequest); _kayakoApiRequest.Verify(x => x.ExecutePost<DepartmentCollection>(ApiBaseMethods.Departments, parameters.ToString()), Times.Once()); Assert.That(departmentCreated, Is.EqualTo(departments.First())); }
/// <summary> /// Run a search on Users. You can search users from email, full name, phone, organization name and user group. /// </summary> public UserCollection UserSearch(string query) { const string apiMethod = "/Base/UserSearch"; var parameters = new RequestBodyBuilder(); parameters.AppendRequestData("query", query); var users = this.Connector.ExecutePost <UserCollection>(apiMethod, parameters.ToString()); return(users); }
/// <summary> /// Update the user identified by their unique identifier. /// </summary> public User UpdateUser(UserRequest user) { string apiMethod = String.Format("/Base/User/{0}", user.Id); RequestBodyBuilder parameters = PopulateRequestParameters(user, RequestTypes.Update); UserCollection users = Connector.ExecutePut <UserCollection>(apiMethod, parameters.ToString()); if (users.Count > 0) { return(users[0]); } return(null); }
/// <summary> /// Add a new note to a ticket. /// </summary> /// <remarks> /// http://wiki.kayako.com/display/DEV/REST+-+TicketNote#REST-TicketNote-POST%2FTickets%2FTicketNote /// </remarks> /// <returns>The added ticket note.</returns> public TicketNote AddTicketNote(TicketNoteRequest request) { const string apiMethod = "/Tickets/TicketNote"; request.EnsureValidData(RequestTypes.Create); var parameters = new RequestBodyBuilder(); parameters.AppendRequestData("ticketid", request.TicketId); parameters.AppendRequestData("contents", request.Content); parameters.AppendRequestData("notecolor", (int)request.NoteColor); if (request.FullName == null && request.StaffId == null) { throw new ArgumentException("Neither FullName nor StaffId are set, one of these fields are required field and cannot be null."); } if (request.FullName != null && request.StaffId != null) { throw new ArgumentException("FullName are StaffId are both set, only one of these fields must be set."); } if (request.FullName != null) { parameters.AppendRequestData("fullname", request.FullName); } if (request.StaffId != null) { parameters.AppendRequestData("staffid", request.StaffId.Value); } if (request.ForStaffId != null) { parameters.AppendRequestData("forstaffid", request.ForStaffId.Value); } var notes = this.Connector.ExecutePost <TicketNoteCollection>(apiMethod, parameters.ToString()); return(notes.Count > 0 ? notes[0] : null); }
/// <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="request">Ticket request</param> /// <returns></returns> public TicketPost AddTicketPost(TicketPostRequest request) { const string apiMethod = "/Tickets/TicketPost"; request.EnsureValidData(RequestTypes.Create); var 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); } } var posts = this.Connector.ExecutePost <TicketPostCollection>(apiMethod, parameters.ToString()); return(posts.Count > 0 ? posts[0] : null); }
/// <summary> /// Create a new User record /// </summary> public User CreateUser(UserRequest user, string password, bool sendWelcomeEmail) { string apiMethod = "/Base/User/"; RequestBodyBuilder parameters = PopulateRequestParameters(user, RequestTypes.Create); if (!String.IsNullOrEmpty(password)) { parameters.AppendRequestData("password", password); } parameters.AppendRequestData("sendwelcomeemail", Convert.ToInt32(sendWelcomeEmail)); UserCollection users = Connector.ExecutePost <UserCollection>(apiMethod, parameters.ToString()); if (users != null && users.Count > 0) { return(users[0]); } return(null); }
/// <summary> /// Run a search on tickets. You can combine the search factors to make the span multiple areas. /// For example, to search the full name, contents and email you can send the arguments as: /// query=John&fullname=1&email=1&contents=1 /// </summary> public TicketCollection SearchTickets(TicketSearchQuery query) { if (String.IsNullOrEmpty(query.Query)) { throw new ArgumentException("A search query must be provided"); } string apiMethod = "/Tickets/TicketSearch"; RequestBodyBuilder parameters = query.GetRequestBodyParameters(); TicketCollection tickets = Connector.ExecutePost <TicketCollection>(apiMethod, parameters.ToString()); return(tickets); }
/// <summary> /// Add a new time tracking note to a ticket /// </summary> public TicketTimeTrack AddTicketTimeTrackingNote(TicketTimeTrackRequest request) { request.EnsureValidData(RequestTypes.Create); string apiMethod = "/Tickets/TicketTimeTrack"; RequestBodyBuilder parameters = new RequestBodyBuilder(); parameters.AppendRequestData("ticketid", request.TicketId); parameters.AppendRequestData("contents", request.Contents); parameters.AppendRequestData("staffid", request.StaffId); parameters.AppendRequestData("worktimeline", request.WorkTimeline); parameters.AppendRequestData("billtimeline", request.BillTimeline); parameters.AppendRequestData("timespent", request.TimeSpent); parameters.AppendRequestData("timebillable", request.TimeBillable); if (request.WorkerStaffId != null) { parameters.AppendRequestData("workerstaffid", request.WorkerStaffId); } if (request.NoteColor != null) { parameters.AppendRequestData("notecolor", EnumUtility.ToApiString(request.NoteColor)); } TicketTimeTrackCollection ticketTimeTracks = Connector.ExecutePost <TicketTimeTrackCollection>(apiMethod, parameters.ToString()); if (ticketTimeTracks != null && ticketTimeTracks.Count > 0) { return(ticketTimeTracks[0]); } return(null); }
public NewsItemComment CreateNewsItemComment(NewsItemCommentRequest newsItemCommentRequest) { newsItemCommentRequest.EnsureValidData(RequestTypes.Create); RequestBodyBuilder parameters = new RequestBodyBuilder(); parameters.AppendRequestData("newsitemid", newsItemCommentRequest.NewsItemId); parameters.AppendRequestDataNonEmptyString("contents", newsItemCommentRequest.Contents); parameters.AppendRequestData("creatortype", EnumUtility.ToApiString(newsItemCommentRequest.CreatorType)); if (newsItemCommentRequest.CreatorId != null) { parameters.AppendRequestData("creatorid", newsItemCommentRequest.CreatorId); } else { parameters.AppendRequestDataNonEmptyString("fullname", newsItemCommentRequest.FullName); } parameters.AppendRequestDataNonEmptyString("email", newsItemCommentRequest.Email); parameters.AppendRequestData("parentcommentid", newsItemCommentRequest.ParentCommentId); var newsItemComments = Connector.ExecutePost <NewsItemCommentCollection>(NewsItemCommentBaseUrl, parameters.ToString()); if (newsItemComments != null && newsItemComments.Count > 0) { return(newsItemComments[0]); } return(null); }
public TroubleshooterCategory CreateTroubleshooterCategory(TroubleshooterCategoryRequest troubleshooterCategoryRequest) { RequestBodyBuilder parameters = PopulateRequestParameters(troubleshooterCategoryRequest, RequestTypes.Create); TroubleshooterCategoryCollection troubleshooterCategories = Connector.ExecutePost <TroubleshooterCategoryCollection>(TroubleshooterCategoryBaseUrl, parameters.ToString()); if (troubleshooterCategories != null && troubleshooterCategories.Count > 0) { return(troubleshooterCategories[0]); } return(null); }
/// <summary> /// Creates a new department /// </summary> /// <param name="dept">Department data to create a new department with. Department Title, Module and Type must be supplied</param> /// <returns>Department data representing the department created</returns> public Department CreateDepartment(DepartmentRequest dept) { RequestBodyBuilder parameters = PopulateRequestParameters(dept, RequestTypes.Create); DepartmentCollection depts = Connector.ExecutePost <DepartmentCollection>(ApiBaseMethods.Departments, parameters.ToString()); if (depts != null && depts.Count > 0) { return(depts[0]); } return(null); }
public Ticket CreateTicket(TicketRequest ticketRequest) { string apiMethod = "/Tickets/Ticket"; ticketRequest.EnsureValidData(RequestTypes.Create); RequestBodyBuilder parameters = new RequestBodyBuilder(); parameters.AppendRequestData("subject", ticketRequest.Subject); parameters.AppendRequestData("fullname", ticketRequest.FullName); parameters.AppendRequestData("email", ticketRequest.Email); parameters.AppendRequestData("contents", ticketRequest.Contents); parameters.AppendRequestData("departmentid", ticketRequest.DepartmentId); parameters.AppendRequestData("ticketstatusid", ticketRequest.TicketStatusId); parameters.AppendRequestData("ticketpriorityid", ticketRequest.TicketPriorityId); parameters.AppendRequestData("tickettypeid", ticketRequest.TicketTypeId); if (ticketRequest.AutoUserId != null) { parameters.AppendRequestData("autouserid", Convert.ToInt32(ticketRequest.AutoUserId)); } else if (ticketRequest.UserId != null) { parameters.AppendRequestData("userid", ticketRequest.UserId); } else if (ticketRequest.StaffId != null) { parameters.AppendRequestData("staffid", ticketRequest.StaffId); } if (ticketRequest.OwnerStaffId != null) { parameters.AppendRequestData("ownerstaffid", ticketRequest.OwnerStaffId); } if (ticketRequest.TemplateGroupId != null) { parameters.AppendRequestData("templategroup", ticketRequest.TemplateGroupId); } else if (!string.IsNullOrEmpty(ticketRequest.TemplateGroupName)) { parameters.AppendRequestData("templategroup", ticketRequest.TemplateGroupName); } if (ticketRequest.IgnoreAutoResponder != null) { parameters.AppendRequestData("ignoreautoresponder", Convert.ToInt32(ticketRequest.IgnoreAutoResponder)); } if (ticketRequest.CreationType != null) { parameters.AppendRequestData("type", EnumUtility.ToApiString(ticketRequest.CreationType)); } TicketCollection tickets = Connector.ExecutePost<TicketCollection>(apiMethod, parameters.ToString()); if (tickets.Count > 0) { return tickets[0]; } return null; }
public KnowledgebaseArticle UpdateKnowledgebaseArticle(KnowledgebaseArticleRequest knowledgebaseArticleRequest) { string apiMethod = String.Format("{0}/{1}", KnowledgebaseArticleBaseUrl, knowledgebaseArticleRequest.Id); RequestBodyBuilder parameters = PopulateRequestParameters(knowledgebaseArticleRequest, RequestTypes.Update); KnowledgebaseArticleCollection knowledgebaseArticles = Connector.ExecutePut <KnowledgebaseArticleCollection>(apiMethod, parameters.ToString()); if (knowledgebaseArticles != null && knowledgebaseArticles.Count > 0) { return(knowledgebaseArticles[0]); } return(null); }
/// <summary> /// Add a new time tracking note to a ticket /// </summary> public TicketTimeTrack AddTicketTimeTrackingNote(TicketTimeTrackRequest request) { request.EnsureValidData(RequestTypes.Create); string apiMethod = "/Tickets/TicketTimeTrack"; RequestBodyBuilder parameters = new RequestBodyBuilder(); parameters.AppendRequestData("ticketid", request.TicketId); parameters.AppendRequestData("contents", request.Contents); parameters.AppendRequestData("staffid", request.StaffId); parameters.AppendRequestData("worktimeline", request.WorkTimeline); parameters.AppendRequestData("billtimeline", request.BillTimeline); parameters.AppendRequestData("timespent", request.TimeSpent); parameters.AppendRequestData("timebillable", request.TimeBillable); if (request.WorkerStaffId != null) { parameters.AppendRequestData("workerstaffid", request.WorkerStaffId); } if (request.NoteColor != null) { parameters.AppendRequestData("notecolor", EnumUtility.ToApiString(request.NoteColor)); } TicketTimeTrackCollection ticketTimeTracks = Connector.ExecutePost<TicketTimeTrackCollection>(apiMethod, parameters.ToString()); if (ticketTimeTracks != null && ticketTimeTracks.Count > 0) { return ticketTimeTracks[0]; } return null; }
public NewsItemComment CreateNewsItemComment(NewsItemCommentRequest newsItemCommentRequest) { newsItemCommentRequest.EnsureValidData(RequestTypes.Create); RequestBodyBuilder parameters = new RequestBodyBuilder(); parameters.AppendRequestData("newsitemid", newsItemCommentRequest.NewsItemId); parameters.AppendRequestDataNonEmptyString("contents", newsItemCommentRequest.Contents); parameters.AppendRequestData("creatortype", EnumUtility.ToApiString(newsItemCommentRequest.CreatorType)); if (newsItemCommentRequest.CreatorId != null) { parameters.AppendRequestData("creatorid", newsItemCommentRequest.CreatorId); } else { parameters.AppendRequestDataNonEmptyString("fullname", newsItemCommentRequest.FullName); } parameters.AppendRequestDataNonEmptyString("email", newsItemCommentRequest.Email); parameters.AppendRequestData("parentcommentid", newsItemCommentRequest.ParentCommentId); var newsItemComments = Connector.ExecutePost<NewsItemCommentCollection>(NewsItemCommentBaseUrl, parameters.ToString()); if (newsItemComments != null && newsItemComments.Count > 0) { return newsItemComments[0]; } return null; }
public void CreateDepartment() { var departmentRequest = new DepartmentRequest { Title = "Title", DisplayOrder = 2, Type = DepartmentType.Public }; var departments = new DepartmentCollection { new Department { Title = "Title", DisplayOrder = 2, Type = DepartmentType.Public } }; var parameters = new RequestBodyBuilder(); parameters.AppendRequestData("title", departmentRequest.Title); parameters.AppendRequestData("type", EnumUtility.ToApiString(departmentRequest.Type)); parameters.AppendRequestData("module", EnumUtility.ToApiString(departmentRequest.Module)); parameters.AppendRequestData("displayorder", departmentRequest.DisplayOrder); parameters.AppendRequestData("uservisibilitycustom", 0); _kayakoApiRequest.Setup(x => x.ExecutePost <DepartmentCollection>(ApiBaseMethods.Departments, parameters.ToString())).Returns(departments); var departmentCreated = _departmentController.CreateDepartment(departmentRequest); _kayakoApiRequest.Verify(x => x.ExecutePost <DepartmentCollection>(ApiBaseMethods.Departments, parameters.ToString()), Times.Once()); Assert.That(departmentCreated, Is.EqualTo(departments.First())); }
///// <summary> ///// Add a new note to a ticket. ///// </summary> ///// <remarks> ///// http://wiki.kayako.com/display/DEV/REST+-+TicketNote#REST-TicketNote-POST%2FTickets%2FTicketNote</remarks> ///// <returns>The added ticket note.</returns> public TicketNote AddTicketNote(TicketNoteRequest request) { string apiMethod = "/Tickets/TicketNote"; request.EnsureValidData(RequestTypes.Create); RequestBodyBuilder parameters = new RequestBodyBuilder(); parameters.AppendRequestData("ticketid", request.TicketId); parameters.AppendRequestData("contents", request.Content); parameters.AppendRequestData("notecolor", (int)request.NoteColor); if (request.FullName == null && request.StaffId == null) { throw new ArgumentException("Neither FullName nor StaffId are set, one of these fields are required field and cannot be null."); } if (request.FullName != null && request.StaffId != null) { throw new ArgumentException("FullName are StaffId are both set, only one of these fields must be set."); } if (request.FullName != null) { parameters.AppendRequestData("fullname", request.FullName); } if (request.StaffId != null) { parameters.AppendRequestData("staffid", request.StaffId.Value); } if (request.ForStaffId != null) { parameters.AppendRequestData("forstaffid", request.ForStaffId.Value); } TicketNoteCollection notes = Connector.ExecutePost<TicketNoteCollection>(apiMethod, parameters.ToString()); if (notes.Count > 0) { return notes[0]; } return null; }
/// <summary> /// Add an attachment to a ticket post. /// </summary> /// <param name="ticketId">The unique numeric identifier of the ticket</param> /// <param name="ticketPostId">The unique numeric identifier of the ticket post</param> /// <param name="fileName">The file name for the attachment </param> /// <param name="contents">The BASE64 encoded attachment contents</param> public TicketAttachment AddTicketAttachment(TicketAttachmentRequest request) { string apiMethod = "/Tickets/TicketAttachment"; request.EnsureValidData(RequestTypes.Create); RequestBodyBuilder parameters = new RequestBodyBuilder(); parameters.AppendRequestData("ticketid", request.TicketId); parameters.AppendRequestData("ticketpostid", request.TicketPostId); parameters.AppendRequestData("filename", request.FileName); parameters.AppendRequestData("contents", request.Contents); TicketAttachmentCollection attachments = Connector.ExecutePost<TicketAttachmentCollection>(apiMethod, parameters.ToString()); if (attachments != null && attachments.Count > 0) { return attachments[0]; } return null; }
/// <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; }
/// <summary> /// Add an attachment to a ticket post. /// </summary> /// <param name="ticketId">The unique numeric identifier of the ticket</param> /// <param name="ticketPostId">The unique numeric identifier of the ticket post</param> /// <param name="fileName">The file name for the attachment </param> /// <param name="contents">The BASE64 encoded attachment contents</param> public TicketAttachment AddTicketAttachment(TicketAttachmentRequest request) { string apiMethod = "/Tickets/TicketAttachment"; request.EnsureValidData(RequestTypes.Create); RequestBodyBuilder parameters = new RequestBodyBuilder(); parameters.AppendRequestData("ticketid", request.TicketId); parameters.AppendRequestData("ticketpostid", request.TicketPostId); parameters.AppendRequestData("filename", request.FileName); parameters.AppendRequestData("contents", request.Contents); TicketAttachmentCollection attachments = Connector.ExecutePost <TicketAttachmentCollection>(apiMethod, parameters.ToString()); if (attachments != null && attachments.Count > 0) { return(attachments[0]); } return(null); }
public void UpdateDepartment() { var departmentRequest = new DepartmentRequest { Title = "Title", DisplayOrder = 2, Type = DepartmentType.Public, Id = 12 }; var departments = new DepartmentCollection { new Department { Title = "Title", DisplayOrder = 2, Type = DepartmentType.Public } }; var apiMethod = string.Format("{0}/{1}", ApiBaseMethods.Departments, departmentRequest.Id); var parameters = new RequestBodyBuilder(); parameters.AppendRequestData("title", departmentRequest.Title); parameters.AppendRequestData("type", EnumUtility.ToApiString(departmentRequest.Type)); parameters.AppendRequestData("displayorder", departmentRequest.DisplayOrder); parameters.AppendRequestData("uservisibilitycustom", 0); this.kayakoApiRequest.Setup(x => x.ExecutePut <DepartmentCollection>(apiMethod, parameters.ToString())).Returns(departments); var departmentUpdated = this.departmentController.UpdateDepartment(departmentRequest); this.kayakoApiRequest.Verify(x => x.ExecutePut <DepartmentCollection>(apiMethod, parameters.ToString()), Times.Once()); Assert.That(departmentUpdated, Is.EqualTo(departments.First())); }
public KnowledgebaseArticle CreateKnowledgebaseArticle(KnowledgebaseArticleRequest knowledgebaseArticleRequest) { RequestBodyBuilder parameters = PopulateRequestParameters(knowledgebaseArticleRequest, RequestTypes.Create); KnowledgebaseArticleCollection knowledgebaseArticles = Connector.ExecutePost <KnowledgebaseArticleCollection>(KnowledgebaseArticleBaseUrl, parameters.ToString()); if (knowledgebaseArticles != null && knowledgebaseArticles.Count > 0) { return(knowledgebaseArticles[0]); } return(null); }
public Ticket UpdateTicket(TicketRequest request) { request.EnsureValidData(RequestTypes.Update); RequestBodyBuilder parameters = new RequestBodyBuilder(); if (!String.IsNullOrEmpty(request.Subject)) { parameters.AppendRequestData("subject", request.Subject); } if (!String.IsNullOrEmpty(request.FullName)) { parameters.AppendRequestData("fullname", request.FullName); } if (!String.IsNullOrEmpty(request.Email)) { parameters.AppendRequestData("email", request.Email); } if (request.DepartmentId != null) { parameters.AppendRequestData("departmentid", request.DepartmentId); } if (request.TicketStatusId != null) { parameters.AppendRequestData("ticketstatusid", request.TicketStatusId); } if (request.TicketPriorityId != null) { parameters.AppendRequestData("ticketpriorityid", request.TicketPriorityId); } if (request.TicketTypeId != null) { parameters.AppendRequestData("tickettypeid", request.TicketTypeId); } if (request.OwnerStaffId != null) { parameters.AppendRequestData("ownerstaffid", request.OwnerStaffId); } if (request.UserId != null) { parameters.AppendRequestData("userid", request.UserId); } if (request.TemplateGroupId != null) { parameters.AppendRequestData("templategroup", request.TemplateGroupId); } else if(!string.IsNullOrEmpty(request.TemplateGroupName)) { parameters.AppendRequestData("templategroup", request.TemplateGroupName); } string apiMethod = String.Format("/Tickets/Ticket/{0}", request.Id); TicketCollection tickets = Connector.ExecutePut<TicketCollection>(apiMethod, parameters.ToString()); if (tickets != null && tickets.Count > 0) { return tickets[0]; } return null; }
public KnowledgebaseAttachment CreateKnowledgebaseAttachment(KnowledgebaseAttachmentRequest knowledgebaseAttachmentRequest) { const string apiMethod = KnowledgebaseAttachmentBaseUrl; RequestBodyBuilder parameters = PopulateRequestParameters(knowledgebaseAttachmentRequest, RequestTypes.Create); KnowledgebaseAttachmentCollection knowledgebaseAttachments = Connector.ExecutePost <KnowledgebaseAttachmentCollection>(apiMethod, parameters.ToString()); if (knowledgebaseAttachments != null && knowledgebaseAttachments.Count > 0) { return(knowledgebaseAttachments[0]); } return(null); }
/// <summary> /// Create a new Staff record /// </summary> /// <param name="staffUser">Data representing the new staff</param> /// <param name="password">The staff password </param> /// <returns></returns> public StaffUser CreateStaffUser(StaffUserRequest staffUser) { string apiMethod = "/Base/Staff/"; RequestBodyBuilder parameters = PopulateRequestParameters(staffUser, RequestTypes.Create); StaffUserCollection staff = Connector.ExecutePost <StaffUserCollection>(apiMethod, parameters.ToString()); if (staff != null && staff.Count > 0) { return(staff[0]); } return(null); }
/// <summary> /// Update the department identified by its internal identifier /// </summary> /// <param name="dept">Data to update the department. Department Id and Title must be supplied</param> /// <returns>Department data representing the updated department</returns> public Department UpdateDepartment(DepartmentRequest dept) { string apiMethod = String.Format("{0}/{1}", ApiBaseMethods.Departments, dept.Id); RequestBodyBuilder parameters = PopulateRequestParameters(dept, RequestTypes.Update); DepartmentCollection depts = Connector.ExecutePut <DepartmentCollection>(apiMethod, parameters.ToString()); if (depts != null && depts.Count > 0) { return(depts[0]); } return(null); }
/// <summary> /// Run a search on Users. You can search users from email, full name, phone, organization name and user group. /// </summary> public UserCollection UserSearch(string query) { string apiMethod = "/Base/UserSearch"; RequestBodyBuilder parameters = new RequestBodyBuilder(); parameters.AppendRequestData("query", query); UserCollection users = Connector.ExecutePost<UserCollection>(apiMethod, parameters.ToString()); return users; }
/// <summary> /// Retrieve the user group identified by its unique identifier /// </summary> public UserGroup CreateUserGroup(UserGroupRequest userGroup) { string apiMethod = "/Base/UserGroup/"; RequestBodyBuilder parameters = PopulateRequestParameters(userGroup, RequestTypes.Create); UserGroupCollection userGroups = Connector.ExecutePost <UserGroupCollection>(apiMethod, parameters.ToString()); if (userGroups != null && userGroups.Count > 0) { return(userGroups[0]); } return(null); }
public NewsSubscriber CreateNewsSubscriber(NewsSubscriberRequest newsSubscriberRequest) { RequestBodyBuilder parameters = PopulateRequestParameters(newsSubscriberRequest, RequestTypes.Create); NewsSubscriberCollection newsSubscriber = Connector.ExecutePost <NewsSubscriberCollection>(NewsSubscriberBaseUrl, parameters.ToString()); if (newsSubscriber != null && newsSubscriber.Count > 0) { return(newsSubscriber[0]); } return(null); }
/// <summary> /// Update the staff group identified by its internal identifer /// </summary> /// <param name="staffGroup">Data representing the staff group to update. Staff Group Id and Title must be supplied</param> /// <returns></returns> public StaffGroup UpdateStaffGroup(StaffGroupRequest staffGroup) { string apiMethod = String.Format("/Base/StaffGroup/{0}", staffGroup.Id); RequestBodyBuilder parameters = PopulateRequestParameters(staffGroup, RequestTypes.Update); StaffGroupCollection staffGroups = Connector.ExecutePut <StaffGroupCollection>(apiMethod, parameters.ToString()); if (staffGroups != null && staffGroups.Count > 0) { return(staffGroups[0]); } return(null); }
/// <summary> /// Create a new user organization record /// </summary> /// <remarks> /// See - http://wiki.kayako.com/display/DEV/REST+-+UserOrganization#REST-UserOrganization-POST%2FBase%2FUserOrganization /// </remarks> /// <param name="org">Organisation to create</param> /// <returns>Added organisation.</returns> public UserOrganization CreateUserOrganization(UserOrganizationRequest org) { string apiMethod = "/Base/UserOrganization"; RequestBodyBuilder parameters = PopulateRequestParameters(org, RequestTypes.Create); UserOrganizationCollection orgs = Connector.ExecutePost <UserOrganizationCollection>(apiMethod, parameters.ToString()); if (orgs.Count > 0) { return(orgs[0]); } return(null); }
public NewsCategory UpdateNewsCategory(NewsCategoryRequest newsCategoryRequest) { string apiMethod = String.Format("{0}/{1}", NewsCategoryBaseUrl, newsCategoryRequest.Id); RequestBodyBuilder parameters = PopulateRequestParameters(newsCategoryRequest, RequestTypes.Update); NewsCategoryCollection newsCategories = Connector.ExecutePut <NewsCategoryCollection>(apiMethod, parameters.ToString()); if (newsCategories != null && newsCategories.Count > 0) { return(newsCategories[0]); } return(null); }
/// <summary> /// Update the user organization identified by its unique identifier /// </summary> /// <param name="org"></param> /// <returns></returns> public UserOrganization UpdateUserOrganization(UserOrganizationRequest org) { string apiMethod = String.Format("/Base/UserOrganization/{0}", org.Id); RequestBodyBuilder parameters = PopulateRequestParameters(org, RequestTypes.Update); UserOrganizationCollection orgs = Connector.ExecutePut <UserOrganizationCollection>(apiMethod, parameters.ToString()); if (orgs != null && orgs.Count > 0) { return(orgs[0]); } return(null); }
public NewsSubscriber UpdateNewsSubscriber(NewsSubscriberRequest newsSubscriberRequest) { string apiMethod = string.Format("{0}/{1}", NewsSubscriberBaseUrl, newsSubscriberRequest.Id); RequestBodyBuilder parameters = PopulateRequestParameters(newsSubscriberRequest, RequestTypes.Update); NewsSubscriberCollection newsSubscriber = Connector.ExecutePut <NewsSubscriberCollection>(apiMethod, parameters.ToString()); if (newsSubscriber != null && newsSubscriber.Count > 0) { return(newsSubscriber[0]); } return(null); }
public Ticket UpdateTicket(TicketRequest request) { request.EnsureValidData(RequestTypes.Update); RequestBodyBuilder parameters = new RequestBodyBuilder(); if (!String.IsNullOrEmpty(request.Subject)) { parameters.AppendRequestData("subject", request.Subject); } if (!String.IsNullOrEmpty(request.FullName)) { parameters.AppendRequestData("fullname", request.FullName); } if (!String.IsNullOrEmpty(request.Email)) { parameters.AppendRequestData("email", request.Email); } if (request.DepartmentId != null) { parameters.AppendRequestData("departmentid", request.DepartmentId); } if (request.TicketStatusId != null) { parameters.AppendRequestData("ticketstatusid", request.TicketStatusId); } if (request.TicketPriorityId != null) { parameters.AppendRequestData("ticketpriorityid", request.TicketPriorityId); } if (request.TicketTypeId != null) { parameters.AppendRequestData("tickettypeid", request.TicketTypeId); } if (request.OwnerStaffId != null) { parameters.AppendRequestData("ownerstaffid", request.OwnerStaffId); } if (request.UserId != null) { parameters.AppendRequestData("userid", request.UserId); } if (request.TemplateGroupId != null) { parameters.AppendRequestData("templategroup", request.TemplateGroupId); } else if (!string.IsNullOrEmpty(request.TemplateGroupName)) { parameters.AppendRequestData("templategroup", request.TemplateGroupName); } string apiMethod = String.Format("/Tickets/Ticket/{0}", request.Id); TicketCollection tickets = Connector.ExecutePut <TicketCollection>(apiMethod, parameters.ToString()); if (tickets != null && tickets.Count > 0) { return(tickets[0]); } return(null); }
public NewsCategory CreateNewsCategory(NewsCategoryRequest newsCategoryRequest) { RequestBodyBuilder parameters = PopulateRequestParameters(newsCategoryRequest, RequestTypes.Create); NewsCategoryCollection newsCategories = Connector.ExecutePost <NewsCategoryCollection>(NewsCategoryBaseUrl, parameters.ToString()); if (newsCategories != null && newsCategories.Count > 0) { return(newsCategories[0]); } return(null); }
public TroubleshooterStep UpdateTroubleshooterStep(TroubleshooterStepRequest troubleshooterStepRequest) { string apiMethod = String.Format("{0}/{1}", TroubleshooterStepBaseUrl, troubleshooterStepRequest.Id); RequestBodyBuilder parameters = PopulateRequestParameters(troubleshooterStepRequest, RequestTypes.Update); TroubleshooterStepCollection troubleshooterStep = Connector.ExecutePut <TroubleshooterStepCollection>(apiMethod, parameters.ToString()); if (troubleshooterStep != null && troubleshooterStep.Count > 0) { return(troubleshooterStep[0]); } return(null); }