Skip to content

Commit

Permalink
chore: update sdk with new relationships api
Browse files Browse the repository at this point in the history
  • Loading branch information
daniel-almeida-konkconsulting committed Jun 14, 2024
1 parent 1639d16 commit 1d12c7f
Show file tree
Hide file tree
Showing 13 changed files with 91 additions and 142 deletions.
66 changes: 31 additions & 35 deletions ConsumerApi.Sdk/Endpoints/Relationships/RelationshipsEndpoint.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ namespace Backbone.ConsumerApi.Sdk.Endpoints.Relationships;

public class RelationshipsEndpoint(EndpointClient client) : ConsumerApiEndpoint(client)
{
public async Task<ApiResponse<Relationship>> GetRelationship(string id)
public async Task<ApiResponse<RelationshipDTO>> GetRelationship(string id)
{
return await _client.Get<Relationship>($"api/{API_VERSION}/Relationships/{id}");
return await _client.Get<RelationshipDTO>($"api/{API_VERSION}/Relationships/{id}");
}

public async Task<ApiResponse<ListRelationshipsResponse>> ListRelationships(PaginationFilter? pagination = null)
Expand All @@ -28,57 +28,53 @@ public async Task<ApiResponse<ListRelationshipsResponse>> ListRelationships(IEnu
.Execute();
}

public async Task<ApiResponse<RelationshipMetadata>> CreateRelationship(CreateRelationshipRequest request)
public async Task<ApiResponse<RelationshipMetadataDTO>> CreateRelationship(CreateRelationshipRequest request)
{
return await _client.Post<RelationshipMetadata>($"api/{API_VERSION}/Relationships", request);
return await _client.Post<RelationshipMetadataDTO>($"api/{API_VERSION}/Relationships", request);
}

public async Task<ApiResponse<ListRelationshipChangesResponse>> ListChanges(
PaginationFilter? pagination = null, IEnumerable<string>? ids = null, OptionalDateRange? createdAt = null, OptionalDateRange? completedAt = null,
OptionalDateRange? modifiedAt = null, bool? onlyPeerChanges = null, string? createdBy = null, string? completedBy = null, string? status = null,
string? type = null
)
public async Task<ApiResponse<RelationshipMetadataDTO>> AcceptRelationship(string relationshipId, AcceptRelationshipRequest request)
{
var builder = _client
.Request<ListRelationshipChangesResponse>(HttpMethod.Get, $"api/{API_VERSION}/Relationships/Changes")
.Authenticate()
.WithPagination(pagination);
return await _client.Put<RelationshipMetadataDTO>($"api/{API_VERSION}/Relationships/{relationshipId}/Accept", request);
}

public async Task<ApiResponse<RelationshipMetadataDTO>> RejectRelationship(string relationshipId, RejectRelationshipRequest request)
{
return await _client.Put<RelationshipMetadataDTO>($"api/{API_VERSION}/Relationships/{relationshipId}/Reject", request);
}

if (ids != null)
{
var arr = ids.ToArray();
if (arr.Length != 0) builder.AddQueryParameter("ids", arr);
}
public async Task<ApiResponse<RelationshipMetadataDTO>> RevokeRelationship(string relationshipId, RevokeRelationshipRequest request)
{
return await _client.Put<RelationshipMetadataDTO>($"api/{API_VERSION}/Relationships/{relationshipId}/Revoke", request);
}

if (createdAt != null) builder.AddQueryParameter("createdAt", createdAt);
if (completedAt != null) builder.AddQueryParameter("completedAt", completedAt);
if (modifiedAt != null) builder.AddQueryParameter("modifiedAt", modifiedAt);
if (onlyPeerChanges != null) builder.AddQueryParameter("onlyPeerChanges", onlyPeerChanges);
if (createdBy != null) builder.AddQueryParameter("createdBy", createdBy);
if (completedBy != null) builder.AddQueryParameter("completedBy", completedBy);
if (status != null) builder.AddQueryParameter("status", status);
if (type != null) builder.AddQueryParameter("type", type);
public async Task<ApiResponse<RelationshipMetadataDTO>> RevokeRelationshipReactivation(string relationshipId)
{
return await _client.Put<RelationshipMetadataDTO>($"api/{API_VERSION}/Relationships/{relationshipId}/Reactivate/Revoke");
}

return await builder.Execute();
public async Task<ApiResponse<RelationshipDTO>> TerminateRelationship(string relationshipId)
{
return await _client.Put<RelationshipDTO>($"api/{API_VERSION}/Relationships/{relationshipId}/Terminate");
}

public async Task<ApiResponse<RelationshipChange>> GetChange(string id)
public async Task<ApiResponse<RelationshipMetadataDTO>> RelationshipReactivationRequest(string relationshipId)
{
return await _client.Get<RelationshipChange>($"api/{API_VERSION}/Relationships/Changes/{id}");
return await _client.Put<RelationshipMetadataDTO>($"api/{API_VERSION}/Relationships/{relationshipId}/Reactivate");
}

public async Task<ApiResponse<RelationshipMetadata>> AcceptChange(string relationshipId, string changeId, CompleteRelationshipChangeRequest request)
public async Task<ApiResponse<RelationshipMetadataDTO>> AcceptReactivationOfRelationship(string relationshipId)
{
return await _client.Put<RelationshipMetadata>($"api/{API_VERSION}/Relationships/{relationshipId}/Changes/{changeId}/Accept", request);
return await _client.Put<RelationshipMetadataDTO>($"api/{API_VERSION}/Relationships/{relationshipId}/Reactivate/Accept");
}

public async Task<ApiResponse<RelationshipMetadata>> RejectChange(string relationshipId, string changeId, CompleteRelationshipChangeRequest request)
public async Task<ApiResponse<RelationshipMetadataDTO>> RejectReactivationOfRelationship(string relationshipId)
{
return await _client.Put<RelationshipMetadata>($"api/{API_VERSION}/Relationships/{relationshipId}/Changes/{changeId}/Reject", request);
return await _client.Put<RelationshipMetadataDTO>($"api/{API_VERSION}/Relationships/{relationshipId}/Reactivate/Reject");
}

public async Task<ApiResponse<RelationshipMetadata>> RevokeChange(string relationshipId, string changeId, CompleteRelationshipChangeRequest request)
public async Task<ApiResponse<RelationshipMetadataDTO>> DecomposeRelationship(string relationshipId)
{
return await _client.Put<RelationshipMetadata>($"api/{API_VERSION}/Relationships/{relationshipId}/Changes/{changeId}/Revoke", request);
return await _client.Put<RelationshipMetadataDTO>($"api/{API_VERSION}/Relationships/{relationshipId}/Decompose");
}
}

This file was deleted.

45 changes: 0 additions & 45 deletions ConsumerApi.Sdk/Endpoints/Relationships/Types/Relationship.cs

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
namespace Backbone.ConsumerApi.Sdk.Endpoints.Relationships.Types;

public class RelationshipAuditLogEntryDTO
{
public required DateTime CreatedAt { get; set; }
public required string CreatedBy { get; set; }
public required string CreatedByDevice { get; set; }
public required string Reason { get; set; }
public required string? OldStatus { get; set; }
public required string NewStatus { get; set; }
}
14 changes: 14 additions & 0 deletions ConsumerApi.Sdk/Endpoints/Relationships/Types/RelationshipDTO.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
namespace Backbone.ConsumerApi.Sdk.Endpoints.Relationships.Types;

public class RelationshipDTO
{
public required string Id { get; set; }
public required string RelationshipTemplateId { get; set; }
public required string From { get; set; }
public required string To { get; set; }
public byte[]? CreationContent { get; set; }
public byte[]? CreationResponseContent { get; set; }
public DateTime CreatedAt { get; set; }
public required string Status { get; set; }
public required List<RelationshipAuditLogEntryDTO> AuditLog { get; set; }
}

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
namespace Backbone.ConsumerApi.Sdk.Endpoints.Relationships.Types;

public class RelationshipMetadataDTO
{
public required string Id { get; set; }
public required string RelationshipTemplateId { get; set; }

public required string From { get; set; }
public required string To { get; set; }

public required DateTime CreatedAt { get; set; }

public required string Status { get; set; }

public required List<RelationshipAuditLogEntryDTO> AuditLog { get; set; }
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
namespace Backbone.ConsumerApi.Sdk.Endpoints.Relationships.Types.Requests;

public class AcceptRelationshipRequest
{
public byte[]? CreationResponseContent { get; set; } = Array.Empty<byte>();
}

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
namespace Backbone.ConsumerApi.Sdk.Endpoints.Relationships.Types.Requests;

public class RejectRelationshipRequest
{
public byte[]? CreationResponseContent { get; set; } = Array.Empty<byte>();
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
namespace Backbone.ConsumerApi.Sdk.Endpoints.Relationships.Types.Requests;

public class RevokeRelationshipRequest
{
public byte[]? CreationResponseContent { get; set; } = Array.Empty<byte>();
}

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@

namespace Backbone.ConsumerApi.Sdk.Endpoints.Relationships.Types.Responses;

public class ListRelationshipsResponse : EnumerableResponseBase<Relationship>;
public class ListRelationshipsResponse : EnumerableResponseBase<RelationshipDTO>;

0 comments on commit 1d12c7f

Please sign in to comment.