Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 8 additions & 5 deletions .github/workflows/publish-package-pipeline.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,12 @@ on:
- development
paths:
- 'Artifacts/Comanda.Internal.Contracts/**'
pull_request:
branches:
- master
- development
paths:
- 'Artifacts/Comanda.Internal.Contracts/**'

jobs:
publish:
Expand Down Expand Up @@ -38,11 +44,8 @@ jobs:

if [[ "${GITHUB_REF}" == "refs/heads/master" ]]; then
VERSION="${BASE_VERSION}.${GITHUB_RUN_NUMBER}"
elif [[ "${GITHUB_REF}" == "refs/heads/development" ]]; then
VERSION="${BASE_VERSION}-beta.${GITHUB_RUN_NUMBER}"
else
echo "branch not configured for publication"
exit 1
VERSION="${BASE_VERSION}-beta.${GITHUB_RUN_NUMBER}"
fi

echo "use version: $VERSION"
Expand All @@ -51,4 +54,4 @@ jobs:
echo "package_version=$VERSION" >> $GITHUB_OUTPUT

- name: push package to nuget
run: dotnet nuget push ./output/*.nupkg -k ${{ secrets.NUGET_API_KEY }} -s https://api.nuget.org/v3/index.json --skip-duplicate
run: dotnet nuget push ./output/*.nupkg -k ${{ secrets.NUGET_API_KEY }} -s https://api.nuget.org/v3/index.json --skip-duplicate
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,7 @@ public sealed class OrderClient(HttpClient httpClient) : IOrderClient
PropertyNameCaseInsensitive = true
};

public async Task<Result<PaginationScheme<OrderScheme>>> GetOrdersAsync(
OrdersFetchParameters parameters, CancellationToken cancellation = default)
public async Task<Result<PaginationScheme<OrderScheme>>> GetOrdersAsync(OrdersFetchParameters parameters, CancellationToken cancellation = default)
{
var queryString = QueryParametersParser.ToQueryString(parameters);

Expand Down Expand Up @@ -62,8 +61,7 @@ public async Task<Result<PaginationScheme<OrderScheme>>> GetOrdersAsync(
return Result<PaginationScheme<OrderScheme>>.Success(result);
}

public async Task<Result<OrderScheme>> CreateOrderAsync(
OrderCreationScheme parameters, CancellationToken cancellation = default)
public async Task<Result<OrderScheme>> CreateOrderAsync(OrderCreationScheme parameters, CancellationToken cancellation = default)
{
var response = await httpClient.PostAsJsonAsync("orders", parameters, cancellation);
var content = await response.Content.ReadAsStringAsync(cancellation);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ public sealed record OrderCreationScheme : IDispatchable<Result<OrderScheme>>
{
public Fulfillment Fulfillment { get; init; }
public Priority Priority { get; init; }
public Address? Address { get; init; } = default!;
public Metadata Metadata { get; init; } = default!;
public IEnumerable<Item> Items { get; init; } = [];
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ public sealed record OrderScheme
public string Identifier { get; init; } = default!;
public string Code { get; init; } = default!;

public Address? Address { get; init; } = default!;
public Status Status { get; init; }
public Priority Priority { get; init; }
public Fulfillment Fulfillment { get; init; }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ public static Order AsOrder(this OrderCreationScheme scheme, Code code)
var order = new Order
{
Code = code,
Address = scheme.Address,
Fulfillment = scheme.Fulfillment,
Priority = scheme.Priority,
Metadata = scheme.Metadata,
Expand Down Expand Up @@ -47,6 +48,7 @@ public static Order AsOrder(this OrderCreationScheme scheme, Code code)
{
Identifier = order.Id,
Code = order.Code.Identifier,
Address = order.Address,
Priority = order.Priority,
Status = order.Status,
Fulfillment = order.Fulfillment,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ public sealed record OrderCreationScheme : IDispatchable<Result<OrderScheme>>
{
public Fulfillment Fulfillment { get; init; }
public Priority Priority { get; init; }
public Address? Address { get; init; } = default!;
public Metadata Metadata { get; init; } = default!;
public IEnumerable<Item> Items { get; init; } = [];
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ public sealed record OrderScheme
public string Identifier { get; init; } = default!;
public string Code { get; init; } = default!;

public Address? Address { get; init; } = default!;
public Status Status { get; init; }
public Priority Priority { get; init; }
public Fulfillment Fulfillment { get; init; }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
global using Comanda.Orders.Application.Payloads.Order;
global using Comanda.Orders.Application.Mappers;

global using HttpsRichardy.Internal.Essentials.Utilities;
global using HttpsRichardy.Internal.Essentials.Patterns;
global using HttpsRichardy.Internal.Essentials.Filtering;
global using HttpsRichardy.Internal.Essentials.Concepts;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,11 @@ public OrderCreationSchemeValidator()
.IsInEnum()
.WithMessage("fulfillment must be a valid enum value.");

RuleFor(order => order.Address)
.NotNull()
.WithMessage("address must be provided when fulfillment is delivery.")
.When(order => order.Fulfillment == Fulfillment.Delivery);

RuleFor(order => order.Priority)
.IsInEnum()
.WithMessage("priority must be a valid enum value.");
Expand All @@ -20,6 +25,31 @@ public OrderCreationSchemeValidator()
.NotNull()
.WithMessage("metadata must be provided.");

When(order => order.Fulfillment == Fulfillment.Delivery && order.Address is not null, () =>
{
RuleFor(order => order.Address!.Street)
.NotEmpty()
.WithMessage("The street field is required and cannot be empty.");

RuleFor(order => order.Address!.Number)
.NotEmpty()
.WithMessage("The number field is required and represents the street number of the address.");

RuleFor(order => order.Address!.City)
.NotEmpty()
.WithMessage("The city field is required and cannot be empty.");

RuleFor(order => order.Address!.State)
.NotEmpty()
.WithMessage("The state field is required and cannot be empty.");

RuleFor(order => order.Address!.ZipCode)
.NotEmpty()
.WithMessage("The zip code field is required.")
.Matches(ExpressionPatterns.Cep)
.WithMessage("The zip code is invalid. It must match the Brazilian postal code format.");
});

When(order => order.Metadata is not null, () =>
{
RuleFor(order => order.Metadata!.MerchantId)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ public sealed class Order : Aggregate
{
public Code Code { get; set; } = default!;
public Metadata Metadata { get; set; } = default!;
public Address? Address { get; set; } = default!;

public Status Status { get; set; } = Status.Pending;
public Priority Priority { get; set; } = Priority.Normal;
public Fulfillment Fulfillment { get; set; } = Fulfillment.Unspecified;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
namespace Comanda.Orders.Domain.Concepts;

public sealed record Address : IValueObject<Address>
{
public string Street { get; init; } = default!;
public string Number { get; init; } = default!;
public string City { get; init; } = default!;

public string State { get; init; } = default!;
public string ZipCode { get; init; } = default!;
public string Neighborhood { get; init; } = default!;

public string? Complement { get; init; }
public string? Reference { get; init; }
}
Loading