/// <summary> /// Update the staff identified by <paramref name="staffUser" /> /// </summary> /// <remarks> /// http://wiki.kayako.com/display/DEV/REST+-+Staff#REST-Staff-PUT%2FBase%2FStaff%2F%24id%24 /// </remarks> /// <param name="staffUser">User to updated</param> /// <returns>Updated user.</returns> public StaffUser UpdateStaffUser(StaffUserRequest staffUser) { var apiMethod = string.Format("/Base/Staff/{0}", staffUser.Id); var parameters = PopulateRequestParameters(staffUser, RequestTypes.Update); var users = this.Connector.ExecutePut <StaffUserCollection>(apiMethod, parameters.ToString()); return(users.Count > 0 ? users[0] : null); }
/// <summary> /// Update the staff identified by <paramref name="staffUser"/> /// </summary> /// <remarks> /// http://wiki.kayako.com/display/DEV/REST+-+Staff#REST-Staff-PUT%2FBase%2FStaff%2F%24id%24 /// </remarks> /// <param name="staffUser">User to updated</param> /// <returns>Updated user.</returns> public StaffUser UpdateStaffUser(StaffUserRequest staffUser) { string apiMethod = String.Format("/Base/Staff/{0}", staffUser.Id); RequestBodyBuilder parameters = PopulateRequestParameters(staffUser, RequestTypes.Update); StaffUserCollection users = Connector.ExecutePut <StaffUserCollection>(apiMethod, parameters.ToString()); if (users.Count > 0) { return(users[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); }
public void CreateUpdateDeleteStaffUser() { StaffUser dummyStaffUser = TestData; StaffUserRequest req = StaffUserRequest.FromResponseData(dummyStaffUser); req.Password = "******"; StaffUser createdStaffUser = TestSetup.KayakoApiService.Staff.CreateStaffUser(req); Assert.IsNotNull(createdStaffUser); dummyStaffUser.Id = createdStaffUser.Id; CompareStaffUsers(dummyStaffUser, createdStaffUser); dummyStaffUser.Designation = "Mrs"; dummyStaffUser.Email = "*****@*****.**"; dummyStaffUser.EnableDst = false; dummyStaffUser.FirstName = "UpdatedFirstName"; dummyStaffUser.Greeting = "UpdatedGreetingtext"; StaffGroupCollection staffGroups = TestSetup.KayakoApiService.Staff.GetStaffGroups(); dummyStaffUser.GroupId = staffGroups[staffGroups.Count - 1].Id; dummyStaffUser.IsEnabled = false; dummyStaffUser.LastName = "UpdatedLastName"; dummyStaffUser.MobileNumber = "0798765432"; //Can't test signature as it doesn't come back from the Api //dummyStaffUser.Signature = "Signature Updated"; dummyStaffUser.TimeZone = "GMT BST"; dummyStaffUser.UserName = "******"; StaffUser updatedStaffUser = TestSetup.KayakoApiService.Staff.UpdateStaffUser(StaffUserRequest.FromResponseData(dummyStaffUser)); dummyStaffUser.FullName = String.Format("{0} {1}", dummyStaffUser.FirstName, dummyStaffUser.LastName); Assert.IsNotNull(updatedStaffUser); CompareStaffUsers(dummyStaffUser, updatedStaffUser); bool success = TestSetup.KayakoApiService.Staff.DeleteStaffUser(updatedStaffUser.Id); Assert.IsTrue(success); }
public void CreateUpdateDeleteStaffUser() { var dummyStaffUser = this.TestData; var req = StaffUserRequest.FromResponseData(dummyStaffUser); req.Password = "******"; var createdStaffUser = TestSetup.KayakoApiService.Staff.CreateStaffUser(req); Assert.IsNotNull(createdStaffUser); dummyStaffUser.Id = createdStaffUser.Id; this.CompareStaffUsers(dummyStaffUser, createdStaffUser); dummyStaffUser.Designation = "Mrs"; dummyStaffUser.Email = "*****@*****.**"; dummyStaffUser.EnableDst = false; dummyStaffUser.FirstName = "UpdatedFirstName"; dummyStaffUser.Greeting = "UpdatedGreetingtext"; var staffGroups = TestSetup.KayakoApiService.Staff.GetStaffGroups(); dummyStaffUser.GroupId = staffGroups[^ 1].Id;
private static RequestBodyBuilder PopulateRequestParameters(StaffUserRequest staffUser, RequestTypes requestType) { staffUser.EnsureValidData(requestType); RequestBodyBuilder parameters = new RequestBodyBuilder(); if (!String.IsNullOrEmpty(staffUser.FirstName)) { parameters.AppendRequestData("firstname", staffUser.FirstName); } if (!String.IsNullOrEmpty(staffUser.LastName)) { parameters.AppendRequestData("lastname", staffUser.LastName); } if (!String.IsNullOrEmpty(staffUser.UserName)) { parameters.AppendRequestData("username", staffUser.UserName); } if (!String.IsNullOrEmpty(staffUser.Password)) { parameters.AppendRequestData("password", staffUser.Password); } if (staffUser.GroupId > 0) { parameters.AppendRequestData("staffgroupid", staffUser.GroupId); } if (!String.IsNullOrEmpty(staffUser.Email)) { parameters.AppendRequestData("email", staffUser.Email); } if (!String.IsNullOrEmpty(staffUser.Designation)) { parameters.AppendRequestData("designation", staffUser.Designation); } if (!String.IsNullOrEmpty(staffUser.MobileNumber)) { parameters.AppendRequestData("mobilenumber", staffUser.MobileNumber); } parameters.AppendRequestData("isenabled", Convert.ToInt32(staffUser.IsEnabled)); if (!String.IsNullOrEmpty(staffUser.Greeting)) { parameters.AppendRequestData("greeting", staffUser.Greeting); } if (!String.IsNullOrEmpty(staffUser.Signature)) { parameters.AppendRequestData("staffsignature", staffUser.Signature); } if (!String.IsNullOrEmpty(staffUser.TimeZone)) { parameters.AppendRequestData("timezone", staffUser.TimeZone); } parameters.AppendRequestData("enabledst", Convert.ToInt32(staffUser.EnableDst)); return(parameters); }