Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed an issue where a user could not be rolled out of the enterprise. #709

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion Box.V2/Converter/BoxJsonConverter.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using Box.V2.Config;
using Box.V2.Config;
using Newtonsoft.Json;
using System;
using System.Collections.Generic;
Expand Down Expand Up @@ -43,6 +43,13 @@ public T Parse<T>(string content)
/// <returns>JSON string</returns>
public string Serialize<T>(T entity)
{
if (entity is Box.V2.Models. BoxUserRollOutRequest)
{
return JsonConvert.SerializeObject(entity, new JsonSerializerSettings()
{
DateFormatString = Constants.RFC3339DateFormat
});
}
return JsonConvert.SerializeObject(entity, _settings);
}
}
Expand Down
7 changes: 4 additions & 3 deletions Box.V2/Managers/BoxUsersManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -58,12 +58,13 @@ public async Task<BoxUser> CreateEnterpriseUserAsync(BoxUserRequest userRequest,

/// <summary>
/// Used to edit the settings and information about a user. This method only works for enterprise admins. To roll a user out
/// of the enterprise (and convert them to a standalone free user), update the special enterprise attribute to be null.
/// of the enterprise (and convert them to a standalone free user), use the BoxUserRollOutRequest object for user request and set their user ID.
/// </summary>
/// <param name="userRequest">BoxUserRequest object.</param>
/// <typeparam name="T">The type of Request to make. Must inherit from BoxRequestEntity</typeparam>
/// <param name="userRequest">An object that inherits from the class BoxRequestEntity. At this point only BoxUserRequest and BoxUserRollOutRequest.</param>
/// <param name="fields">Attribute(s) to include in the response.</param>
/// <returns>Returns the user object for the updated user. Errors may be thrown when the fields are invalid or this API call is made from a non-admin account.</returns>
public async Task<BoxUser> UpdateUserInformationAsync(BoxUserRequest userRequest, IEnumerable<string> fields = null)
public async Task<BoxUser> UpdateUserInformationAsync<T>(T userRequest, IEnumerable<string> fields = null) where T : BoxRequestEntity
{
userRequest.ThrowIfNull("userRequest")
.Id.ThrowIfNullOrWhiteSpace("userRequest.Id");
Expand Down
19 changes: 19 additions & 0 deletions Box.V2/Models/Request/BoxUserRollOutRequest.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
using Newtonsoft.Json;
using System.Collections.Generic;


namespace Box.V2.Models
{
/// <summary>
/// A request class for rolling users out of box
/// </summary>
public class BoxUserRollOutRequest : BoxRequestEntity
{
/// <summary>
/// Setting this to null will roll the user out of the enterprise and make them a free user
/// </summary>
[JsonProperty(PropertyName = "enterprise")]
public string Enterprise { get; set; }

}
}
16 changes: 16 additions & 0 deletions docs/users.md
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,22 @@ var updates = new BoxUserRequest()
BoxUser updatedUser = await client.UsersManager.UpdateUserInformationAsync(updates);
```

Roll User Out of Enterprise
---------------------------

To update a user's information, call
`UsersManager.UpdateUserInformationAsync(BoxUserRollOutRequest userRequest, IEnumerable<string> fields = null)`
with only the id.

<!-- sample put_users_id -->
```c#
var updates = new BoxUserRollOutRequest()
{
Id = "44444"
};
BoxUser updatedUser = await client.UsersManager.UpdateUserInformationAsync(updates);
```

Delete User
-----------

Expand Down