diff --git a/Box.V2.Test.Integration/BoxFilesManagerIntegrationTest.cs b/Box.V2.Test.Integration/BoxFilesManagerIntegrationTest.cs index bc9f3fa53..daaddb07c 100644 --- a/Box.V2.Test.Integration/BoxFilesManagerIntegrationTest.cs +++ b/Box.V2.Test.Integration/BoxFilesManagerIntegrationTest.cs @@ -181,12 +181,12 @@ await Retry(async () => [TestMethod] [ExpectedException(typeof(TimeoutException))] - public async Task DownloadStreamAsync_ForTimeoutShorterThanDownloadTime_ShouldAbortDownload() + public async Task DownloadAsync_ForTimeoutShorterThanDownloadTime_ShouldAbortDownload() { var uploadedFile = await CreateSmallFile(FolderId); var timeout = new TimeSpan(0, 0, 0, 0, 1); - await UserClient.FilesManager.DownloadStreamAsync(uploadedFile.Id, timeout: timeout); + await UserClient.FilesManager.DownloadAsync(uploadedFile.Id, timeout: timeout); } [TestMethod] diff --git a/Box.V2.Test.Integration/BoxSearchManagerIntegrationTest.cs b/Box.V2.Test.Integration/BoxSearchManagerIntegrationTest.cs index 352fa7ad9..49f656d13 100644 --- a/Box.V2.Test.Integration/BoxSearchManagerIntegrationTest.cs +++ b/Box.V2.Test.Integration/BoxSearchManagerIntegrationTest.cs @@ -13,7 +13,7 @@ public async Task SearchAsync_ForNonExistentKeyword_ShouldReturnNoResults() { const string Keyword = "NonExistentKeyWord"; - BoxCollection results = await UserClient.SearchManager.SearchAsync(Keyword, 200); + BoxCollection results = await UserClient.SearchManager.QueryAsync(Keyword, limit: 200); Assert.IsNotNull(results); Assert.AreEqual(0, results.Entries.Count); diff --git a/Box.V2.Test/BoxCCGAuthTest.cs b/Box.V2.Test/BoxCCGAuthTest.cs index f8e3d6c18..3e7b0eb45 100644 --- a/Box.V2.Test/BoxCCGAuthTest.cs +++ b/Box.V2.Test/BoxCCGAuthTest.cs @@ -29,7 +29,6 @@ public BoxCCGAuthTest() _boxConfig.SetupGet(x => x.ClientId).Returns("123"); _boxConfig.SetupGet(x => x.ClientSecret).Returns("SECRET"); _boxConfig.SetupGet(x => x.BoxApiHostUri).Returns(new Uri(Constants.BoxApiHostUriString)); - _boxConfig.SetupGet(x => x.BoxAuthTokenApiUri).Returns(new Uri(Constants.BoxAuthTokenApiUriString)); _ccgAuth = new BoxCCGAuth(_boxConfig.Object, _service); } diff --git a/Box.V2.Test/BoxConfigTest.cs b/Box.V2.Test/BoxConfigTest.cs index 7bc7c027b..66141bf79 100644 --- a/Box.V2.Test/BoxConfigTest.cs +++ b/Box.V2.Test/BoxConfigTest.cs @@ -31,9 +31,9 @@ public void BoxConfig_SetUriString() var exampleUri = new Uri("https://example.com/"); config = BoxConfigBuilder.CreateFromJsonString(JsonString) - .SetBoxApiUri(exampleUri) + .SetBoxApiHostUri(exampleUri) .Build(); - Assert.AreEqual(config.BoxApiUri, exampleUri); + Assert.AreEqual(config.BoxApiUri, exampleUri + "2.0/"); } [TestMethod] @@ -63,20 +63,6 @@ public void BoxConfig_CreateFromString() Assert.AreEqual(config.EnterpriseId, "eid-123"); } - [TestMethod] - public void BoxConfig_SetAuthTokenUriString() - { - var boxConfig = new BoxConfigBuilder("", "") - .Build(); - Assert.AreEqual(boxConfig.BoxAuthTokenApiUri, new Uri(Constants.BoxAuthTokenApiUriString)); - - var exampleUri = new Uri("https://example.com/token"); - var newConfig = new BoxConfigBuilder("", "") - .SetBoxTokenApiUri(exampleUri) - .Build(); - Assert.AreEqual(newConfig.BoxAuthTokenApiUri.ToString(), exampleUri + "/"); - } - [TestMethod] public void BoxConfig_SetBoxApiHostUri() { diff --git a/Box.V2.Test/BoxFilesManagerTest.cs b/Box.V2.Test/BoxFilesManagerTest.cs index f941464fc..2b15e7fcf 100644 --- a/Box.V2.Test/BoxFilesManagerTest.cs +++ b/Box.V2.Test/BoxFilesManagerTest.cs @@ -833,43 +833,6 @@ public async Task DeleteFile_ErrorResponse_Exception() } } - [TestMethod] - public async Task DownloadStream_ValidResponse_ValidStream() - { - - using (var exampleFile = new FileStream(string.Format(GetSaveFolderPath(), "example.png"), FileMode.OpenOrCreate)) - { - /*** Arrange ***/ - var location = new Uri("http://dl.boxcloud.com"); - var headers = new HttpResponseMessage().Headers; - headers.Location = location; - Handler.Setup(h => h.ExecuteAsync(It.IsAny())) - .Returns(Task.FromResult>(new BoxResponse() - { - Status = ResponseStatus.Success, - Headers = headers - - })); - IBoxRequest boxRequest = null; - Handler.Setup(h => h.ExecuteAsync(It.IsAny())) - .Returns(Task.FromResult>(new BoxResponse() - { - Status = ResponseStatus.Success, - ResponseObject = exampleFile - - })) - .Callback(r => boxRequest = r); ; - - /*** Act ***/ - Stream result = await _filesManager.DownloadStreamAsync("34122832467"); - - /*** Assert ***/ - - Assert.IsNotNull(result, "Stream is Null"); - - } - } - [TestMethod] public async Task Download_LargeOffset_ValidStream() { diff --git a/Box.V2.Test/BoxFoldersManagerTest.cs b/Box.V2.Test/BoxFoldersManagerTest.cs index b373acc79..ad0f3acd4 100644 --- a/Box.V2.Test/BoxFoldersManagerTest.cs +++ b/Box.V2.Test/BoxFoldersManagerTest.cs @@ -75,60 +75,6 @@ public async Task GetFolderItems_ValidResponse_SortDirection() Assert.AreEqual("DESC", boxRequest.Parameters["direction"]); } - [TestMethod] - public async Task GetFolder_ValidResponse_ValidFolder() - { - Handler.Setup(h => h.ExecuteAsync(It.IsAny())) - .Returns(() => Task.FromResult>(new BoxResponse() - { - Status = ResponseStatus.Success, - ContentString = "{ \"type\":\"folder\", \"id\":\"0\", \"sequence_id\":null, \"etag\":null, \"name\":\"All Files\", \"created_at\":null, \"modified_at\":null, \"description\":\"\", \"size\":61591428468, \"path_collection\":{ \"total_count\":0, \"entries\":[ ] }, \"created_by\":{ \"type\":\"user\", \"id\":\"189912110\", \"name\":\"Brian\", \"login\":\"brianytang@gmail.com\" }, \"modified_by\":{ \"type\":\"user\", \"id\":\"189912110\", \"name\":\"Brian\", \"login\":\"brianytang@gmail.com\" }, \"trashed_at\":null, \"purged_at\":null, \"content_created_at\":null, \"content_modified_at\":null, \"owned_by\":{ \"type\":\"user\", \"id\":\"189912110\", \"name\":\"Brian\", \"login\":\"brianytang@gmail.com\" }, \"shared_link\":null, \"folder_upload_email\":null, \"parent\":null, \"item_status\":\"active\", \"item_collection\":{ \"total_count\":10, \"entries\":[ { \"type\":\"folder\", \"id\":\"766352168\", \"sequence_id\":\"0\", \"etag\":\"0\", \"name\":\"Books\" }, { \"type\":\"folder\", \"id\":\"869883498\", \"sequence_id\":\"0\", \"etag\":\"0\", \"name\":\"bytLabs\" }, { \"type\":\"folder\", \"id\":\"767221958\", \"sequence_id\":\"0\", \"etag\":\"0\", \"name\":\"Games\" }, { \"type\":\"folder\", \"id\":\"766174084\", \"sequence_id\":\"0\", \"etag\":\"0\", \"name\":\"Mixes\" }, { \"type\":\"folder\", \"id\":\"57181304\", \"sequence_id\":\"0\", \"etag\":\"0\", \"name\":\"Muzik\" }, { \"type\":\"folder\", \"id\":\"857305570\", \"sequence_id\":\"0\", \"etag\":\"0\", \"name\":\"My\" }, { \"type\":\"folder\", \"id\":\"627316229\", \"sequence_id\":\"1\", \"etag\":\"1\", \"name\":\"My Music Folder\" }, { \"type\":\"folder\", \"id\":\"860155462\", \"sequence_id\":\"0\", \"etag\":\"0\", \"name\":\"sample\" }, { \"type\":\"folder\", \"id\":\"775829294\", \"sequence_id\":\"0\", \"etag\":\"0\", \"name\":\"Software\" }, { \"type\":\"folder\", \"id\":\"811565831\", \"sequence_id\":\"0\", \"etag\":\"0\", \"name\":\"Test\" } ], \"offset\":0, \"limit\":10, \"order\":[ { \"by\":\"type\", \"direction\":\"ASC\" }, { \"by\":\"name\", \"direction\":\"ASC\" } ] } }" - })); - - BoxFolder f = await _foldersManager.GetItemsAsync("0", 10); - - Assert.AreEqual(f.Id, "0"); - Assert.AreEqual(f.Type, "folder"); - Assert.IsNull(f.SequenceId); - Assert.IsNull(f.ETag); - Assert.IsNull(f.CreatedAt); - Assert.IsNull(f.ModifiedAt); - Assert.AreEqual(f.Description, ""); - Assert.AreEqual(f.Size, 61591428468); - Assert.AreEqual(f.PathCollection.TotalCount, 0); - Assert.AreEqual(f.PathCollection.Entries.Count, 0); - Assert.AreEqual(f.CreatedBy.Type, "user"); - Assert.AreEqual(f.CreatedBy.Id, "189912110"); - Assert.AreEqual(f.CreatedBy.Name, "Brian"); - Assert.AreEqual(f.CreatedBy.Login, "brianytang@gmail.com"); - Assert.AreEqual(f.ModifiedBy.Type, "user"); - Assert.AreEqual(f.ModifiedBy.Id, "189912110"); - Assert.AreEqual(f.ModifiedBy.Name, "Brian"); - Assert.AreEqual(f.ModifiedBy.Login, "brianytang@gmail.com"); - //Assert.IsNull(f.TrashedAt); // Need to add property - //Assert.IsNull(f.PurgedAt); // Need to add property - //Assert.IsNull(f.ContentCreatedAt); // Need to add property - //Assert.IsNull(f.ContentModifiedAt); // Need to add property - Assert.AreEqual(f.OwnedBy.Type, "user"); - Assert.AreEqual(f.OwnedBy.Id, "189912110"); - Assert.AreEqual(f.OwnedBy.Name, "Brian"); - Assert.AreEqual(f.OwnedBy.Login, "brianytang@gmail.com"); - Assert.IsNull(f.SharedLink); - Assert.IsNull(f.FolderUploadEmail); - Assert.IsNull(f.Parent); - Assert.AreEqual(f.ItemStatus, "active"); - Assert.AreEqual(f.Id, "0"); - Assert.AreEqual(f.Name, "All Files"); - Assert.AreEqual(f.ModifiedBy.Id, "189912110"); - Assert.AreEqual(f.ItemCollection.TotalCount, 10); - Assert.AreEqual(f.ItemCollection.Entries.Count, 10); - //Assert.AreEqual(f.Offset, "0"); // Need to add property - //Assert.AreEqual(f.Order[0].By, "type"); // Need to add property - //Assert.AreEqual(f.Order[0].Direction, "ASC"); // Need to add property - //Assert.AreEqual(f.Order[1].By, "name"); // Need to add property - //Assert.AreEqual(f.Order[1].Direction, "ASC"); // Need to add property - } - [TestMethod] public async Task CreateFolder_ValidResponse_ValidFolder() { @@ -707,7 +653,7 @@ public async Task GetTrashedItems_ValidResponse_ValidFiles() })); /*** Act ***/ - BoxCollection i = await _foldersManager.GetTrashItemsAsync("fakeId", 10); + BoxCollection i = await _foldersManager.GetTrashItemsAsync(10); BoxItem i1 = i.Entries.FirstOrDefault(); BoxItem i2 = i.Entries.Skip(1).FirstOrDefault(); diff --git a/Box.V2.Test/BoxMetadataManagerTest.cs b/Box.V2.Test/BoxMetadataManagerTest.cs index 53cdd9ac7..d28bb1455 100644 --- a/Box.V2.Test/BoxMetadataManagerTest.cs +++ b/Box.V2.Test/BoxMetadataManagerTest.cs @@ -554,65 +554,6 @@ public async Task SetFolderMetadataAsync_Create_Error() } } - [TestMethod] - public async Task ExecuteMetadataQuery_ValidResponse() - { - /*** Arrange ***/ - IBoxRequest boxRequest = null; - Handler.Setup(h => h.ExecuteAsync>(It.IsAny())) - .Returns(Task.FromResult>>(new BoxResponse>() - { - Status = ResponseStatus.Success, - ContentString = LoadFixtureFromJson("Fixtures/BoxMetadata/ExecuteMetadataQuery200.json") - })) - .Callback(r => boxRequest = r); - - /*** Act ***/ - var queryParams = new Dictionary - { - { "arg", 100 } - }; - var orderByList = new List(); - var orderBy = new BoxMetadataQueryOrderBy() - { - FieldKey = "amount", - Direction = BoxSortDirection.ASC - }; - orderByList.Add(orderBy); - var marker = "q3f87oqf3qygou5t478g9gwrbul"; - BoxCollectionMarkerBased items = await _metadataManager.ExecuteMetadataQueryAsync(from: "enterprise_123456.someTemplate", query: "amount >= :arg", queryParameters: queryParams, ancestorFolderId: "5555", indexName: "amountAsc", orderBy: orderByList, marker: marker, autoPaginate: false); - /*** Assert ***/ - - // Request check - Assert.IsNotNull(boxRequest); - Assert.AreEqual(RequestMethod.Post, boxRequest.Method); - Assert.AreEqual(MetadataQueryUri, boxRequest.AbsoluteUri.AbsoluteUri); - var payload = JObject.Parse(boxRequest.Payload); - Assert.AreEqual("enterprise_123456.someTemplate", payload["from"]); - Assert.AreEqual("amount >= :arg", payload["query"]); - Assert.AreEqual(100, payload["query_params"]["arg"]); - Assert.AreEqual("5555", payload["ancestor_folder_id"]); - var payloadOrderBy = JArray.Parse(payload["order_by"].ToString()); - Assert.AreEqual("amount", payloadOrderBy[0]["field_key"]); - Assert.AreEqual("ASC", payloadOrderBy[0]["direction"]); - Assert.AreEqual(marker, payload["marker"]); - - // Response check - Assert.AreEqual(items.Entries[0].Item.Type, "file"); - Assert.AreEqual(items.Entries[0].Item.Id, "1617554169109"); - Assert.AreEqual(items.Entries[0].Item.Name, "My Contract.docx"); - Assert.AreEqual(items.Entries[0].Item.SequenceId, "0"); - Assert.AreEqual(items.Entries[0].Item.CreatedBy.Type, "user"); - Assert.AreEqual(items.Entries[0].Item.CreatedBy.Login, "admin@company.com"); - Assert.AreEqual(items.Entries[0].Item.Parent.Id, "16125613433"); - Assert.AreEqual(items.NextMarker, "AAAAAmVYB1FWec8GH6yWu2nwmanfMh07IyYInaa7DZDYjgO1H4KoLW29vPlLY173OKsci6h6xGh61gG73gnaxoS+o0BbI1/h6le6cikjlupVhASwJ2Cj0tOD9wlnrUMHHw3/ISf+uuACzrOMhN6d5fYrbidPzS6MdhJOejuYlvsg4tcBYzjauP3+VU51p77HFAIuObnJT0ff"); - var metadata = JObject.FromObject(items.Entries[0].Metadata["enterprise_123456"]); - Assert.AreEqual(metadata["someTemplate"]["$parent"], "file_161753469109"); - Assert.AreEqual(metadata["someTemplate"]["customerName"], "Phoenix Corp"); - Assert.AreEqual(metadata["someTemplate"]["$typeVersion"], 0); - Assert.AreEqual(metadata["someTemplate"]["region"], "West"); - } - [TestMethod] public async Task ExecuteMetadataQueryWithoutUseIndexWithFields_ValidResponse() { diff --git a/Box.V2.Test/BoxSearchManagerTest.cs b/Box.V2.Test/BoxSearchManagerTest.cs index 91e5045da..a37586b22 100644 --- a/Box.V2.Test/BoxSearchManagerTest.cs +++ b/Box.V2.Test/BoxSearchManagerTest.cs @@ -33,7 +33,7 @@ public async Task SearchKeyword_ValidResponse_ValidResults() .Callback(r => boxRequest = r); /*** Act ***/ - BoxCollection results = await SearchManager.SearchAsync("fakeKeyword", 10, sort: "modified_at", direction: BoxSortDirection.ASC); + BoxCollection results = await SearchManager.QueryAsync("fakeKeyword", limit: 10, sort: "modified_at", direction: BoxSortDirection.ASC); var queryParams = boxRequest.Parameters; /*** Assert ***/ Assert.AreEqual(4, results.TotalCount); @@ -41,54 +41,6 @@ public async Task SearchKeyword_ValidResponse_ValidResults() Assert.AreEqual("ASC", queryParams["direction"]); } - [TestMethod] - public async Task SearchWithDateRanges_ValidResponse_ValidResults() - { - /*** Arrange ***/ - var responseString = "{\"total_count\":4,\"entries\":[{\"type\":\"file\",\"id\":\"1874102965\",\"sequence_id\":\"0\",\"etag\":\"0\",\"sha1\":\"63a112a4567fb556f5269735102a2f24f2cbea56\",\"name\":\"football.jpg\",\"description\":\"\",\"size\":260271,\"path_collection\":{\"total_count\":1,\"entries\":[{\"type\":\"folder\",\"id\":\"0\",\"sequence_id\":null,\"etag\":null,\"name\":\"All Files\"}]},\"created_at\":\"2012-03-22T18:25:07-07:00\",\"modified_at\":\"2012-10-25T14:40:05-07:00\",\"created_by\":{\"type\":\"user\",\"id\":\"175065494\",\"name\":\"Andrew Luck\",\"login\":\"aluck@colts.com\"},\"modified_by\":{\"type\":\"user\",\"id\":\"175065494\",\"name\":\"Andrew Luck\",\"login\":\"aluck@colts.com\"},\"owned_by\":{\"type\":\"user\",\"id\":\"175065494\",\"name\":\"Andrew Luck\",\"login\":\"aluck@colts.com\"},\"shared_link\":null,\"parent\":{\"type\":\"folder\",\"id\":\"0\",\"sequence_id\":null,\"etag\":null,\"name\":\"All Files\"},\"item_status\":\"active\", \"sort\":\"modified_at\", \"direction\":\"ASC\"}],\"offset\":0,\"limit\":1}"; - IBoxRequest boxRequest = null; - - Handler.Setup(h => h.ExecuteAsync>(It.IsAny())) - .Returns(Task.FromResult>>(new BoxResponse>() - { - Status = ResponseStatus.Success, - ContentString = responseString - })) - .Callback(r => boxRequest = r); - - /*** Act ***/ - var startDate = new DateTimeOffset(1988, 11, 18, 9, 30, 0, TimeSpan.Zero); - var endDate = new DateTimeOffset(2018, 11, 18, 9, 30, 0, TimeSpan.Zero); - var results = await SearchManager.SearchAsync("test", createdAtRangeFromDate: startDate, createdAtRangeToDate: endDate, updatedAtRangeFromDate: startDate, updatedAtRangeToDate: endDate); - - /*** Assert ***/ - Assert.AreEqual("query=test&created_at_range=1988-11-18T09%3A30%3A00%2B00%3A00%2C2018-11-18T09%3A30%3A00%2B00%3A00&updated_at_range=1988-11-18T09%3A30%3A00%2B00%3A00%2C2018-11-18T09%3A30%3A00%2B00%3A00&limit=30&offset=0", boxRequest.GetQueryString()); - } - - [TestMethod] - public async Task SearchWithOpenDateRanges_ValidResponse_ValidResults() - { - /*** Arrange ***/ - var responseString = "{\"total_count\":4,\"entries\":[{\"type\":\"file\",\"id\":\"1874102965\",\"sequence_id\":\"0\",\"etag\":\"0\",\"sha1\":\"63a112a4567fb556f5269735102a2f24f2cbea56\",\"name\":\"football.jpg\",\"description\":\"\",\"size\":260271,\"path_collection\":{\"total_count\":1,\"entries\":[{\"type\":\"folder\",\"id\":\"0\",\"sequence_id\":null,\"etag\":null,\"name\":\"All Files\"}]},\"created_at\":\"2012-03-22T18:25:07-07:00\",\"modified_at\":\"2012-10-25T14:40:05-07:00\",\"created_by\":{\"type\":\"user\",\"id\":\"175065494\",\"name\":\"Andrew Luck\",\"login\":\"aluck@colts.com\"},\"modified_by\":{\"type\":\"user\",\"id\":\"175065494\",\"name\":\"Andrew Luck\",\"login\":\"aluck@colts.com\"},\"owned_by\":{\"type\":\"user\",\"id\":\"175065494\",\"name\":\"Andrew Luck\",\"login\":\"aluck@colts.com\"},\"shared_link\":null,\"parent\":{\"type\":\"folder\",\"id\":\"0\",\"sequence_id\":null,\"etag\":null,\"name\":\"All Files\"},\"item_status\":\"active\", \"sort\":\"modified_at\", \"direction\":\"ASC\"}],\"offset\":0,\"limit\":1}"; - IBoxRequest boxRequest = null; - - Handler.Setup(h => h.ExecuteAsync>(It.IsAny())) - .Returns(Task.FromResult>>(new BoxResponse>() - { - Status = ResponseStatus.Success, - ContentString = responseString - })) - .Callback(r => boxRequest = r); - - /*** Act ***/ - var startDate = new DateTimeOffset(1988, 11, 18, 9, 30, 0, TimeSpan.Zero); - var endDate = new DateTimeOffset(2018, 11, 18, 9, 30, 0, TimeSpan.Zero); - var results = await SearchManager.SearchAsync("test", createdAtRangeFromDate: startDate, updatedAtRangeToDate: endDate); - - /*** Assert ***/ - Assert.AreEqual("query=test&created_at_range=1988-11-18T09%3A30%3A00%2B00%3A00%2C&updated_at_range=%2C2018-11-18T09%3A30%3A00%2B00%3A00&limit=30&offset=0", boxRequest.GetQueryString()); - } - [TestMethod] public async Task Query_ValidResponse_ValidResults() { diff --git a/Box.V2.Test/BoxTasksManagerTest.cs b/Box.V2.Test/BoxTasksManagerTest.cs index d6868017f..2bfd8aa3b 100644 --- a/Box.V2.Test/BoxTasksManagerTest.cs +++ b/Box.V2.Test/BoxTasksManagerTest.cs @@ -270,8 +270,8 @@ public async Task GetTaskAssignment_TranslatedStatus() ""completed_at"": null, ""assigned_at"": ""2013-05-10T11:43:41-07:00"", ""reminded_at"": null, - ""resolution_state"": ""未完了"", - ""status"": ""incomplete"", + ""resolution_state"": ""incomplete"", + ""status"": ""未完了"", ""assigned_by"": { ""type"": ""user"", ""id"": ""33333"", @@ -295,8 +295,8 @@ public async Task GetTaskAssignment_TranslatedStatus() /*** Assert ***/ - Assert.AreEqual("incomplete", result.Status); - Assert.AreEqual("未完了", result.LocalizedStatus); + Assert.AreEqual("incomplete", result.LocalizedStatus); + Assert.AreEqual("未完了", result.Status); Assert.AreEqual(ResolutionStateType.incomplete, result.ResolutionState); } diff --git a/Box.V2.Test/CCGAuthRepositoryTest.cs b/Box.V2.Test/CCGAuthRepositoryTest.cs index 14814563a..5aa3c3d9d 100644 --- a/Box.V2.Test/CCGAuthRepositoryTest.cs +++ b/Box.V2.Test/CCGAuthRepositoryTest.cs @@ -33,7 +33,6 @@ public CCGAuthRepositoryTest() _boxConfig.SetupGet(x => x.ClientId).Returns("123"); _boxConfig.SetupGet(x => x.ClientSecret).Returns("SECRET"); _boxConfig.SetupGet(x => x.BoxApiHostUri).Returns(new Uri(Constants.BoxApiHostUriString)); - _boxConfig.SetupGet(x => x.BoxAuthTokenApiUri).Returns(new Uri(Constants.BoxAuthTokenApiUriString)); _ccgAuth = new BoxCCGAuth(_boxConfig.Object, _service); _userAuthRepository = new CCGAuthRepository(null, _ccgAuth, _userId); _adminAuthRepository = new CCGAuthRepository(null, _ccgAuth, _userId); diff --git a/Box.V2/Config/BoxConfig.cs b/Box.V2/Config/BoxConfig.cs index da654bfaf..26695f174 100644 --- a/Box.V2/Config/BoxConfig.cs +++ b/Box.V2/Config/BoxConfig.cs @@ -59,7 +59,6 @@ public BoxConfig(BoxConfigBuilder builder) BoxAccountApiHostUri = builder.BoxAccountApiHostUri; BoxApiUri = builder.BoxApiUri; BoxUploadApiUri = builder.BoxUploadApiUri; - BoxAuthTokenApiUri = builder.BoxAuthTokenApiUri; RedirectUri = builder.RedirectUri; DeviceId = builder.DeviceId; DeviceName = builder.DeviceName; @@ -156,14 +155,6 @@ public Uri BoxApiUri private set { _boxApiUri = value; } } - private Uri _boxAuthTokenApiUri; - [Obsolete("Use BoxApiHostUri instead")] - public Uri BoxAuthTokenApiUri - { - get { return _boxAuthTokenApiUri ?? new Uri(BoxApiHostUri, Constants.AuthTokenEndpointString); } - private set { _boxAuthTokenApiUri = value; } - } - public string ClientId { get; private set; } public string ConsumerKey { get; private set; } public string ClientSecret { get; private set; } diff --git a/Box.V2/Config/BoxConfigBuilder.cs b/Box.V2/Config/BoxConfigBuilder.cs index e3064ee5c..9d4863904 100644 --- a/Box.V2/Config/BoxConfigBuilder.cs +++ b/Box.V2/Config/BoxConfigBuilder.cs @@ -140,18 +140,6 @@ public BoxConfigBuilder SetBoxAccountApiHostUri(Uri boxAccountApiHostUri) return this; } - /// - /// Sets BoxAPI uri. - /// - /// BoxAPI uri. - /// this BoxConfigBuilder object for chaining - [Obsolete("Use SetBoxApiHostUri() instead")] - public BoxConfigBuilder SetBoxApiUri(Uri boxApiUri) - { - BoxApiUri = EnsureEndsWithSlash(boxApiUri); - return this; - } - /// /// Sets BoxAPI upload uri. /// @@ -163,18 +151,6 @@ public BoxConfigBuilder SetBoxUploadApiUri(Uri boxUploadApiUri) return this; } - /// - /// Sets BoxAPI auth token uri. - /// - /// BoxAPI auth token uri. - /// this BoxConfigBuilder object for chaining - [Obsolete("Use SetBoxApiHostUri() instead")] - public BoxConfigBuilder SetBoxTokenApiUri(Uri boxAuthTokenApiUri) - { - BoxAuthTokenApiUri = EnsureEndsWithSlash(boxAuthTokenApiUri); - return this; - } - /// /// Sets redirect uri. /// @@ -283,14 +259,6 @@ public Uri BoxApiUri private set { _boxApiUri = value; } } - private Uri _boxAuthTokenApiUri; - [Obsolete("Use BoxApiHostUri instead")] - public Uri BoxAuthTokenApiUri - { - get { return _boxAuthTokenApiUri ?? new Uri(BoxApiHostUri, Constants.AuthTokenEndpointString); } - private set { _boxAuthTokenApiUri = value; } - } - public Uri RedirectUri { get; private set; } public string DeviceId { get; private set; } public string DeviceName { get; private set; } diff --git a/Box.V2/Config/Constants.cs b/Box.V2/Config/Constants.cs index 20942e140..6a754c7fe 100644 --- a/Box.V2/Config/Constants.cs +++ b/Box.V2/Config/Constants.cs @@ -162,7 +162,6 @@ public static class Constants /*** Auth ***/ public const string AuthHeaderKey = "Authorization"; - public const string V1AuthString = "BoxAuth api_key={0}&auth_token={1}"; public const string V2AuthString = "Bearer {0}"; public const string BearerTokenType = "bearer"; public const int AccessTokenExpirationTime = 3600; // seconds @@ -460,18 +459,6 @@ public static class UserEventTypes /// public const string EnableTwoFactorAuth = "ENABLE_TWO_FACTOR_AUTH"; - /// - /// Free user accepts invitation to become a managed user. - /// - [Obsolete("Use AdminInviteAccept instead")] - public const string MasterInviteAccept = "MASTER_INVITE_ACCEPT"; - - /// - /// Free user rejects invitation to become a managed user. - /// - [Obsolete("Use AdminInviteReject instead")] - public const string MasterInviteReject = "MASTER_INVITE_REJECT"; - /// /// Free user accepts invitation to become a managed user. /// diff --git a/Box.V2/Config/IBoxConfig.cs b/Box.V2/Config/IBoxConfig.cs index 30b2b129b..821454d3e 100644 --- a/Box.V2/Config/IBoxConfig.cs +++ b/Box.V2/Config/IBoxConfig.cs @@ -11,8 +11,6 @@ public interface IBoxConfig Uri BoxUploadApiUri { get; } Uri BoxApiUri { get; } - [Obsolete("Use BoxApiHostUri instead")] - Uri BoxAuthTokenApiUri { get; } string ClientId { get; } string ConsumerKey { get; } diff --git a/Box.V2/Managers/BoxFilesManager.cs b/Box.V2/Managers/BoxFilesManager.cs index f999c7b32..f2ce94743 100644 --- a/Box.V2/Managers/BoxFilesManager.cs +++ b/Box.V2/Managers/BoxFilesManager.cs @@ -49,32 +49,6 @@ public async Task GetInformationAsync(string id, IEnumerable fi return response.ResponseObject; } - /// - /// Returns the stream of the requested file. - /// - /// Id of the file to download. - /// The ID specific version of this file to download. - /// Optional timeout for response. - /// Optional timeout for response. - /// Optional timeout for response. - /// Stream of the requested file. - [Obsolete("This method is deprecated in favor of DownloadAsync()")] - public async Task DownloadStreamAsync(string id, string versionId = null, TimeSpan? timeout = null, int? startOffsetInBytes = null, int? endOffsetInBytes = null) - { - id.ThrowIfNullOrWhiteSpace("id"); - - BoxRequest request = new BoxRequest(_config.FilesEndpointUri, string.Format(Constants.ContentPathString, id)) { Timeout = timeout } - .Param("version", versionId); - - if (startOffsetInBytes.HasValue && endOffsetInBytes.HasValue) - { - request = request.Header("Range", $"bytes={startOffsetInBytes}-{endOffsetInBytes}"); - } - - IBoxResponse response = await ToResponseAsync(request).ConfigureAwait(false); - return response.ResponseObject; - } - /// /// Returns the stream of the requested file. /// @@ -461,22 +435,6 @@ public async Task GetSessionUploadStatusAsync(Uri sessio return response.ResponseObject; } - /// - /// Upload a new large file version by splitting them up and uploads in a session. - /// - /// The file stream. - /// Id of the remote file. - /// Timeout for subsequent UploadPart requests. - /// Will report progress from 1 - 100. - /// The BoxFileVersion object. - [Obsolete("UploadFileVersionUsingSessionAsync is deprecated, please use UploadNewVersionUsingSessionAsync instead.")] - public async Task UploadFileVersionUsingSessionAsync(Stream stream, string fileId, string fileName = null, - TimeSpan? timeout = null, IProgress progress = null) - { - var response = await UploadNewVersionUsingSessionAsync(stream, fileId, fileName, timeout, progress).ConfigureAwait(false); - return response.FileVersion; - } - /// /// Upload a new large file version by splitting them up and uploads in a session. /// @@ -833,25 +791,6 @@ public async Task DeleteSharedLinkAsync(string id, IEnumerable return response.ResponseObject; } - /// - /// Use this to get a list of all the collaborations on a file - /// - /// Id of the file - /// Attribute(s) to include in the response - /// Collection of the collaborations on a file - [Obsolete("Use GetCollaborationsCollectionAsync() instead; this method does not return the data needed to page through the collection.")] - public async Task> GetCollaborationsAsync(string id, IEnumerable fields = null) - { - id.ThrowIfNullOrWhiteSpace("id"); - - BoxRequest request = new BoxRequest(_config.FilesEndpointUri, string.Format(Constants.CollaborationsPathString, id)) - .Param(ParamFields, fields); - - IBoxResponse> response = await ToResponseAsync>(request).ConfigureAwait(false); - - return response.ResponseObject; - } - /// /// Use this to get a list of all the collaborations on a file /// @@ -957,68 +896,6 @@ public async Task GetPreviewLinkAsync(string id) return file.ExpiringEmbedLink.Url; } - /// - /// Gets the stream of a preview page - /// - /// - /// - /// /// - /// A PNG of the preview - [Obsolete("Please use GetPreviewLinkAsync instead. This functionality is not supported by Box.")] - public async Task GetPreviewAsync(string id, int page, bool handleRetry = true) - { - return (await GetPreviewResponseAsync(id, page, handleRetry: handleRetry).ConfigureAwait(false)).ResponseObject; - } - - /// - /// Get the preview and return a BoxFilePreview response. - /// - /// id of the file to return. - /// page number of the file. - /// specifies whether the method handles retries. If true, then the method would retry the call if the HTTP response is 'Accepted'. The delay for the retry is determined - /// by the RetryAfter header, or if that header is not set, by the constant DefaultRetryDelay. - /// BoxFilePreview that contains the stream, current page number and total number of pages in the file. - [Obsolete("Please use GetPreviewLinkAsync instead. This functionality is not supported by Box.")] - public async Task GetFilePreviewAsync(string id, int page, int? maxWidth = null, int? minWidth = null, int? maxHeight = null, int? minHeight = null, bool handleRetry = true) - { - IBoxResponse response = await GetPreviewResponseAsync(id, page, maxWidth, minWidth, maxHeight, minHeight, handleRetry).ConfigureAwait(false); - - var filePreview = new BoxFilePreview - { - CurrentPage = page, - ReturnedStatusCode = response.StatusCode - }; - - if (response.StatusCode == HttpStatusCode.OK) - { - filePreview.PreviewStream = response.ResponseObject; - filePreview.TotalPages = response.BuildPagesCount(); - } - - return filePreview; - } - - private async Task> GetPreviewResponseAsync(string id, int page, int? maxWidth = null, int? minWidth = null, int? maxHeight = null, int? minHeight = null, bool handleRetry = true) - { - id.ThrowIfNullOrWhiteSpace("id"); - - BoxRequest request = new BoxRequest(_config.FilesEndpointUri, string.Format(Constants.PreviewPathString, id)) - .Param("page", page.ToString()) - .Param("max_width", maxWidth.ToString()) - .Param("max_height", maxHeight.ToString()) - .Param("min_width", minWidth.ToString()) - .Param("min_height", minHeight.ToString()); - - var response = await ToResponseAsync(request).ConfigureAwait(false); - - while (response.StatusCode == HttpStatusCode.Accepted && handleRetry) - { - await Task.Delay(GetTimeDelay(response.Headers)); - response = await ToResponseAsync(request).ConfigureAwait(false); - } - - return response; - } /// /// Return the time to wait until retrying the call. If no RetryAfter value is specified in the header, use default value; diff --git a/Box.V2/Managers/BoxFoldersManager.cs b/Box.V2/Managers/BoxFoldersManager.cs index 60486e415..7c8082992 100644 --- a/Box.V2/Managers/BoxFoldersManager.cs +++ b/Box.V2/Managers/BoxFoldersManager.cs @@ -16,27 +16,6 @@ public class BoxFoldersManager : BoxResourceManager, IBoxFoldersManager public BoxFoldersManager(IBoxConfig config, IBoxService service, IBoxConverter converter, IAuthRepository auth, string asUser = null, bool? suppressNotifications = null) : base(config, service, converter, auth, asUser, suppressNotifications) { } - /// - /// Retrieves the files and/or folders contained in the provided folder id - /// - /// - /// - /// - [Obsolete("This endpoint is not officially supported by the API and is not guaranteed to be available in the next version. Please use GetFolderItemsAsync")] - public async Task GetItemsAsync(string id, int limit, int offset = 0, IEnumerable fields = null) - { - id.ThrowIfNullOrWhiteSpace("id"); - - BoxRequest request = new BoxRequest(_config.FoldersEndpointUri, id) - .Param("limit", limit.ToString()) - .Param("offset", offset.ToString()) - .Param(ParamFields, fields); - - IBoxResponse response = await ToResponseAsync(request).ConfigureAwait(false); - - return response.ResponseObject; - } - /// /// Retrieves the files and/or folders contained within this folder without any other metadata about the folder. /// Any attribute in the full files or folders objects can be passed in with the fields parameter to get specific attributes, @@ -291,33 +270,6 @@ public async Task> GetTrashItemsAsync(int limit, int offs } } - /// - /// Retrieves the files and/or folders that have been moved to the trash. Any attribute in the full files - /// or folders objects can be passed in with the fields parameter to get specific attributes, and only those - /// specific attributes back; otherwise, the mini format is returned for each item by default. Multiple - /// attributes can be passed in separated by commas e.g. fields=name,created_at. Paginated results can be - /// retrieved using the limit and offset parameters. - /// - /// This param is not used in implementation - /// The maximum number of items to return - /// The item at which to begin the response - /// Attribute(s) to include in the response - /// A collection of items contained in the trash is returned. An error is thrown if any of the parameters are invalid. - [Obsolete("This method will be removed in a future update. Please use the GetTrashItemsAsync(int, int, IEnumerable) overload")] - public async Task> GetTrashItemsAsync(string id, int limit, int offset = 0, IEnumerable fields = null) - { - id.ThrowIfNullOrWhiteSpace("id"); - - BoxRequest request = new BoxRequest(_config.FoldersEndpointUri, Constants.TrashItemsPathString) - .Param("limit", limit.ToString()) - .Param("offset", offset.ToString()) - .Param(ParamFields, fields); - - IBoxResponse> response = await ToResponseAsync>(request).ConfigureAwait(false); - - return response.ResponseObject; - } - /// /// Restores an item that has been moved to the trash. Default behavior is to restore the item to the folder it was in /// before it was moved to the trash. If that parent folder no longer exists or if there is now an item with the same diff --git a/Box.V2/Managers/BoxMetadataManager.cs b/Box.V2/Managers/BoxMetadataManager.cs index ee0e44bb2..25196f108 100644 --- a/Box.V2/Managers/BoxMetadataManager.cs +++ b/Box.V2/Managers/BoxMetadataManager.cs @@ -313,43 +313,6 @@ public async Task> return response.ResponseObject; } - /// - /// Allows you to query by metadata on Box items - /// - /// The template used in the query. Must be in the form scope.templateKey - /// The folder_id to which to restrain the query - /// The logical expression of the query - /// Required if query present. The arguments for the query - /// The name of the Index to use - /// A list of BoxMetadataQueryOrderBy objects that contain field_key(s) to order on and the corresponding direction(s) - /// The maximum number of items to return in a page. The default is 100 and the max is 1000. - /// The marker to use for requesting the next page - /// Whether or not to auto-paginate to fetch all items; defaults to false. - /// A collection of items and their associated metadata - [Obsolete("This method is deprecated in favor of ExecuteMetadataQueryAsync() that has a fields parameter. The API will eventually not support this method.")] - public async Task> ExecuteMetadataQueryAsync(string from, string ancestorFolderId, string query = null, Dictionary queryParameters = null, string indexName = null, List orderBy = null, int limit = 100, string marker = null, bool autoPaginate = false) - { - from.ThrowIfNullOrWhiteSpace("from"); - ancestorFolderId.ThrowIfNullOrWhiteSpace("ancestorFolderId"); - - JObject bodyObject = GetMetadataQueryBody(from, ancestorFolderId, query, queryParameters, orderBy, null, limit, marker); - - BoxRequest request = new BoxRequest(_config.MetadataQueryUri) - .Method(RequestMethod.Post) - .Payload(_converter.Serialize(bodyObject)); - request.ContentType = Constants.RequestParameters.ContentTypeJson; - - if (autoPaginate) - { - return await AutoPaginateMarkerMetadataQuery(request).ConfigureAwait(false); - } - else - { - IBoxResponse> response = await ToResponseAsync>(request).ConfigureAwait(false); - return response.ResponseObject; - } - } - /// /// Allows you to query by metadata on Box items with fields passed in /// diff --git a/Box.V2/Managers/BoxResourceManager.cs b/Box.V2/Managers/BoxResourceManager.cs index eafd3881e..cbc937d36 100644 --- a/Box.V2/Managers/BoxResourceManager.cs +++ b/Box.V2/Managers/BoxResourceManager.cs @@ -115,25 +115,10 @@ protected void AddAuthorization(IBoxRequest request, string accessToken = null) { var auth = accessToken ?? _auth.Session.AccessToken; - var authString = _auth.Session.AuthVersion == AuthVersion.V1 ? - string.Format(CultureInfo.InvariantCulture, Constants.V1AuthString, _config.ClientId, auth) : - string.Format(CultureInfo.InvariantCulture, Constants.V2AuthString, auth); - - var sb = new StringBuilder(authString); - - // Appending device_id is required for accounts that have device pinning enabled on V1 auth - if (_auth.Session.AuthVersion == AuthVersion.V1) - { - sb.Append(string.IsNullOrWhiteSpace(_config.DeviceId) ? - string.Empty : - string.Format("&device_id={0}", _config.DeviceId)); - sb.Append(string.IsNullOrWhiteSpace(_config.DeviceName) ? - string.Empty : - string.Format("&device_name={0}", _config.DeviceName)); - } + var authString = string.Format(CultureInfo.InvariantCulture, Constants.V2AuthString, auth); request.Authorization = auth; - request.Header(Constants.AuthHeaderKey, sb.ToString()); + request.Header(Constants.AuthHeaderKey, authString); } /// diff --git a/Box.V2/Managers/BoxSearchManager.cs b/Box.V2/Managers/BoxSearchManager.cs index ba9344e72..a368290a0 100644 --- a/Box.V2/Managers/BoxSearchManager.cs +++ b/Box.V2/Managers/BoxSearchManager.cs @@ -19,89 +19,6 @@ public class BoxSearchManager : BoxResourceManager, IBoxSearchManager public BoxSearchManager(IBoxConfig config, IBoxService service, IBoxConverter converter, IAuthRepository auth, string asUser = null, bool? suppressNotifications = null) : base(config, service, converter, auth, asUser, suppressNotifications) { } - - /// - /// Search for items that are accessible by a single user or an entire enterprise. - /// - /// The string to search for. Box matches the search string against object names, descriptions, text contents of files, and other data. - /// Number of search results to return. The default is 30 and the maximum is 200. - /// The search result at which to start the response. The default is 0. - /// Attribute(s) to include in the response. - /// The scope for which you want to limit your search to. Can be user_content for a search limited to only the current user or enterprise_content for the entire enterprise. To enable the enterprise_content scope for an administrator, please contact Box. - /// Limit searches to specific file extension(s). - /// The from date for when the item was created - /// The to date for when the item was created - /// The from date for when the item was last updated - /// The to date for when the item was last updated - /// The lower bound of the file size range in bytes - /// The upper bound of the file size range in bytes - /// Search by item owners - /// Limit searches to specific parent folders - /// Limit searches to specific Box designated content types. Can be name, description, file_content, comments, or tags. - /// The type you want to return in your search. Can be file, folder, or web_link - /// Allows you to search within the trash. Can be trashed_only or non_trashed_only. Searches without this parameter default to non_trashed_only - /// Filters for a specific metadata template for files with metadata object associations. NOTE: For searches with the mdfilters param, a query string is not required. Currenly only one BoxMetadataFilterRequest element is allowed. - /// The field to sort the search results by, e.g. "modified_at. - /// The direction to return the results. "ASC" for ascending and "DESC" for descending. - /// A collection of search results is returned. If there are no matching search results, the collection will be empty. - [Obsolete("Method is deprecated; use QueryAsync() instead")] - public async Task> SearchAsync(string keyword = null, - int limit = 30, - int offset = 0, - IEnumerable fields = null, - string scope = null, - IEnumerable fileExtensions = null, - DateTimeOffset? createdAtRangeFromDate = null, - DateTimeOffset? createdAtRangeToDate = null, - DateTimeOffset? updatedAtRangeFromDate = null, - DateTimeOffset? updatedAtRangeToDate = null, - int? sizeRangeLowerBoundBytes = null, - int? sizeRangeUpperBoundBytes = null, - IEnumerable ownerUserIds = null, - IEnumerable ancestorFolderIds = null, - IEnumerable contentTypes = null, - string type = null, - string trashContent = null, - List mdFilters = null, - string sort = null, - BoxSortDirection? direction = null) - - { - - string mdFiltersString = null; - if (mdFilters != null) - { - mdFiltersString = _converter.Serialize(mdFilters); - } - - var createdAtRangeString = BuildDateRangeField(createdAtRangeFromDate, createdAtRangeToDate); - var updatedAtRangeString = BuildDateRangeField(updatedAtRangeFromDate, updatedAtRangeToDate); - var sizeRangeString = BuildSizeRangeField(sizeRangeLowerBoundBytes, sizeRangeUpperBoundBytes); - - BoxRequest request = new BoxRequest(_config.SearchEndpointUri) - .Param("query", keyword) - .Param("scope", scope) - .Param("file_extensions", fileExtensions) - .Param("created_at_range", createdAtRangeString) - .Param("updated_at_range", updatedAtRangeString) - .Param("size_range", sizeRangeString) - .Param("owner_user_ids", ownerUserIds) - .Param("ancestor_folder_ids", ancestorFolderIds) - .Param("content_types", contentTypes) - .Param("type", type) - .Param("trash_content", trashContent) - .Param("mdfilters", mdFiltersString) - .Param("limit", limit.ToString()) - .Param("offset", offset.ToString()) - .Param("sort", sort) - .Param("direction", direction.ToString()) - .Param(ParamFields, fields); - - IBoxResponse> response = await ToResponseAsync>(request).ConfigureAwait(false); - - return response.ResponseObject; - } - /// /// Search for items that are accessible by a single user or an entire enterprise. /// diff --git a/Box.V2/Managers/BoxTermsOfServiceManager.cs b/Box.V2/Managers/BoxTermsOfServiceManager.cs index 01c15007f..d5fcc1914 100644 --- a/Box.V2/Managers/BoxTermsOfServiceManager.cs +++ b/Box.V2/Managers/BoxTermsOfServiceManager.cs @@ -102,23 +102,6 @@ public async Task - /// Create a terms of service status for user. - /// - /// The request object for terms of service user status. - /// The status of the terms of service for a user. - [Obsolete("Use CreateBoxTermsOfServiceUserStatusesAsync(BoxTermsOfServiceStatusCreateRequest termsOfServiceUserStatusCreateRequest) instead.")] - public async Task CreateBoxTermsOfServiceUserStatusesAsync(BoxTermsOfServiceUserStatusesRequest termsOfServicesUserStatusesRequest) - { - BoxRequest request = new BoxRequest(_config.TermsOfServiceUserStatusesUri) - .Method(RequestMethod.Post) - .Payload(_converter.Serialize(termsOfServicesUserStatusesRequest)); - - IBoxResponse response = await ToResponseAsync(request).ConfigureAwait(false); - - return response.ResponseObject; - } - /// /// Create a terms of service status for user. /// diff --git a/Box.V2/Managers/IBoxFilesManager.cs b/Box.V2/Managers/IBoxFilesManager.cs index 0a3b8a270..bfcb4e630 100644 --- a/Box.V2/Managers/IBoxFilesManager.cs +++ b/Box.V2/Managers/IBoxFilesManager.cs @@ -22,18 +22,6 @@ public interface IBoxFilesManager /// A full file object is returned if the ID is valid and if the user has access to the file. Task GetInformationAsync(string id, IEnumerable fields = null); - /// - /// Returns the stream of the requested file. - /// - /// Id of the file to download. - /// The ID specific version of this file to download. - /// Optional timeout for response. - /// Optional timeout for response. - /// Optional timeout for response. - /// Stream of the requested file. - [Obsolete("This method is deprecated in favor of DownloadAsync()")] - Task DownloadStreamAsync(string id, string versionId = null, TimeSpan? timeout = null, int? startOffsetInBytes = null, int? endOffsetInBytes = null); - /// /// Returns the stream of the requested file. /// @@ -180,18 +168,6 @@ Task UploadNewVersionAsync(string fileName, string fileId, Stream strea /// Returns an object representing the status of the upload session. Task GetSessionUploadStatusAsync(Uri sessionUploadStatusUri); - /// - /// Upload a new large file version by splitting them up and uploads in a session. - /// - /// The file stream. - /// Id of the remote file. - /// Timeout for subsequent UploadPart requests. - /// Will report progress from 1 - 100. - /// The BoxFileVersion object. - [Obsolete("UploadFileVersionUsingSessionAsync is deprecated, please use UploadNewVersionUsingSessionAsync instead.")] - Task UploadFileVersionUsingSessionAsync(Stream stream, string fileId, string fileName = null, - TimeSpan? timeout = null, IProgress progress = null); - /// /// Upload a new large file version by splitting them up and uploads in a session. /// @@ -281,15 +257,6 @@ Task UploadUsingSessionAsync(Stream stream, string fileName, /// if the ID is valid and if the update is successful. Task DeleteSharedLinkAsync(string id, IEnumerable fields = null); - /// - /// Use this to get a list of all the collaborations on a file - /// - /// Id of the file - /// Attribute(s) to include in the response - /// Collection of the collaborations on a file - [Obsolete("Use GetCollaborationsCollectionAsync() instead; this method does not return the data needed to page through the collection.")] - Task> GetCollaborationsAsync(string id, IEnumerable fields = null); - /// /// Use this to get a list of all the collaborations on a file /// @@ -335,27 +302,6 @@ Task UploadUsingSessionAsync(Stream stream, string fileName, /// Preview link (URI) for a file that is valid for 60 seconds. Task GetPreviewLinkAsync(string id); - /// - /// Gets the stream of a preview page - /// - /// - /// - /// /// - /// A PNG of the preview - [Obsolete("Please use GetPreviewLinkAsync instead. This functionality is not supported by Box.")] - Task GetPreviewAsync(string id, int page, bool handleRetry = true); - - /// - /// Get the preview and return a BoxFilePreview response. - /// - /// id of the file to return. - /// page number of the file. - /// specifies whether the method handles retries. If true, then the method would retry the call if the HTTP response is 'Accepted'. The delay for the retry is determined - /// by the RetryAfter header, or if that header is not set, by the constant DefaultRetryDelay. - /// BoxFilePreview that contains the stream, current page number and total number of pages in the file. - [Obsolete("Please use GetPreviewLinkAsync instead. This functionality is not supported by Box.")] - Task GetFilePreviewAsync(string id, int page, int? maxWidth = null, int? minWidth = null, int? maxHeight = null, int? minHeight = null, bool handleRetry = true); - /// /// Retrieves an item that has been moved to the trash. /// diff --git a/Box.V2/Managers/IBoxFoldersManager.cs b/Box.V2/Managers/IBoxFoldersManager.cs index 635a0eee0..fc19302be 100644 --- a/Box.V2/Managers/IBoxFoldersManager.cs +++ b/Box.V2/Managers/IBoxFoldersManager.cs @@ -7,15 +7,6 @@ namespace Box.V2.Managers { public interface IBoxFoldersManager { - /// - /// Retrieves the files and/or folders contained in the provided folder id - /// - /// - /// - /// - [Obsolete("This endpoint is not officially supported by the API and is not guaranteed to be available in the next version. Please use GetFolderItemsAsync")] - Task GetItemsAsync(string id, int limit, int offset = 0, IEnumerable fields = null); - /// /// Retrieves the files and/or folders contained within this folder without any other metadata about the folder. /// Any attribute in the full files or folders objects can be passed in with the fields parameter to get specific attributes, @@ -127,21 +118,6 @@ public interface IBoxFoldersManager /// A collection of items contained in the trash is returned. An error is thrown if any of the parameters are invalid. Task> GetTrashItemsAsync(int limit, int offset = 0, IEnumerable fields = null, bool autoPaginate = false, string sort = null, BoxSortDirection? direction = null); - /// - /// Retrieves the files and/or folders that have been moved to the trash. Any attribute in the full files - /// or folders objects can be passed in with the fields parameter to get specific attributes, and only those - /// specific attributes back; otherwise, the mini format is returned for each item by default. Multiple - /// attributes can be passed in separated by commas e.g. fields=name,created_at. Paginated results can be - /// retrieved using the limit and offset parameters. - /// - /// This param is not used in implementation - /// The maximum number of items to return - /// The item at which to begin the response - /// Attribute(s) to include in the response - /// A collection of items contained in the trash is returned. An error is thrown if any of the parameters are invalid. - [Obsolete("This method will be removed in a future update. Please use the GetTrashItemsAsync(int, int, IEnumerable) overload")] - Task> GetTrashItemsAsync(string id, int limit, int offset = 0, IEnumerable fields = null); - /// /// Restores an item that has been moved to the trash. Default behavior is to restore the item to the folder it was in /// before it was moved to the trash. If that parent folder no longer exists or if there is now an item with the same diff --git a/Box.V2/Managers/IBoxMetadataManager.cs b/Box.V2/Managers/IBoxMetadataManager.cs index e921cc949..d3366af79 100644 --- a/Box.V2/Managers/IBoxMetadataManager.cs +++ b/Box.V2/Managers/IBoxMetadataManager.cs @@ -167,22 +167,6 @@ public interface IBoxMetadataManager /// Collection of enterprise metadata instances associated with the file. Task> GetEnterpriseMetadataAsync(string scope = "enterprise"); - /// - /// Allows you to query by metadata on Box items - /// - /// The template used in the query. Must be in the form scope.templateKey - /// The folder_id to which to restrain the query - /// The logical expression of the query - /// Required if query present. The arguments for the query - /// The name of the Index to use - /// A list of BoxMetadataQueryOrderBy objects that contain field_key(s) to order on and the corresponding direction(s) - /// The maximum number of items to return in a page. The default is 100 and the max is 1000. - /// The marker to use for requesting the next page - /// Whether or not to auto-paginate to fetch all items; defaults to false. - /// A collection of items and their associated metadata - [Obsolete("This method is deprecated in favor of ExecuteMetadataQueryAsync() that has a fields parameter. The API will eventually not support this method.")] - Task> ExecuteMetadataQueryAsync(string from, string ancestorFolderId, string query = null, Dictionary queryParameters = null, string indexName = null, List orderBy = null, int limit = 100, string marker = null, bool autoPaginate = false); - /// /// Allows you to query by metadata on Box items with fields passed in /// diff --git a/Box.V2/Managers/IBoxSearchManager.cs b/Box.V2/Managers/IBoxSearchManager.cs index f1e3b3f4f..71fc72533 100644 --- a/Box.V2/Managers/IBoxSearchManager.cs +++ b/Box.V2/Managers/IBoxSearchManager.cs @@ -11,52 +11,6 @@ namespace Box.V2.Managers /// public interface IBoxSearchManager { - /// - /// Search for items that are accessible by a single user or an entire enterprise. - /// - /// The string to search for. Box matches the search string against object names, descriptions, text contents of files, and other data. - /// Number of search results to return. The default is 30 and the maximum is 200. - /// The search result at which to start the response. The default is 0. - /// Attribute(s) to include in the response. - /// The scope for which you want to limit your search to. Can be user_content for a search limited to only the current user or enterprise_content for the entire enterprise. To enable the enterprise_content scope for an administrator, please contact Box. - /// Limit searches to specific file extension(s). - /// The from date for when the item was created - /// The to date for when the item was created - /// The from date for when the item was last updated - /// The to date for when the item was last updated - /// The lower bound of the file size range in bytes - /// The upper bound of the file size range in bytes - /// Search by item owners - /// Limit searches to specific parent folders - /// Limit searches to specific Box designated content types. Can be name, description, file_content, comments, or tags. - /// The type you want to return in your search. Can be file, folder, or web_link - /// Allows you to search within the trash. Can be trashed_only or non_trashed_only. Searches without this parameter default to non_trashed_only - /// Filters for a specific metadata template for files with metadata object associations. NOTE: For searches with the mdfilters param, a query string is not required. Currenly only one BoxMetadataFilterRequest element is allowed. - /// The field to sort the search results by, e.g. "modified_at. - /// The direction to return the results. "ASC" for ascending and "DESC" for descending. - /// A collection of search results is returned. If there are no matching search results, the collection will be empty. - [Obsolete("Method is deprecated; use QueryAsync() instead")] - Task> SearchAsync(string keyword = null, - int limit = 30, - int offset = 0, - IEnumerable fields = null, - string scope = null, - IEnumerable fileExtensions = null, - DateTimeOffset? createdAtRangeFromDate = null, - DateTimeOffset? createdAtRangeToDate = null, - DateTimeOffset? updatedAtRangeFromDate = null, - DateTimeOffset? updatedAtRangeToDate = null, - int? sizeRangeLowerBoundBytes = null, - int? sizeRangeUpperBoundBytes = null, - IEnumerable ownerUserIds = null, - IEnumerable ancestorFolderIds = null, - IEnumerable contentTypes = null, - string type = null, - string trashContent = null, - List mdFilters = null, - string sort = null, - BoxSortDirection? direction = null); - /// /// Search for items that are accessible by a single user or an entire enterprise. /// diff --git a/Box.V2/Managers/IBoxTermsOfServiceManager.cs b/Box.V2/Managers/IBoxTermsOfServiceManager.cs index 36c5d6fad..8e92ffb77 100644 --- a/Box.V2/Managers/IBoxTermsOfServiceManager.cs +++ b/Box.V2/Managers/IBoxTermsOfServiceManager.cs @@ -47,14 +47,6 @@ public interface IBoxTermsOfServiceManager /// The user status for terms of service objects. Task> GetTermsOfServiceUserStatusesAsync(string tosId, string userId = null); - /// - /// Create a terms of service status for user. - /// - /// The request object for terms of service user status. - /// The status of the terms of service for a user. - [Obsolete("Use CreateBoxTermsOfServiceUserStatusesAsync(BoxTermsOfServiceStatusCreateRequest termsOfServiceUserStatusCreateRequest) instead.")] - Task CreateBoxTermsOfServiceUserStatusesAsync(BoxTermsOfServiceUserStatusesRequest termsOfServicesUserStatusesRequest); - /// /// Create a terms of service status for user. /// diff --git a/Box.V2/Models/BoxPreflightCheck.cs b/Box.V2/Models/BoxPreflightCheck.cs index d6fe9c6c0..6a0c667de 100644 --- a/Box.V2/Models/BoxPreflightCheck.cs +++ b/Box.V2/Models/BoxPreflightCheck.cs @@ -9,14 +9,12 @@ namespace Box.V2.Models public class BoxPreflightCheck { public const string FieldUploadUrl = "upload_url"; - [Obsolete] public const string FieldUploadToken = "upload_token"; /// /// The upload URL to optionally use when uploading the file /// [JsonProperty(PropertyName = FieldUploadUrl)] - [Obsolete] public virtual string UploadUrl { get; private set; } /// @@ -31,10 +29,9 @@ public virtual Uri UploadUri } /// - /// Currently not used. + /// An optional access token to use to upload the file. /// [JsonProperty(PropertyName = FieldUploadToken)] - [Obsolete] public virtual string UploadToken { get; private set; } /// diff --git a/Box.V2/Models/BoxTaskAssignment.cs b/Box.V2/Models/BoxTaskAssignment.cs index 4ef68de6f..61965400e 100644 --- a/Box.V2/Models/BoxTaskAssignment.cs +++ b/Box.V2/Models/BoxTaskAssignment.cs @@ -55,14 +55,13 @@ public class BoxTaskAssignment : BoxEntity public virtual DateTimeOffset? RemindedAt { get; private set; } /// - /// Gets the state of the resolution. + /// Gets the state of the resolution as an Enum. /// - [Obsolete("This field is deprecated, and may not work consistently. Use Status or LocalizedStatus instead.")] public virtual ResolutionStateType? ResolutionState { get { - return (ResolutionStateType)System.Enum.Parse(typeof(ResolutionStateType), Status, ignoreCase: true); + return (ResolutionStateType)Enum.Parse(typeof(ResolutionStateType), LocalizedStatus, ignoreCase: true); } } @@ -73,7 +72,7 @@ public virtual ResolutionStateType? ResolutionState public virtual string Status { get; private set; } /// - /// Gets the localized/human-readable resolution status of the task assignment. + /// Gets the localized/human-readable resolution status of the task assignment in a string format. /// [JsonProperty(PropertyName = FieldResolutionState)] public virtual string LocalizedStatus { get; private set; } diff --git a/Box.V2/Models/OAuthSession.cs b/Box.V2/Models/OAuthSession.cs index 11566cd9e..24714d792 100644 --- a/Box.V2/Models/OAuthSession.cs +++ b/Box.V2/Models/OAuthSession.cs @@ -1,4 +1,3 @@ -using System; using Box.V2.Models; using Newtonsoft.Json; @@ -25,25 +24,11 @@ public class OAuthSession /// Token type (usually bearer) [JsonConstructor] public OAuthSession(string access_token, string refresh_token, int expires_in, string token_type) - : this(access_token, refresh_token, expires_in, token_type, AuthVersion.V2) { } - - /// - /// Instantiates a new OAuth 2 session and allows you to define the auth version. This constructor is primarily - /// available to support legacy V1 calls. Creating an Auth session with V1 is not encouraged as they will not work in 2014 - /// - /// A valid access token - /// A valid refresh token - /// Time in seconds the access token will expire - /// Token type (usually bearer) - /// V1 or V2 auth - [Obsolete("V1 auth will no longer be available after 6/14")] - public OAuthSession(string access_token, string refresh_token, int expires_in, string token_type, AuthVersion authVersion) { AccessToken = access_token; RefreshToken = refresh_token; ExpiresIn = expires_in; TokenType = token_type; - AuthVersion = authVersion; } /// @@ -81,19 +66,5 @@ public OAuthSession(string access_token, string refresh_token, int expires_in, s /// [JsonProperty(PropertyName = FieldRestrictedTo)] public virtual BoxRestrictedTo[] RestrictedTo { get; private set; } - - /// - /// Read-only property to provide support for legacy V1 authentication - /// - public virtual AuthVersion AuthVersion { get; private set; } - } - - /// - /// Allows the SDK to differentiate between a V1 and a V2 auth token - /// - public enum AuthVersion - { - V1, - V2 } } diff --git a/Box.V2/Models/Request/BoxPermissionsRequest.cs b/Box.V2/Models/Request/BoxPermissionsRequest.cs index fed4d3da8..f0cfb7cbf 100644 --- a/Box.V2/Models/Request/BoxPermissionsRequest.cs +++ b/Box.V2/Models/Request/BoxPermissionsRequest.cs @@ -15,14 +15,6 @@ public class BoxPermissionsRequest [JsonProperty(PropertyName = "can_download")] public bool Download { get; set; } - /// - /// Whether this link allows previews. Can only be used with Open and Company - /// - [Obsolete("CanPreview is now deprecated in the API and cannot be altered. Results will always be true")] - [JsonProperty(PropertyName = "can_preview")] - [JsonConverter(typeof(StringEnumConverter))] - public BoxPermissionType? Preview { get; set; } - /// /// Defines if the shared link allows for the item to be edited. /// This value can only be true if can_download is also true and if the item has a type of file diff --git a/docs/upgrades/4.x.x to 5.x.x.md b/docs/upgrades/4.x.x to 5.x.x.md index ab7d538a2..f516e050a 100644 --- a/docs/upgrades/4.x.x to 5.x.x.md +++ b/docs/upgrades/4.x.x to 5.x.x.md @@ -9,16 +9,181 @@ Follow the [General changes](#general-changes) to see the changes that are packa Some old, deprecated methods have been removed from version 5.x.x. Read this section further to see a new, alternative methods. -#### BoxMetadataManager - -Old +#### BoxMetadataManager/IBoxMetadataManager + ```c# +//Old ExecuteMetadataQueryAsync(string from, string ancestorFolderId, IEnumerable fields, string query, Dictionary queryParameters, string indexName, List orderBy, int limit, string marker, bool autoPaginate) + +ExecuteMetadataQueryAsync(string from, string ancestorFolderId, string query = null, Dictionary queryParameters = null, string indexName = null, List orderBy = null, int limit = 100, string marker = null, bool autoPaginate = false) + +//New +ExecuteMetadataQueryAsync(BoxMetadataQueryRequest queryRequest) ``` -New +#### BoxConfigBuilder/IBoxConfigBuilder + ```c# -ExecuteMetadataQueryAsync(BoxMetadataQueryRequest queryRequest) +//Old +SetBoxApiUri(...) +SetBoxTokenApiUri(...) + +//New +SetBoxApiHostUri(...) +``` + +#### BoxFilesManager/IBoxFilesManager + +```c# +//Old +DownloadStreamAsync(...) + +//New +DownloadAsync(...) +``` + +```c# +//Old +UploadFileVersionUsingSessionAsync(...) + +//New +UploadNewVersionUsingSessionAsync(...) +``` + + +```c# +//Old +GetCollaborationsAsync(...) + +//New +GetCollaborationsCollectionAsync(...) +``` + +```c# +//Old +GetFilePreviewAsync(...) +GetPreviewAsync(...) + +//New +GetPreviewLinkAsync(...) +``` + +#### BoxSearchManager/IBoxSearchManager + +```c# +//Old +SearchAsync(...) + +//New +QueryAsync(...) +``` + +#### BoxFolderManager/IBoxFolderManager + +```c# +//Old +GetTrashItemsAsync(string id, int limit, int offset = 0, IEnumerable fields = null) + +//New +GetTrashItemsAsync(int limit, int offset = 0, IEnumerable fields = null, bool autoPaginate = false, string sort = null, BoxSortDirection? direction = null) +``` + +```c# +//Old +GetItemsAsync(...) + +//New +GetFolderItemsAsync(...) +``` + +#### BoxTermsOfServiceManager/IBoxTermsOfServiceManager + +```c# +//Old +CreateBoxTermsOfServiceUserStatusesAsync(BoxTermsOfServiceUserStatusesRequest termsOfServicesUserStatusesRequest) + +//New +CreateBoxTermsOfServiceUserStatusesAsync(BoxTermsOfServiceUserStatusCreateRequest termsOfServiceUserStatusCreateRequest) +``` + +#### OAuthSession + +```c# +//Old +OAuthSession(string access_token, string refresh_token, int expires_in, string token_type, AuthVersion authVersion) + +//New +OAuthSession(string access_token, string refresh_token, int expires_in, string token_type) +``` + +### Deprecated fields + +Some old, deprecated fields have been removed from version 5.x.x. Read this section further to see a new, alternative fields. + +#### BoxConfigBuilder/IBoxConfigBuilder + +```c# +//Old +BoxAuthTokenApiUri + +//New +BoxApiHostUri +``` + +#### Constants + +```c# +//Old +MasterInviteAccept + +//New +AdminInviteAccept +``` + +```c# +//Old +MasterInviteReject + +//New +AdminInviteReject +``` + +```c# +//Old +V1AuthString + +//New +//V1 Auth is no longer support in the API. +``` + +#### IBoxConfig + +```c# +//Old +BoxAuthTokenApiUri + +//New +BoxApiHostUri +``` + +#### BoxPermissionsRequest + +```c# +//Old +BoxPermissionType? Preview + +//New +//Deprecated field. Value is always true +``` + +#### OAuthSession + +```c# +//Old +AuthVersion + +//New +//Box API have now one auth version so there is no need to differentiate between them. ``` ## Box.V2