From 59c35042f2e823dd46790f25baf3254c45faa83d Mon Sep 17 00:00:00 2001 From: carycheng77 Date: Wed, 20 Dec 2017 14:16:38 -0800 Subject: [PATCH] added two test cases and minor change to the documentation for single file collaboration (#425) --- ...BoxCollaborationsManagerTestIntegration.cs | 43 +++++++++++++++++++ Box.V2/Managers/BoxCollaborationsManager.cs | 2 +- .../Models/Request/BoxCollaborationRequest.cs | 2 +- 3 files changed, 45 insertions(+), 2 deletions(-) diff --git a/Box.V2.Test.Integration/BoxCollaborationsManagerTestIntegration.cs b/Box.V2.Test.Integration/BoxCollaborationsManagerTestIntegration.cs index a6d119df0..0c142506a 100644 --- a/Box.V2.Test.Integration/BoxCollaborationsManagerTestIntegration.cs +++ b/Box.V2.Test.Integration/BoxCollaborationsManagerTestIntegration.cs @@ -59,6 +59,49 @@ public async Task CollaborationsOnFolderWorkflow_LiveSession_ValidResponse() Assert.IsTrue(success, "Collaboration deletion was unsucessful"); } + // Test to add collaboration by Box User ID and Box Group ID. + [TestMethod] + public async Task AddGroupCollaboration_File_Fields_ValidResponse() + { + const string fileId = "238288183114"; + const string groupId = "176708848"; + const string userId = "349294186"; + + // Add Group Collaboration + BoxCollaborationRequest addGroupRequest = new BoxCollaborationRequest() + { + Item = new BoxRequestEntity() + { + Id = fileId, + Type = BoxType.file + }, + AccessibleBy = new BoxCollaborationUserRequest() + { + Type = BoxType.group, + Id = groupId + }, + Role = "viewer" + }; + + //Add User Collaboration + BoxCollaborationRequest addUserRequest = new BoxCollaborationRequest() + { + Item = new BoxRequestEntity() + { + Id = fileId, + Type = BoxType.file + }, + AccessibleBy = new BoxCollaborationUserRequest() + { + Type = BoxType.user, + Id = userId + }, + Role = "editor" + }; + var groupFileCollaboration = await _client.CollaborationsManager.AddCollaborationAsync(addGroupRequest, notify: false); + var userFileCollaboration = await _client.CollaborationsManager.AddCollaborationAsync(addUserRequest, notify: false); + } + [TestMethod] public async Task CollaborationsOnFileWorkflow_LiveSession_ValidResponse() { diff --git a/Box.V2/Managers/BoxCollaborationsManager.cs b/Box.V2/Managers/BoxCollaborationsManager.cs index e7f2e9cb4..232299ad7 100644 --- a/Box.V2/Managers/BoxCollaborationsManager.cs +++ b/Box.V2/Managers/BoxCollaborationsManager.cs @@ -19,7 +19,7 @@ public BoxCollaborationsManager(IBoxConfig config, IBoxService service, IBoxConv : base(config, service, converter, auth, asUser, suppressNotifications) { } /// - /// Used to add a collaboration for a single user or a single group to a folder. + /// Used to add a collaboration for a single user or a single group to a folder or file. /// Either an email address, a user ID, or a group id can be used to create the collaboration. /// If the collaboration is being created with a group, access to this endpoint is granted based on the group's invitability_level. /// diff --git a/Box.V2/Models/Request/BoxCollaborationRequest.cs b/Box.V2/Models/Request/BoxCollaborationRequest.cs index 65879f246..4a8613232 100644 --- a/Box.V2/Models/Request/BoxCollaborationRequest.cs +++ b/Box.V2/Models/Request/BoxCollaborationRequest.cs @@ -9,7 +9,7 @@ public class BoxCollaborationRequest : BoxRequestEntity { /// /// The item to add the collaboration on - /// The ID and Type are required. The Type MUST also be folder + /// The ID and Type are required. The Type can be folder or file. /// [JsonProperty(PropertyName = "item")] public BoxRequestEntity Item { get; set; }