/// <summary> /// Create a new user under the specified domain under the default user group. /// </summary> /// <param name="newUser"></param> /// <returns></returns> public User CreateUserInDomain(User newUser) { RestRequest request = new RestRequest(string.Format("/domains/{0}/users.xml", newUser.domain_id), Method.POST); request.AddParameter("user[name]", newUser.name); if (!string.IsNullOrEmpty(newUser.user_type)) request.AddParameter("user[user_type]", newUser.user_type); if (!string.IsNullOrEmpty(newUser.first_name)) request.AddParameter("user[first_name]", newUser.first_name); if (!string.IsNullOrEmpty(newUser.last_name)) request.AddParameter("user[last_name]", newUser.last_name); if (!string.IsNullOrEmpty(newUser.password)) request.AddParameter("user[password]", newUser.password); if (newUser.parent_id > 0) request.AddParameter("user[parent_id]", newUser.parent_id); IRestResponse<User> response = client.Execute<User>(request); response.HandleErrors(); return response.Data; }
/// <summary> /// Create a new user under the specified user group. /// </summary> /// <param name="newUser"></param> /// <returns></returns> public User CreateUserInGroup(User newUser) { RestRequest request = new RestRequest(string.Format("/user_groups/{0}/users.xml", newUser.user_group_id), Method.POST); request.AddParameter("name", newUser.name); request.AddParameter("user_type", newUser.user_type); if (!string.IsNullOrEmpty(newUser.first_name)) request.AddParameter("first_name", newUser.first_name); if (!string.IsNullOrEmpty(newUser.last_name)) request.AddParameter("last_name", newUser.last_name); if (!string.IsNullOrEmpty(newUser.password)) request.AddParameter("password", newUser.password); if (newUser.parent_id > 0) request.AddParameter("parent_id", newUser.parent_id); IRestResponse<User> response = client.Execute<User>(request); response.HandleErrors(); return response.Data; }