Skip to content

Commit

Permalink
Fix inconsistent usage of T and U types for body and response.
Browse files Browse the repository at this point in the history
fix #266
  • Loading branch information
DiscoPYF committed Aug 15, 2020
1 parent 7f2cc30 commit 10974ff
Show file tree
Hide file tree
Showing 7 changed files with 34 additions and 21 deletions.
4 changes: 2 additions & 2 deletions arangodb-net-standard.Test/GraphApi/GraphApiClientTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1547,7 +1547,7 @@ await _fixture.ArangoDBClient.Graph.PostGraphAsync(new PostGraphBody
WaitForSync = true
});

var response = await _client.PatchEdgeAsync<PatchEdgeMockModel, object>(
var response = await _client.PatchEdgeAsync<object, PatchEdgeMockModel>(
graphName,
edgeClx,
createEdgeResponse.Edge._key,
Expand Down Expand Up @@ -1579,7 +1579,7 @@ public async Task PatchEdgeAsync_ShouldThrow_WhenGraphNotFound()

var exception = await Assert.ThrowsAsync<ApiErrorException>(async () =>
{
await _client.PatchEdgeAsync<PatchEdgeMockModel, object>(graphName, "edgeClx", "", new { });
await _client.PatchEdgeAsync<object, PatchEdgeMockModel>(graphName, "edgeClx", "", new { });
});

Assert.Equal(HttpStatusCode.NotFound, exception.ApiError.Code);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,24 @@
using System.Net;

namespace ArangoDBNetStandard.DocumentApi.Models
namespace ArangoDBNetStandard.DocumentApi.Models
{
public class DeleteDocumentsDocumentResponse<T>: DeleteDocumentResponse<T>
/// <summary>
/// Represents the response for one document when deleting multiple document.
/// </summary>
/// <typeparam name="T">The type of the deserialized old document object when requested.</typeparam>
public class DeleteDocumentsDocumentResponse<T> : DeleteDocumentResponse<T>
{
/// <summary>
/// Indicates whether an error occurred.
/// </summary>
public bool Error { get; set; }

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

/// <summary>
/// ArangoDB error number.
/// </summary>
public int ErrorNum { get; set; }
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,20 @@
/// <summary>
/// Represents a response returned when updating a single document.
/// </summary>
/// <typeparam name="U">The type of the deserialized new/old document object when requested.</typeparam>
public class PatchDocumentResponse<U> : DocumentBase
/// <typeparam name="T">The type of the deserialized new/old document object when requested.</typeparam>
public class PatchDocumentResponse<T> : DocumentBase
{
/// <summary>
/// Deserialized copy of the new document object. This will only be present if requested with the
/// <see cref="PatchDocumentQuery.ReturnNew"/> option.
/// </summary>
public U New { get; set; }
public T New { get; set; }

/// <summary>
/// Deserialized copy of the old document object. This will only be present if requested with the
/// <see cref="PatchDocumentQuery.ReturnOld"/> option.
/// </summary>
public U Old { get; set; }
public T Old { get; set; }

/// <summary>
/// Contains the revision of the old (now updated) document.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ public class PatchDocumentsDocumentResponse<T> : PatchDocumentResponse<T>
public bool Error { get; set; }

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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ public class PutDocumentsDocumentResponse<T> : PutDocumentResponse<T>
public bool Error { get; set; }

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

Expand Down
11 changes: 6 additions & 5 deletions arangodb-net-standard/GraphApi/GraphApiClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -652,19 +652,20 @@ public virtual async Task<PutEdgeDefinitionResponse> PutEdgeDefinitionAsync(
/// Updates the data of the specific edge in the collection.
/// PATCH/_api/gharial/{graph}/edge/{collection}/{edge}
/// </summary>
/// <typeparam name="T">Type of the returned edge document, when ReturnOld or ReturnNew query params are used.</typeparam>
/// <typeparam name="U">Type of the patch object used to perform a partial update of the edge document.</typeparam>
/// <typeparam name="T">Type of the patch object used to perform a partial update of the edge document.</typeparam>
/// <typeparam name="U">Type of the returned edge document,
/// when <see cref="PatchEdgeQuery.ReturnOld"/> or <see cref="PatchEdgeQuery.ReturnNew"/> query params are used.</typeparam>
/// <param name="graphName"></param>
/// <param name="collectionName"></param>
/// <param name="edgeKey"></param>
/// <param name="edge"></param>
/// <param name="query"></param>
/// <returns></returns>
public virtual async Task<PatchEdgeResponse<T>> PatchEdgeAsync<T, U>(
public virtual async Task<PatchEdgeResponse<U>> PatchEdgeAsync<T, U>(
string graphName,
string collectionName,
string edgeKey,
U edge,
T edge,
PatchEdgeQuery query = null)
{
var content = GetContent(edge, true, true);
Expand All @@ -682,7 +683,7 @@ public virtual async Task<PatchEdgeResponse<T>> PatchEdgeAsync<T, U>(
if (response.IsSuccessStatusCode)
{
var stream = await response.Content.ReadAsStreamAsync();
return DeserializeJsonFromStream<PatchEdgeResponse<T>>(stream);
return DeserializeJsonFromStream<PatchEdgeResponse<U>>(stream);
}
throw await GetApiErrorException(response);
}
Expand Down
9 changes: 5 additions & 4 deletions arangodb-net-standard/GraphApi/IGraphApiClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -297,19 +297,20 @@ Task<PutEdgeDefinitionResponse> PutEdgeDefinitionAsync(
/// Updates the data of the specific edge in the collection.
/// PATCH/_api/gharial/{graph}/edge/{collection}/{edge}
/// </summary>
/// <typeparam name="T">Type of the returned edge document, when ReturnOld or ReturnNew query params are used.</typeparam>
/// <typeparam name="U">Type of the patch object used to perform a partial update of the edge document.</typeparam>
/// <typeparam name="T">Type of the patch object used to perform a partial update of the edge document.</typeparam>
/// <typeparam name="U">Type of the returned edge document,
/// when <see cref="PatchEdgeQuery.ReturnOld"/> or <see cref="PatchEdgeQuery.ReturnNew"/> query params are used.</typeparam>
/// <param name="graphName"></param>
/// <param name="collectionName"></param>
/// <param name="edgeKey"></param>
/// <param name="edge"></param>
/// <param name="query"></param>
/// <returns></returns>
Task<PatchEdgeResponse<T>> PatchEdgeAsync<T, U>(
Task<PatchEdgeResponse<U>> PatchEdgeAsync<T, U>(
string graphName,
string collectionName,
string edgeKey,
U edge,
T edge,
PatchEdgeQuery query = null);

/// <summary>
Expand Down

0 comments on commit 10974ff

Please sign in to comment.