-
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.
- Loading branch information
1 parent
cca504c
commit b1f88f3
Showing
16 changed files
with
443 additions
and
3 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
Binary file not shown.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using Box.V2.Models; | ||
using Newtonsoft.Json; | ||
using Newtonsoft.Json.Linq; | ||
|
||
namespace Box.V2.Converter | ||
{ | ||
internal class BoxZipConflictConverter : JsonConverter | ||
{ | ||
public override bool CanConvert(Type objectType) | ||
{ | ||
throw new NotImplementedException(); | ||
} | ||
|
||
public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer) | ||
{ | ||
List<BoxZipConflict> conflicts = new List<BoxZipConflict>(); | ||
|
||
// Load JObject from stream | ||
JArray conflictsArray = JArray.Load(reader); | ||
foreach (JArray conflict in conflictsArray) | ||
{ | ||
BoxZipConflict zipConflict = new BoxZipConflict(); | ||
JObject conflictObject = new JObject(); | ||
conflictObject.Add("items", conflict); | ||
// Populate the object properties | ||
serializer.Populate(conflictObject.CreateReader(), zipConflict); | ||
conflicts.Add(zipConflict); | ||
} | ||
|
||
return conflicts; | ||
} | ||
|
||
public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer) | ||
{ | ||
throw new NotImplementedException(); | ||
} | ||
} | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
using Box.V2.Converter; | ||
using Newtonsoft.Json; | ||
using System; | ||
using System.Collections.Generic; | ||
|
||
namespace Box.V2.Models | ||
{ | ||
/// <summary> | ||
/// Box representation of a created zip | ||
/// </summary> | ||
public class BoxZip | ||
{ | ||
public const string FieldDownloadUrl = "download_url"; | ||
public const string FieldStatusUrl = "status_url"; | ||
public const string FieldExpiresAt = "expires_at"; | ||
public const string FieldNameConflicts = "name_conflicts"; | ||
|
||
/// <summary> | ||
/// A URL to download the zip from | ||
/// </summary> | ||
[JsonProperty(PropertyName = FieldDownloadUrl)] | ||
public Uri DownloadUrl { get; private set; } | ||
|
||
/// <summary> | ||
/// A URL to get the download status of a zip | ||
/// </summary> | ||
[JsonProperty(PropertyName = FieldStatusUrl)] | ||
public Uri StatusUrl { get; private set; } | ||
|
||
/// <summary> | ||
/// The date after which the zip can no longer be downloaded | ||
/// </summary> | ||
[JsonProperty(PropertyName = FieldExpiresAt)] | ||
public DateTime ExpiresAt { get; private set; } | ||
|
||
/// <summary> | ||
/// A list of naming conflicts among the files and folders in the zip | ||
/// </summary> | ||
[JsonProperty(PropertyName = FieldNameConflicts)] | ||
[JsonConverter(typeof(BoxZipConflictConverter))] | ||
public List<BoxZipConflict> NameConflicts { get; private set; } | ||
} | ||
} | ||
|
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,19 @@ | ||
using Newtonsoft.Json; | ||
using System; | ||
using System.Collections.Generic; | ||
|
||
namespace Box.V2.Models | ||
{ | ||
/// <summary> | ||
/// Represents a conflict that occurs between items that have the same name. | ||
/// </summary> | ||
public class BoxZipConflict | ||
{ | ||
/// <summary> | ||
/// The items that have a conflict | ||
/// </summary> | ||
[JsonProperty(PropertyName = "items")] | ||
public List<BoxZipConflictItem> items { get; private set; } | ||
} | ||
} | ||
|
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,39 @@ | ||
using Newtonsoft.Json; | ||
|
||
namespace Box.V2.Models | ||
{ | ||
/// <summary> | ||
/// Box representation of a naming conflict creating a zip file for an item | ||
/// </summary> | ||
public class BoxZipConflictItem | ||
{ | ||
public const string FieldId = "id"; | ||
public const string FieldType = "type"; | ||
public const string FieldOriginalName = "original_name"; | ||
public const string FieldDownloadName = "download_name"; | ||
|
||
/// <summary> | ||
/// The Id of the item | ||
/// </summary> | ||
[JsonProperty(PropertyName = FieldId)] | ||
public string Id { get; private set; } | ||
|
||
/// <summary> | ||
/// The type of the item | ||
/// </summary> | ||
[JsonProperty(PropertyName = FieldType)] | ||
public string Type { get; private set; } | ||
|
||
/// <summary> | ||
/// The original name of the item | ||
/// </summary> | ||
[JsonProperty(PropertyName = FieldOriginalName)] | ||
public string OriginalName { get; private set; } | ||
|
||
/// <summary> | ||
/// the new name of the item when it downloads that resolves the conflict | ||
/// </summary> | ||
[JsonProperty(PropertyName = FieldDownloadName)] | ||
public string DownloadName { get; private set; } | ||
} | ||
} |
Oops, something went wrong.