/// <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; }
private static RequestBodyBuilder PopulateRequestParameters(UserOrganizationRequest org, RequestTypes requestType) { org.EnsureValidData(requestType); RequestBodyBuilder parameters = new RequestBodyBuilder(); parameters.AppendRequestData("name", org.Name); parameters.AppendRequestData("organizationtype", EnumUtility.ToApiString(org.OrganizationType)); if (!String.IsNullOrEmpty(org.Address)) { parameters.AppendRequestData("address", org.Address); } if (!String.IsNullOrEmpty(org.City)) { parameters.AppendRequestData("city", org.City); } if (!String.IsNullOrEmpty(org.State)) { parameters.AppendRequestData("state", org.State); } if (!String.IsNullOrEmpty(org.PostalCode)) { parameters.AppendRequestData("postalcode", org.PostalCode); } if (!String.IsNullOrEmpty(org.Country)) { parameters.AppendRequestData("country", org.Country); } if (!String.IsNullOrEmpty(org.Phone)) { parameters.AppendRequestData("phone", org.Phone); } if (!String.IsNullOrEmpty(org.Fax)) { parameters.AppendRequestData("fax", org.Fax); } if (!String.IsNullOrEmpty(org.Website)) { parameters.AppendRequestData("website", org.Website); } if (org.SlaPlanId != null) { parameters.AppendRequestData("slaplanid", org.SlaPlanId); } if (org.SlaPlanExpiry != null) { parameters.AppendRequestData("slaplanexpiry", org.SlaPlanExpiry); } return parameters; }
/// <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 static UserOrganization ToResponseData(UserOrganizationRequest requestData) => ToResponseType <UserOrganizationRequest, UserOrganization>(requestData);
public static UserOrganization ToResponseData(UserOrganizationRequest requestData) { return(UserOrganizationRequest.ToResponseType <UserOrganizationRequest, UserOrganization>(requestData)); }
public static UserOrganizationRequest FromResponseData(UserOrganization responseData) { return(UserOrganizationRequest.FromResponseType <UserOrganization, UserOrganizationRequest>(responseData)); }
public static UserOrganization ToResponseData(UserOrganizationRequest requestData) { return UserOrganizationRequest.ToResponseType<UserOrganizationRequest, UserOrganization>(requestData); }