Skip to content

Commit

Permalink
Align response of patch documents with other endpoints.
Browse files Browse the repository at this point in the history
  • Loading branch information
DiscoPYF committed Jul 18, 2020
1 parent 965ff7e commit b8c8615
Show file tree
Hide file tree
Showing 7 changed files with 78 additions and 13 deletions.
4 changes: 2 additions & 2 deletions arangodb-net-standard/DocumentApi/DocumentApiClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -430,7 +430,7 @@ public virtual async Task<DeleteDocumentsResponse<T>> DeleteDocumentsAsync<T>(
/// <param name="patches"></param>
/// <param name="query"></param>
/// <returns></returns>
public virtual async Task<IList<PatchDocumentsResponse<U>>> PatchDocumentsAsync<T, U>(
public virtual async Task<PatchDocumentsResponse<U>> PatchDocumentsAsync<T, U>(
string collectionName,
IList<T> patches,
PatchDocumentsQuery query = null)
Expand All @@ -446,7 +446,7 @@ public virtual async Task<IList<PatchDocumentsResponse<U>>> PatchDocumentsAsync<
if (response.IsSuccessStatusCode)
{
var stream = await response.Content.ReadAsStreamAsync();
return DeserializeJsonFromStream<IList<PatchDocumentsResponse<U>>>(stream);
return DeserializeJsonFromStream<PatchDocumentsResponse<U>>(stream);
}
throw await GetApiErrorException(response);
}
Expand Down
2 changes: 1 addition & 1 deletion arangodb-net-standard/DocumentApi/IDocumentApiClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,7 @@ Task<DeleteDocumentsResponse<T>> DeleteDocumentsAsync<T>(
/// <param name="patches"></param>
/// <param name="query"></param>
/// <returns></returns>
Task<IList<PatchDocumentsResponse<U>>> PatchDocumentsAsync<T, U>(
Task<PatchDocumentsResponse<U>> PatchDocumentsAsync<T, U>(
string collectionName,
IList<T> patches,
PatchDocumentsQuery query = null);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,15 @@

namespace ArangoDBNetStandard.DocumentApi.Models
{
/// <summary>
/// Represents the response for deleting multiple documents.
/// </summary>
/// <typeparam name="T">The type of the deserialized old document object when requested.</typeparam>
public class DeleteDocumentsResponse<T> : List<DeleteDocumentsDocumentResponse<T>>
{
/// <summary>
/// Creates an instance of <see cref="DeleteDocumentsResponse{T}"/>.
/// </summary>
public DeleteDocumentsResponse()
{
}
Expand All @@ -13,6 +20,11 @@ private DeleteDocumentsResponse(int capacity)
{
}

/// <summary>
/// Creates an empty response.
/// This is used when <see cref="DeleteDocumentsQuery.Silent"/> is true.
/// </summary>
/// <returns></returns>
public static DeleteDocumentsResponse<T> Empty()
{
return new DeleteDocumentsResponse<T>(0);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
namespace ArangoDBNetStandard.DocumentApi.Models
{
/// <summary>
/// Represents the response for one document when updating multiple document.
/// </summary>
/// <typeparam name="T">The type of the deserialized new/old document object when requested.</typeparam>
public class PatchDocumentsDocumentResponse<T> : PatchDocumentResponse<T>
{
/// <summary>
/// Indicates whether an error occurred.
/// </summary>
public bool Error { get; set; }

/// <summary>
/// Error message.
/// </summary>
public string ErrorMessage { get; set; }

/// <summary>
/// ArangoDB error number.
/// </summary>
public int ErrorNum { get; set; }
}
}
33 changes: 26 additions & 7 deletions arangodb-net-standard/DocumentApi/Models/PatchDocumentsResponse.cs
Original file line number Diff line number Diff line change
@@ -1,14 +1,33 @@
namespace ArangoDBNetStandard.DocumentApi.Models
using System.Collections.Generic;

namespace ArangoDBNetStandard.DocumentApi.Models
{
public class PatchDocumentsResponse<T> : PatchDocumentResponse<T>
/// <summary>
/// Represents the response for updating multiple documents.
/// </summary>
/// <typeparam name="T">The type of the deserialized new/old document object when requested.</typeparam>
public class PatchDocumentsResponse<T> : List<PatchDocumentsDocumentResponse<T>>
{
public bool Error { get; set; }

/// <summary>
/// Error message.
/// Creates an instance of <see cref="PatchDocumentsResponse{T}"/>.
/// </summary>
public string ErrorMessage { get; set; }
public PatchDocumentsResponse()
{
}

private PatchDocumentsResponse(int capacity)
: base(capacity)
{
}

public int ErrorNum { get; set; }
/// <summary>
/// Creates an empty response.
/// This is used when <see cref="PostDocumentsQuery.Silent"/> is true.
/// </summary>
/// <returns></returns>
public static PatchDocumentsResponse<T> Empty()
{
return new PatchDocumentsResponse<T>(0);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,9 @@ public class PostDocumentsQuery
public bool? ReturnOld { get; set; }

/// <summary>
/// TODO
/// If set to true, an empty object will be returned as response.
/// No meta-data will be returned for the created document.
/// This option can be used to save some network traffic.
/// </summary>
public bool? Silent { get; set; }

Expand Down
12 changes: 10 additions & 2 deletions arangodb-net-standard/DocumentApi/Models/PostDocumentsResponse.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,14 @@
namespace ArangoDBNetStandard.DocumentApi.Models
{
/// <summary>
/// Response after posting multiple documents
/// Represents the response for creating multiple documents.
/// </summary>
/// <typeparam name="T"></typeparam>
/// <typeparam name="T">The type of the deserialized new/old document object when requested.</typeparam>
public class PostDocumentsResponse<T> : List<PostDocumentsDocumentResponse<T>>
{
/// <summary>
/// Creates an instance of <see cref="PostDocumentsResponse{T}"/>.
/// </summary>
public PostDocumentsResponse()
{
}
Expand All @@ -17,6 +20,11 @@ private PostDocumentsResponse(int capacity)
{
}

/// <summary>
/// Creates an empty response.
/// This is used when <see cref="PostDocumentsQuery.Silent"/> is true.
/// </summary>
/// <returns></returns>
public static PostDocumentsResponse<T> Empty()
{
return new PostDocumentsResponse<T>(0);
Expand Down

0 comments on commit b8c8615

Please sign in to comment.