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; }
/// <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 static StaffUser ToResponseData(StaffUserRequest requestData) { return StaffUserRequest.ToResponseType<StaffUserRequest, StaffUser>(requestData); }
public static StaffUser ToResponseData(StaffUserRequest requestData) => ToResponseType <StaffUserRequest, StaffUser>(requestData);
public static StaffUser ToResponseData(StaffUserRequest requestData) { return(StaffUserRequest.ToResponseType <StaffUserRequest, StaffUser>(requestData)); }
public static StaffUserRequest FromResponseData(StaffUser responseData) { return(StaffUserRequest.FromResponseType <StaffUser, StaffUserRequest>(responseData)); }