-
Notifications
You must be signed in to change notification settings - Fork 163
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix!: return proper object type from `GetFileVersionsUnderRetentionFo…
…rAssignmentAsync` method (#875)
- Loading branch information
Showing
11 changed files
with
81 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
30 changes: 30 additions & 0 deletions
30
Box.V2/Converter/BoxFileVersionsUnderRetentionItemConverter.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
using System; | ||
using Box.V2.Config; | ||
using Box.V2.Models; | ||
using Newtonsoft.Json.Linq; | ||
|
||
namespace Box.V2.Converter | ||
{ | ||
// workaround for https://developer.box.com/reference/get-retention-policy-assignments-id-file-versions-under-retention/ | ||
// which currently returns 'file-version' instead of 'file' in 'type' field | ||
internal class BoxFileVersionsUnderRetentionItemConverter : BoxItemConverter | ||
{ | ||
protected override BoxEntity Create(Type objectType, JObject jObject) | ||
{ | ||
// we need to identify the top level node somehow so we check if 'file version' field is present | ||
if (FieldExists(ItemType, jObject) && FieldExists("file_version", jObject)) | ||
{ | ||
switch (jObject[ItemType].ToString()) | ||
{ | ||
// should work even if this bug is fixed | ||
case Constants.TypeFileVersion: | ||
case Constants.TypeFile: | ||
jObject[ItemType] = Constants.TypeFile; | ||
return new BoxFile(); | ||
} | ||
} | ||
|
||
return base.Create(objectType, jObject); | ||
} | ||
} | ||
} |
12 changes: 12 additions & 0 deletions
12
Box.V2/Converter/BoxFileVersionsUnderRetentionJsonConverter.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
using Newtonsoft.Json; | ||
|
||
namespace Box.V2.Converter | ||
{ | ||
internal class BoxFileVersionsUnderRetentionJsonConverter : BoxJsonConverter | ||
{ | ||
public override T Parse<T>(string content) | ||
{ | ||
return JsonConvert.DeserializeObject<T>(content, new BoxFileVersionsUnderRetentionItemConverter()); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters