Table of Contents

Class InvoiceEndpoints

Namespace
arolariu.Backend.Domain.Invoices.Endpoints
Assembly
arolariu.Backend.Domain.Invoices.dll

The invoice endpoints.

public static class InvoiceEndpoints
Inheritance
InvoiceEndpoints
Inherited Members

Fields

EndpointNameTag

private const string EndpointNameTag = "Invoices Management System v1.0.0-alphaRC1"

Field Value

string

SemanticVersioning

private const string SemanticVersioning = "1.0.0-alphaRC1"

Field Value

string

Methods

AddInvoiceToMerchantAsync(IInvoiceProcessingService, IHttpContextAccessor, Guid, IEnumerable<Guid>, ClaimsPrincipal)

Adds invoice(s) to a specific merchant.

[SwaggerOperation(null, null, Summary = "Adds invoice(s) to a specific merchant in the system.", Description = "Adds invoice(s) to a specific merchant in the Invoice Management System. If the merchant identifier passed to the route is valid, the server will add the invoice(s) to the merchant, given that the user is allowed to add invoices to this merchant.", OperationId = "AddInvoiceToMerchantAsync", Tags = new string[] { "Invoices Management System v1.0.0-alphaRC1" })]
[SwaggerResponse(202, "The invoice(s) were added to the merchant successfully.", typeof(Merchant))]
[SwaggerResponse(400, "The merchant identifier is not valid. Please input a valid identifier.", typeof(ValidationProblemDetails))]
[SwaggerResponse(401, "You are not authorized to add invoices to this merchant.", typeof(ProblemDetails))]
[SwaggerResponse(404, "The invoices could not be added to the merchant due to the merchant not being found.", typeof(ProblemDetails))]
[SwaggerResponse(409, "The invoices could not be added to the merchant due to a conflict (the invoices are already in the merchant).", typeof(ProblemDetails))]
[SwaggerResponse(413, "The invoices could not be added to the merchant due to the payload being too large (keep the request under 1MB).", typeof(ProblemDetails))]
[SwaggerResponse(429, "You have made too many requests, slow down a little.", typeof(ProblemDetails))]
[SwaggerResponse(500, "The invoices could not be added to the merchant due to an internal service error.", typeof(ProblemDetails))]
[Authorize]
internal static Task<IResult> AddInvoiceToMerchantAsync(IInvoiceProcessingService invoiceProcessingService, IHttpContextAccessor httpContext, Guid id, IEnumerable<Guid> invoiceIdentifiers, ClaimsPrincipal principal)

Parameters

invoiceProcessingService IInvoiceProcessingService
httpContext IHttpContextAccessor
id Guid
invoiceIdentifiers IEnumerable<Guid>
principal ClaimsPrincipal

Returns

Task<IResult>

AddMerchantToInvoiceAsync(IInvoiceProcessingService, IHttpContextAccessor, Guid, Merchant, ClaimsPrincipal)

Adds a merchant to an invoice.

[SwaggerOperation(null, null, Summary = "Adds a merchant to an invoice in the system.", Description = "Adds a merchant to an invoice in the Invoice Management System. If the invoice identifier passed to the route is valid, the server will add the merchant to the invoice, given that the user is allowed to add merchants to this invoice.", OperationId = "AddMerchantToInvoiceAsync", Tags = new string[] { "Invoices Management System v1.0.0-alphaRC1" })]
[SwaggerResponse(201, "The merchant was added to the invoice successfully.", typeof(Invoice))]
[SwaggerResponse(400, "The merchant information is not valid (please respect the merchant schema).", typeof(ValidationProblemDetails))]
[SwaggerResponse(401, "You are not authorized to perform this operation.", typeof(ProblemDetails))]
[SwaggerResponse(404, "The merchant could not be added to the invoice due to the invoice not being found.", typeof(ProblemDetails))]
[SwaggerResponse(409, "The merchant could not be added to the invoice due to a conflict (the merchant is not in the invoice).", typeof(ProblemDetails))]
[SwaggerResponse(413, "The merchant could not be added to the invoice due to the payload being too large (keep the request under 1MB).", typeof(ProblemDetails))]
[SwaggerResponse(429, "You have made too many requests, slow down a little.", typeof(ProblemDetails))]
[SwaggerResponse(500, "The merchant could not be added to the invoice due to an internal service error", typeof(ProblemDetails))]
[Authorize]
internal static Task<IResult> AddMerchantToInvoiceAsync(IInvoiceProcessingService invoiceProcessingService, IHttpContextAccessor httpContext, Guid id, Merchant merchant, ClaimsPrincipal principal)

Parameters

invoiceProcessingService IInvoiceProcessingService
httpContext IHttpContextAccessor
id Guid
merchant Merchant
principal ClaimsPrincipal

Returns

Task<IResult>

AddProductToInvoiceAsync(IInvoiceProcessingService, IHttpContextAccessor, Guid, Product, ClaimsPrincipal)

Adds a product to a specific invoice.

[SwaggerOperation(null, null, Summary = "Adds a product to a specific invoice in the system.", Description = "Adds a product to a specific invoice in the Invoice Management System. If the invoice identifier passed to the route is valid, the server will add the product to the invoice, given that the user is allowed to add products to this invoice.", OperationId = "AddProductToInvoiceAsync", Tags = new string[] { "Invoices Management System v1.0.0-alphaRC1" })]
[SwaggerResponse(202, "The product was added to the invoice successfully.", typeof(Invoice))]
[SwaggerResponse(400, "The product information is not valid (please respect the product schema).", typeof(ValidationProblemDetails))]
[SwaggerResponse(401, "You are not authorized to perform this operation.", typeof(ProblemDetails))]
[SwaggerResponse(404, "The product could not be added to the invoice due to the invoice not being found.", typeof(ProblemDetails))]
[SwaggerResponse(409, "The product could not be added to the invoice due to a conflict (the product is already in the invoice).", typeof(ProblemDetails))]
[SwaggerResponse(413, "The product could not be added to the invoice due to the payload being too large (keep the request under 1MB).", typeof(ProblemDetails))]
[SwaggerResponse(429, "You have made too many requests, slow down a little.", typeof(ProblemDetails))]
[SwaggerResponse(500, "The product could not be added to the invoice due to an internal service error.", typeof(ProblemDetails))]
[Authorize]
internal static Task<IResult> AddProductToInvoiceAsync(IInvoiceProcessingService invoiceProcessingService, IHttpContextAccessor httpContext, Guid id, Product product, ClaimsPrincipal principal)

Parameters

invoiceProcessingService IInvoiceProcessingService
httpContext IHttpContextAccessor
id Guid
product Product
principal ClaimsPrincipal

Returns

Task<IResult>

AnalyzeInvoiceAsync(IInvoiceProcessingService, IHttpContextAccessor, Guid, AnalysisOptions, ClaimsPrincipal)

Analyzes a specific invoice.

[SwaggerOperation(null, null, Summary = "Analyzes a specific invoice from the system.", Description = "Analyzes a specific invoice from the Invoice Management System. If the invoice identifier passed to the route is valid, the server will start analyzing the invoice, given that the user is allowed to perform this operation.", OperationId = "AnalyzeInvoiceAsync", Tags = new string[] { "Invoices Management System v1.0.0-alphaRC1" })]
[SwaggerResponse(202, "The invoice was analyzed successfully.", typeof(Invoice))]
[SwaggerResponse(400, "The invoice identifier is not valid.", typeof(ValidationProblemDetails))]
[SwaggerResponse(401, "You are not authorized to perform this operation.", typeof(ProblemDetails))]
[SwaggerResponse(402, "You cannot analyze this invoice. You don't have enough credits.", typeof(ProblemDetails))]
[SwaggerResponse(403, "You are not authenticated. Please authenticate before hitting this endpoint.", typeof(ProblemDetails))]
[SwaggerResponse(404, "The invoice could not be analyzed due to the invoice not being found.", typeof(ProblemDetails))]
[SwaggerResponse(429, "You have made too many requests, slow down a little.", typeof(ProblemDetails))]
[SwaggerResponse(500, "The invoice could not be analyzed due to an internal service error.", typeof(ProblemDetails))]
[Authorize]
internal static Task<IResult> AnalyzeInvoiceAsync(IInvoiceProcessingService invoiceProcessingService, IHttpContextAccessor httpContext, Guid id, AnalysisOptions options, ClaimsPrincipal principal)

Parameters

invoiceProcessingService IInvoiceProcessingService
httpContext IHttpContextAccessor
id Guid
options AnalysisOptions
principal ClaimsPrincipal

Returns

Task<IResult>

CreateNewInvoiceAsync(IInvoiceProcessingService, IHttpContextAccessor, CreateInvoiceDto, ClaimsPrincipal)

Creates a new invoice.

[SwaggerOperation(null, null, Summary = "Create a new invoice (receipt) in the system.", Description = "This request will create a new invoice in the Invoice Management System. This endpoint will validate that the input (Invoice DTO) is valid, and then will perform a series of operations to onboard the invoice into the Invoice Management System.", OperationId = "CreateNewInvoiceAsync", Tags = new string[] { "Invoices Management System v1.0.0-alphaRC1" })]
[SwaggerResponse(201, "The invoice was created successfully in the system.", typeof(Invoice))]
[SwaggerResponse(400, "The invoice DTO (payload) is not valid. Please respect the request body.", typeof(ValidationProblemDetails))]
[SwaggerResponse(401, "You are not authorized to create a new invoice in the system.", typeof(ProblemDetails))]
[SwaggerResponse(403, "You are not authenticated. Please authenticate with a valid account.", typeof(ProblemDetails))]
[SwaggerResponse(409, "The invoice could not be created due to a conflict (there is another invoice with the same id).", typeof(ProblemDetails))]
[SwaggerResponse(413, "The invoice could not be created due to the payload being too large (keep the request under 1MB).", typeof(ProblemDetails))]
[SwaggerResponse(429, "You have made too many requests, slow down a little.", typeof(ProblemDetails))]
[SwaggerResponse(500, "The invoice could not be created due to an internal service error.", typeof(ProblemDetails))]
[Authorize]
internal static Task<IResult> CreateNewInvoiceAsync(IInvoiceProcessingService invoiceProcessingService, IHttpContextAccessor httpContext, CreateInvoiceDto invoiceDto, ClaimsPrincipal principal)

Parameters

invoiceProcessingService IInvoiceProcessingService
httpContext IHttpContextAccessor
invoiceDto CreateInvoiceDto
principal ClaimsPrincipal

Returns

Task<IResult>

CreateNewMerchantAsync(IInvoiceProcessingService, IHttpContextAccessor, CreateMerchantDto, ClaimsPrincipal)

Creates a new merchant.

[SwaggerOperation(null, null, Summary = "Creates a new merchant in the system.", Description = "Creates a new merchant in the Merchant Management System. This endpoint will validate that the input (Merchant DTO) is valid, and then will perform a series of operations to onboard the merchant into the Merchant Management System.", OperationId = "CreateNewMerchantAsync", Tags = new string[] { "Invoices Management System v1.0.0-alphaRC1" })]
[SwaggerResponse(201, "The merchant was created successfully in the system.", typeof(Merchant))]
[SwaggerResponse(400, "The merchant DTO (payload) is not valid. Please respect the request body.", typeof(ValidationProblemDetails))]
[SwaggerResponse(401, "You are not authorized to create a new merchant in the system.", typeof(ProblemDetails))]
[SwaggerResponse(403, "You are not authenticated. Please authenticate with a valid account.", typeof(ProblemDetails))]
[SwaggerResponse(409, "The merchant could not be created due to a conflict (there is another merchant with the same id).", typeof(ProblemDetails))]
[SwaggerResponse(413, "The merchant could not be created due to the payload being too large (keep the request under 1MB).", typeof(ProblemDetails))]
[SwaggerResponse(429, "You have made too many requests, slow down a little.", typeof(ProblemDetails))]
[SwaggerResponse(500, "The merchant could not be created due to an internal service error.", typeof(ProblemDetails))]
[Authorize]
internal static Task<IResult> CreateNewMerchantAsync(IInvoiceProcessingService invoiceProcessingService, IHttpContextAccessor httpContext, CreateMerchantDto merchantDto, ClaimsPrincipal principal)

Parameters

invoiceProcessingService IInvoiceProcessingService
httpContext IHttpContextAccessor
merchantDto CreateMerchantDto
principal ClaimsPrincipal

Returns

Task<IResult>

DeleteInvoiceAsync(IInvoiceProcessingService, IHttpContextAccessor, Guid, ClaimsPrincipal)

Deletes a specific invoice.

[SwaggerOperation(null, null, Summary = "Deletes a specific invoice from the system.", Description = "Deletes a specific invoice from the Invoice Management System. If the invoice identifier passed to the route is valid, the server will delete the invoice, given that the user is allowed to delete this invoice.", OperationId = "DeleteInvoiceAsync", Tags = new string[] { "Invoices Management System v1.0.0-alphaRC1" })]
[SwaggerResponse(204, "The invoice was deleted successfully.", null)]
[SwaggerResponse(400, "The invoice identifier is not valid.", typeof(ValidationProblemDetails))]
[SwaggerResponse(401, "You are not authorized to perform this operation.", typeof(ProblemDetails))]
[SwaggerResponse(403, "You are not authenticated. Please authenticate before hitting this endpoint.", typeof(ProblemDetails))]
[SwaggerResponse(404, "The invoice could not be deleted due to the invoice not being found.", typeof(ProblemDetails))]
[SwaggerResponse(429, "You have made too many requests, slow down a little.", typeof(ProblemDetails))]
[SwaggerResponse(500, "The invoice could not be deleted due to an internal service error.", typeof(ProblemDetails))]
[Authorize]
internal static Task<IResult> DeleteInvoiceAsync(IInvoiceProcessingService invoiceProcessingService, IHttpContextAccessor httpContext, Guid id, ClaimsPrincipal principal)

Parameters

invoiceProcessingService IInvoiceProcessingService
httpContext IHttpContextAccessor
id Guid
principal ClaimsPrincipal

Returns

Task<IResult>

DeleteMerchantAsync(IInvoiceProcessingService, IHttpContextAccessor, Guid, Guid, ClaimsPrincipal)

Deletes a specific merchant.

[SwaggerOperation(null, null, Summary = "Deletes a specific merchant from the system.", Description = "Deletes a specific merchant from the Merchant Management System. ", OperationId = "DeleteMerchantAsync", Tags = new string[] { "Invoices Management System v1.0.0-alphaRC1" })]
[SwaggerResponse(204, "The merchant was deleted successfully.", null)]
[SwaggerResponse(400, "The merchant identifier is not valid.", typeof(ValidationProblemDetails))]
[SwaggerResponse(401, "You are not authorized to perform this operation.", typeof(ProblemDetails))]
[SwaggerResponse(403, "You are not authenticated. Please authenticate before hitting this endpoint.", typeof(ProblemDetails))]
[SwaggerResponse(404, "The merchant could not be deleted due to the merchant not being found.", typeof(ProblemDetails))]
[SwaggerResponse(429, "You have made too many requests, slow down a little.", typeof(ProblemDetails))]
[SwaggerResponse(500, "The merchant could not be deleted due to an internal service error.", typeof(ProblemDetails))]
[Authorize]
internal static Task<IResult> DeleteMerchantAsync(IInvoiceProcessingService invoiceProcessingService, IHttpContextAccessor httpContext, Guid id, Guid parentCompanyId, ClaimsPrincipal principal)

Parameters

invoiceProcessingService IInvoiceProcessingService
httpContext IHttpContextAccessor
id Guid
parentCompanyId Guid
principal ClaimsPrincipal

Returns

Task<IResult>

IsPrincipalSuperUser(ClaimsPrincipal)

Helper method to check if the user is a super user. Super users tipically have more permissions than regular users.

private static bool IsPrincipalSuperUser(ClaimsPrincipal principal)

Parameters

principal ClaimsPrincipal

Returns

bool

MapInvoiceAnalysisEndpoints(IEndpointRouteBuilder)

The invoice analysis endpoints.

private static void MapInvoiceAnalysisEndpoints(this IEndpointRouteBuilder router)

Parameters

router IEndpointRouteBuilder

The IEndpointRouteBuilder used for mapping the endpoints.

MapInvoiceEndpoints(IEndpointRouteBuilder)

The map invoice endpoints static method, called by the app builder. This method maps all the invoice endpoints for the web application. The invoice endpoints are split into categories:

  • Standard invoice endpoints (CRUD operations)
public static void MapInvoiceEndpoints(this IEndpointRouteBuilder router)

Parameters

router IEndpointRouteBuilder

The IEndpointRouteBuilder used for mapping the endpoints.

MapStandardInvoiceEndpoints(IEndpointRouteBuilder)

Maps the standard invoice endpoints for the web application.

private static void MapStandardInvoiceEndpoints(this IEndpointRouteBuilder router)

Parameters

router IEndpointRouteBuilder

The IEndpointRouteBuilder used for mapping the endpoints.

MapStandardMerchantEndpoints(IEndpointRouteBuilder)

Maps the merchant endpoints for the web application.

private static void MapStandardMerchantEndpoints(this IEndpointRouteBuilder router)

Parameters

router IEndpointRouteBuilder

The IEndpointRouteBuilder used for mapping the endpoints.

RemoveInvoiceFromMerchantAsync(IInvoiceProcessingService, IHttpContextAccessor, Guid, IEnumerable<Guid>, ClaimsPrincipal)

Removes invoice(s) from a specific merchant.

[SwaggerOperation(null, null, Summary = "Removes invoice(s) from a specific merchant in the system.", Description = "Removes invoice(s) from a specific merchant in the Invoice Management System. If the merchant identifier passed to the route is valid, the server will remove the invoice(s) from the merchant, given that the user is allowed to remove invoices from this merchant.", OperationId = "RemoveInvoiceFromMerchantAsync", Tags = new string[] { "Invoices Management System v1.0.0-alphaRC1" })]
[SwaggerResponse(202, "The invoice(s) were removed from the merchant successfully.", typeof(Merchant))]
[SwaggerResponse(400, "The merchant identifier is not valid. Please input a valid identifier.", typeof(ValidationProblemDetails))]
[SwaggerResponse(401, "You are not authorized to remove invoices from this merchant.", typeof(ProblemDetails))]
[SwaggerResponse(404, "The invoices could not be removed from the merchant due to the merchant not being found.", typeof(ProblemDetails))]
[SwaggerResponse(409, "The invoices could not be removed from the merchant due to a conflict (the invoices are not in the merchant).", typeof(ProblemDetails))]
[SwaggerResponse(413, "The invoices could not be removed from the merchant due to the payload being too large (keep the request under 1MB).", typeof(ProblemDetails))]
[SwaggerResponse(429, "You have made too many requests, slow down a little.", typeof(ProblemDetails))]
[SwaggerResponse(500, "The invoices could not be removed from the merchant due to an internal service error.", typeof(ProblemDetails))]
[Authorize]
internal static Task<IResult> RemoveInvoiceFromMerchantAsync(IInvoiceProcessingService invoiceProcessingService, IHttpContextAccessor httpContext, Guid id, IEnumerable<Guid> invoiceIdentifiers, ClaimsPrincipal principal)

Parameters

invoiceProcessingService IInvoiceProcessingService
httpContext IHttpContextAccessor
id Guid
invoiceIdentifiers IEnumerable<Guid>
principal ClaimsPrincipal

Returns

Task<IResult>

RemoveMerchantFromInvoiceAsync(IInvoiceProcessingService, IHttpContextAccessor, Guid, ClaimsPrincipal)

Removes a merchant from an invoice.

[SwaggerOperation(null, null, Summary = "Removes a merchant from an invoice in the system.", Description = "Removes a merchant from an invoice in the Invoice Management System. If the invoice identifier passed to the route is valid, the server will remove the merchant from the invoice, given that the user is allowed to remove merchants from this invoice.", OperationId = "RemoveMerchantFromInvoiceAsync", Tags = new string[] { "Invoices Management System v1.0.0-alphaRC1" })]
[SwaggerResponse(204, "The merchant was removed from the invoice successfully.", typeof(Invoice))]
[SwaggerResponse(400, "The merchant information is not valid (please respect the merchant schema).", typeof(ValidationProblemDetails))]
[SwaggerResponse(401, "You are not authorized to perform this operation.", typeof(ProblemDetails))]
[SwaggerResponse(404, "The merchant could not be removed from the invoice due to the invoice not being found.", typeof(ProblemDetails))]
[SwaggerResponse(409, "The merchant could not be removed from the invoice due to a conflict (the merchant is not in the invoice).", typeof(ProblemDetails))]
[SwaggerResponse(413, "The merchant could not be removed from the invoice due to the payload being too large (keep the request under 1MB).", typeof(ProblemDetails))]
[SwaggerResponse(429, "You have made too many requests, slow down a little.", typeof(ProblemDetails))]
[SwaggerResponse(500, "The merchant could not be removed from the invoice due to an internal service error", typeof(ProblemDetails))]
[Authorize]
internal static Task<IResult> RemoveMerchantFromInvoiceAsync(IInvoiceProcessingService invoiceProcessingService, IHttpContextAccessor httpContext, Guid id, ClaimsPrincipal principal)

Parameters

invoiceProcessingService IInvoiceProcessingService
httpContext IHttpContextAccessor
id Guid
principal ClaimsPrincipal

Returns

Task<IResult>

RemoveProductFromInvoiceAsync(IInvoiceProcessingService, IHttpContextAccessor, Guid, string, ClaimsPrincipal)

Removes a product from a specific invoice.

[SwaggerOperation(null, null, Summary = "Removes a product from a specific invoice in the system.", Description = "Removes a product from a specific invoice in the Invoice Management System. If the invoice identifier passed to the route is valid, the server will remove the product from the invoice, given that the user is allowed to remove products from this invoice.", OperationId = "RemoveProductFromInvoiceAsync", Tags = new string[] { "Invoices Management System v1.0.0-alphaRC1" })]
[SwaggerResponse(202, "The product was removed from the invoice successfully.", typeof(Invoice))]
[SwaggerResponse(400, "The product information is not valid (please respect the product schema).", typeof(ValidationProblemDetails))]
[SwaggerResponse(401, "You are not authorized to perform this operation.", typeof(ProblemDetails))]
[SwaggerResponse(404, "The product could not be removed from the invoice due to the invoice not being found.", typeof(ProblemDetails))]
[SwaggerResponse(409, "The product could not be removed from the invoice due to a conflict (the product is not in the invoice).", typeof(ProblemDetails))]
[SwaggerResponse(413, "The product could not be removed from the invoice due to the payload being too large (keep the request under 1MB).", typeof(ProblemDetails))]
[SwaggerResponse(429, "You have made too many requests, slow down a little.", typeof(ProblemDetails))]
[SwaggerResponse(500, "The product could not be deleted due to an internal service error", typeof(ProblemDetails))]
[Authorize]
internal static Task<IResult> RemoveProductFromInvoiceAsync(IInvoiceProcessingService invoiceProcessingService, IHttpContextAccessor httpContext, Guid id, string productName, ClaimsPrincipal principal)

Parameters

invoiceProcessingService IInvoiceProcessingService
httpContext IHttpContextAccessor
id Guid
productName string
principal ClaimsPrincipal

Returns

Task<IResult>

RetrieveAllInvoicesAsync(IInvoiceProcessingService, IHttpContextAccessor, ClaimsPrincipal)

Retrieves all invoices.

[SwaggerOperation(null, null, Summary = "Retrieves all invoices from the system.", Description = "Retrieves all invoices from the Invoice Management System. If the user is allowed to see all invoices, the server will retrieve all invoices. This is a high-privillege request.", OperationId = "RetrieveAllInvoicesAsync", Tags = new string[] { "Invoices Management System v1.0.0-alphaRC1" })]
[SwaggerResponse(200, "The invoices were retrieved successfully from the system.", typeof(Invoice[]))]
[SwaggerResponse(401, "You are not authorized to perform this operation.", typeof(ProblemDetails))]
[SwaggerResponse(403, "You are not authenticated. Please authenticate before hitting this route.", typeof(ProblemDetails))]
[SwaggerResponse(429, "You have made too many requests, slow down a little.", typeof(ProblemDetails))]
[SwaggerResponse(500, "The invoices could not be retrieved due to an internal service error.", typeof(ProblemDetails))]
[Authorize]
internal static Task<IResult> RetrieveAllInvoicesAsync(IInvoiceProcessingService invoiceProcessingService, IHttpContextAccessor httpContext, ClaimsPrincipal principal)

Parameters

invoiceProcessingService IInvoiceProcessingService
httpContext IHttpContextAccessor
principal ClaimsPrincipal

Returns

Task<IResult>

RetrieveAllMerchantsAsync(IInvoiceProcessingService, IHttpContextAccessor, Guid, ClaimsPrincipal)

Retrieves all merchants.

[SwaggerOperation(null, null, Summary = "Retrieves all merchants from the system.", Description = "Retrieves all merchants from the Merchant Management System. ", OperationId = "RetrieveAllMerchantsAsync", Tags = new string[] { "Invoices Management System v1.0.0-alphaRC1" })]
[SwaggerResponse(200, "The merchants were retrieved successfully from the system.", typeof(Merchant[]))]
[SwaggerResponse(401, "You are not authorized to perform this operation.", typeof(ProblemDetails))]
[SwaggerResponse(403, "You are not authenticated. Please authenticate before hitting this endpoint.", typeof(ProblemDetails))]
[SwaggerResponse(429, "You have made too many requests, slow down a little.", typeof(ProblemDetails))]
[SwaggerResponse(500, "The merchants could not be retrieved due to an internal service error.", typeof(ProblemDetails))]
[Authorize]
internal static Task<IResult> RetrieveAllMerchantsAsync(IInvoiceProcessingService invoiceProcessingService, IHttpContextAccessor httpContext, Guid parentCompanyId, ClaimsPrincipal principal)

Parameters

invoiceProcessingService IInvoiceProcessingService
httpContext IHttpContextAccessor
parentCompanyId Guid
principal ClaimsPrincipal

Returns

Task<IResult>

RetrieveInvoicesFromMerchantAsync(IInvoiceProcessingService, IHttpContextAccessor, Guid, ClaimsPrincipal)

Retrieves all invoices from a specific merchant.

[SwaggerOperation(null, null, Summary = "Retrieves all invoices from a specific merchant in the system.", Description = "Retrieves all invoices from a specific merchant in the Invoice Management System. If the merchant identifier passed to the route is valid, the server will retrieve all invoices from the merchant, given that the user is allowed to see the invoices.", OperationId = "RetrieveInvoicesFromMerchantAsync", Tags = new string[] { "Invoices Management System v1.0.0-alphaRC1" })]
[SwaggerResponse(200, "The invoices were retrieved successfully from the merchant.", typeof(Invoice[]))]
[SwaggerResponse(400, "The merchant identifier is not valid. Please input a valid identifier.", typeof(ValidationProblemDetails))]
[SwaggerResponse(401, "You are not authorized to access the invoices from this merchant.", typeof(ProblemDetails))]
[SwaggerResponse(403, "You are not authenticated. Please authenticate with a valid account.", typeof(ProblemDetails))]
[SwaggerResponse(404, "The invoices could not be retrieved due to the merchant not being found.", typeof(ProblemDetails))]
[SwaggerResponse(429, "You have made too many requests, slow down a little.", typeof(ProblemDetails))]
[SwaggerResponse(500, "The invoices could not be retrieved due to an internal service error.", typeof(ProblemDetails))]
[Authorize]
internal static Task<IResult> RetrieveInvoicesFromMerchantAsync(IInvoiceProcessingService invoiceProcessingService, IHttpContextAccessor httpContext, Guid id, ClaimsPrincipal principal)

Parameters

invoiceProcessingService IInvoiceProcessingService
httpContext IHttpContextAccessor
id Guid
principal ClaimsPrincipal

Returns

Task<IResult>

RetrieveMerchantFromInvoiceAsync(IInvoiceProcessingService, IHttpContextAccessor, Guid, ClaimsPrincipal)

Retrieves the merchant from an invoice.

[SwaggerOperation(null, null, Summary = "Retrieves the merchant from an invoice in the system.", Description = "Retrieves the merchant from an invoice in the Invoice Management System. If the invoice identifier passed to the route is valid, the server will retrieve the merchant from the invoice, given that the user is allowed to see the merchant.", OperationId = "RetrieveMerchantFromInvoiceAsync", Tags = new string[] { "Invoices Management System v1.0.0-alphaRC1" })]
[SwaggerResponse(200, "The merchant was retrieved successfully from the invoice.", typeof(Merchant))]
[SwaggerResponse(400, "The invoice identifier is not valid. Please input a valid identifier.", typeof(ValidationProblemDetails))]
[SwaggerResponse(401, "You are not authorized to access the merchant from this invoice.", typeof(ProblemDetails))]
[SwaggerResponse(403, "You are not authenticated. Please authenticate with a valid account.", typeof(ProblemDetails))]
[SwaggerResponse(404, "The merchant could not be retrieved due to the invoice not being found.", typeof(ProblemDetails))]
[SwaggerResponse(429, "You have made too many requests, slow down a little.", typeof(ProblemDetails))]
[SwaggerResponse(500, "The merchant could not be retrieved due to an internal service error.", typeof(ProblemDetails))]
[Authorize]
internal static Task<IResult> RetrieveMerchantFromInvoiceAsync(IInvoiceProcessingService invoiceProcessingService, IHttpContextAccessor httpContext, Guid id, ClaimsPrincipal principal)

Parameters

invoiceProcessingService IInvoiceProcessingService
httpContext IHttpContextAccessor
id Guid
principal ClaimsPrincipal

Returns

Task<IResult>

RetrieveProductsFromInvoiceAsync(IInvoiceProcessingService, IHttpContextAccessor, Guid, ClaimsPrincipal)

Retrieves all products from a specific invoice.

[SwaggerOperation(null, null, Summary = "Retrieves all products from a specific invoice in the system.", Description = "Retrieves all products from a specific invoice in the Invoice Management System. If the invoice identifier passed to the route is valid, the server will retrieve all products from the invoice, given that the user is allowed to see the products.", OperationId = "RetrieveProductsFromInvoiceAsync", Tags = new string[] { "Invoices Management System v1.0.0-alphaRC1" })]
[SwaggerResponse(200, "The products were retrieved successfully from the invoice.", typeof(Product[]))]
[SwaggerResponse(400, "The invoice identifier is not valid. Please input a valid identifier.", typeof(ValidationProblemDetails))]
[SwaggerResponse(401, "You are not authorized to access the products from this invoice.", typeof(ProblemDetails))]
[SwaggerResponse(403, "You are not authenticated. Please authenticate with a valid account.", typeof(ProblemDetails))]
[SwaggerResponse(404, "The products could not be retrieved due to the invoice not being found.", typeof(ProblemDetails))]
[SwaggerResponse(429, "You have made too many requests, slow down a little.", typeof(ProblemDetails))]
[SwaggerResponse(500, "The products could not be retrieved due to an internal service error.", typeof(ProblemDetails))]
[Authorize]
internal static Task<IResult> RetrieveProductsFromInvoiceAsync(IInvoiceProcessingService invoiceProcessingService, IHttpContextAccessor httpContext, Guid id, ClaimsPrincipal principal)

Parameters

invoiceProcessingService IInvoiceProcessingService
httpContext IHttpContextAccessor
id Guid
principal ClaimsPrincipal

Returns

Task<IResult>

RetrieveProductsFromMerchantAsync(IInvoiceProcessingService, IHttpContextAccessor, Guid, ClaimsPrincipal)

Retrieves all products from a specific merchant.

[SwaggerOperation(null, null, Summary = "Retrieves all products from a specific merchant in the system.", Description = "Retrieves all products from a specific merchant in the Merchant Management System. If the merchant identifier passed to the route is valid, the server will retrieve all products from the merchant, given that the user is allowed to see the products.", OperationId = "RetrieveProductsFromMerchantAsync", Tags = new string[] { "Invoices Management System v1.0.0-alphaRC1" })]
[SwaggerResponse(200, "The products were retrieved successfully from the merchant.", typeof(Product[]))]
[SwaggerResponse(400, "The merchant identifier is not valid. Please input a valid identifier.", typeof(ValidationProblemDetails))]
[SwaggerResponse(401, "You are not authorized to access the products from this merchant.", typeof(ProblemDetails))]
[SwaggerResponse(403, "You are not authenticated. Please authenticate with a valid account.", typeof(ProblemDetails))]
[SwaggerResponse(404, "The products could not be retrieved due to the merchant not being found.", typeof(ProblemDetails))]
[SwaggerResponse(429, "You have made too many requests, slow down a little.", typeof(ProblemDetails))]
[SwaggerResponse(500, "The products could not be retrieved due to an internal service error.", typeof(ProblemDetails))]
[Authorize]
internal static Task<IResult> RetrieveProductsFromMerchantAsync(IInvoiceProcessingService invoiceProcessingService, IHttpContextAccessor httpContext, Guid id, ClaimsPrincipal principal)

Parameters

invoiceProcessingService IInvoiceProcessingService
httpContext IHttpContextAccessor
id Guid
principal ClaimsPrincipal

Returns

Task<IResult>

RetrieveSpecificInvoiceAsync(IInvoiceProcessingService, IHttpContextAccessor, Guid, ClaimsPrincipal)

Retrieves a specific invoice.

[SwaggerOperation(null, null, Summary = "Retrieves a specific invoice from the system.", Description = "Retrieves a specific invoice from the Invoice Management System. If the invoice identifier passed into the route is valid, the server will retrieve the invoice, given that the user is allowed to see this invoice.", OperationId = "RetrieveSpecificInvoiceAsync", Tags = new string[] { "Invoices Management System v1.0.0-alphaRC1" })]
[SwaggerResponse(200, "The invoice was retrieved successfully from the system.", typeof(Invoice))]
[SwaggerResponse(400, "The invoice identifier is not valid. Please input a valid identifier.", typeof(ValidationProblemDetails))]
[SwaggerResponse(401, "You are not authorized to access this invoice.", typeof(ProblemDetails))]
[SwaggerResponse(403, "You are not authenticated. Please authenticate with a valid account.", typeof(ProblemDetails))]
[SwaggerResponse(404, "The invoice could not be retrieved due to the invoice not being found.", typeof(ProblemDetails))]
[SwaggerResponse(429, "You have made too many requests, slow down a little.", typeof(ProblemDetails))]
[SwaggerResponse(500, "The invoice could not be retrieved due to an internal service error.", typeof(ProblemDetails))]
[Authorize]
internal static Task<IResult> RetrieveSpecificInvoiceAsync(IInvoiceProcessingService invoiceProcessingService, IHttpContextAccessor httpContext, Guid id, ClaimsPrincipal principal)

Parameters

invoiceProcessingService IInvoiceProcessingService
httpContext IHttpContextAccessor
id Guid
principal ClaimsPrincipal

Returns

Task<IResult>

RetrieveSpecificMerchantAsync(IInvoiceProcessingService, IHttpContextAccessor, Guid, Guid, ClaimsPrincipal)

Retrieves a specific merchant.

[SwaggerOperation(null, null, Summary = "Retrieves a specific merchant from the system.", Description = "Retrieves a specific merchant from the Merchant Management System. ", OperationId = "RetrieveSpecificMerchantAsync", Tags = new string[] { "Invoices Management System v1.0.0-alphaRC1" })]
[SwaggerResponse(200, "The merchant was retrieved successfully from the system.", typeof(Merchant))]
[SwaggerResponse(400, "The merchant identifier is not valid. Please input a valid identifier.", typeof(ValidationProblemDetails))]
[SwaggerResponse(401, "You are not authorized to access this merchant.", typeof(ProblemDetails))]
[SwaggerResponse(403, "You are not authenticated. Please authenticate with a valid account.", typeof(ProblemDetails))]
[SwaggerResponse(404, "The merchant could not be retrieved due to the merchant not being found.", typeof(ProblemDetails))]
[SwaggerResponse(429, "You have made too many requests, slow down a little.", typeof(ProblemDetails))]
[SwaggerResponse(500, "The merchant could not be retrieved due to an internal service error.", typeof(ProblemDetails))]
[Authorize]
internal static Task<IResult> RetrieveSpecificMerchantAsync(IInvoiceProcessingService invoiceProcessingService, IHttpContextAccessor httpContext, Guid id, Guid parentCompanyId, ClaimsPrincipal principal)

Parameters

invoiceProcessingService IInvoiceProcessingService
httpContext IHttpContextAccessor
id Guid
parentCompanyId Guid
principal ClaimsPrincipal

Returns

Task<IResult>

RetrieveUserIdentifierFromPrincipal(ClaimsPrincipal)

Helper method to retrieve the user identifier from the user principal.

private static Guid RetrieveUserIdentifierFromPrincipal(ClaimsPrincipal principal)

Parameters

principal ClaimsPrincipal

Returns

Guid

UpdateMerchantInInvoiceAsync(IInvoiceProcessingService, IHttpContextAccessor, Guid, Merchant, ClaimsPrincipal)

Updates the merchant in an invoice.

[SwaggerOperation(null, null, Summary = "Updates the merchant in an invoice in the system.", Description = "Updates the merchant in an invoice in the Invoice Management System. If the invoice identifier passed to the route is valid, the server will update the merchant in the invoice, given that the user is allowed to update merchants in this invoice.", OperationId = "UpdateMerchantInInvoiceAsync", Tags = new string[] { "Invoices Management System v1.0.0-alphaRC1" })]
[SwaggerResponse(202, "The merchant was updated in the invoice successfully.", typeof(Invoice))]
[SwaggerResponse(400, "The merchant information is not valid (please respect the merchant schema).", typeof(ValidationProblemDetails))]
[SwaggerResponse(401, "You are not authorized to perform this operation.", typeof(ProblemDetails))]
[SwaggerResponse(404, "The merchant could not be updated in the invoice due to the invoice not being found.", typeof(ProblemDetails))]
[SwaggerResponse(409, "The merchant could not be updated in the invoice due to a conflict (the merchant is not in the invoice).", typeof(ProblemDetails))]
[SwaggerResponse(413, "The merchant could not be updated in the invoice due to the payload being too large (keep the request under 1MB).", typeof(ProblemDetails))]
[SwaggerResponse(429, "You have made too many requests, slow down a little.", typeof(ProblemDetails))]
[SwaggerResponse(500, "The merchant could not be updated due to an internal service error", typeof(ProblemDetails))]
[Authorize]
internal static Task<IResult> UpdateMerchantInInvoiceAsync(IInvoiceProcessingService invoiceProcessingService, IHttpContextAccessor httpContext, Guid id, Merchant merchant, ClaimsPrincipal principal)

Parameters

invoiceProcessingService IInvoiceProcessingService
httpContext IHttpContextAccessor
id Guid
merchant Merchant
principal ClaimsPrincipal

Returns

Task<IResult>

UpdateProductInInvoiceAsync(IInvoiceProcessingService, IHttpContextAccessor, Guid, string, Product, ClaimsPrincipal)

Updates a product in a specific invoice.

[SwaggerOperation(null, null, Summary = "Updates a product in a specific invoice in the system.", Description = "Updates a product in a specific invoice in the Invoice Management System. If the invoice identifier passed to the route is valid, the server will update the product in the invoice, given that the user is allowed to update products in this invoice.", OperationId = "UpdateProductInInvoiceAsync", Tags = new string[] { "Invoices Management System v1.0.0-alphaRC1" })]
[SwaggerResponse(202, "The product was updated in the invoice successfully.", typeof(Invoice))]
[SwaggerResponse(400, "The product information is not valid (please respect the product schema).", typeof(ValidationProblemDetails))]
[SwaggerResponse(401, "You are not authorized to perform this operation.", typeof(ProblemDetails))]
[SwaggerResponse(404, "The product could not be updated in the invoice due to the invoice not being found.", typeof(ProblemDetails))]
[SwaggerResponse(409, "The product could not be updated in the invoice due to a conflict (the product is not in the invoice).", typeof(ProblemDetails))]
[SwaggerResponse(413, "The product could not be updated in the invoice due to the payload being too large (keep the request under 1MB).", typeof(ProblemDetails))]
[SwaggerResponse(429, "You have made too many requests, slow down a little.", typeof(ProblemDetails))]
[SwaggerResponse(500, "The product could not be updated due to an internal service error", typeof(ProblemDetails))]
[Authorize]
internal static Task<IResult> UpdateProductInInvoiceAsync(IInvoiceProcessingService invoiceProcessingService, IHttpContextAccessor httpContext, Guid id, string productName, Product productInformation, ClaimsPrincipal principal)

Parameters

invoiceProcessingService IInvoiceProcessingService
httpContext IHttpContextAccessor
id Guid
productName string
productInformation Product
principal ClaimsPrincipal

Returns

Task<IResult>

UpdateSpecificInvoiceAsync(IInvoiceProcessingService, IHttpContextAccessor, Guid, Invoice, ClaimsPrincipal)

Updates a specific invoice.

[SwaggerOperation(null, null, Summary = "Updates a specific invoice in the system.", Description = "This route will allow you to updates a specific invoice from the Invoice Managemnet System.", OperationId = "UpdateSpecificInvoiceAsync", Tags = new string[] { "Invoices Management System v1.0.0-alphaRC1" })]
[SwaggerResponse(202, "The invoice was updated successfully.", typeof(Invoice))]
[SwaggerResponse(400, "The invoice information is not valid (please respect the invoice schema).", typeof(ValidationProblemDetails))]
[SwaggerResponse(401, "You are not authorized to perform this operation.", typeof(ProblemDetails))]
[SwaggerResponse(403, "You are not authenticated. Please authenticate before hitting this endpoint.", typeof(ProblemDetails))]
[SwaggerResponse(404, "The invoice could not be updated due to the invoice not being found.", typeof(ProblemDetails))]
[SwaggerResponse(429, "You have made too many requests, slow down a little.", typeof(ProblemDetails))]
[SwaggerResponse(500, "The invoice could not be updated due to an internal service error.", typeof(ProblemDetails))]
[Authorize]
internal static Task<IResult> UpdateSpecificInvoiceAsync(IInvoiceProcessingService invoiceProcessingService, IHttpContextAccessor httpContext, Guid id, Invoice invoicePayload, ClaimsPrincipal principal)

Parameters

invoiceProcessingService IInvoiceProcessingService
httpContext IHttpContextAccessor
id Guid
invoicePayload Invoice
principal ClaimsPrincipal

Returns

Task<IResult>

UpdateSpecificMerchantAsync(IInvoiceProcessingService, IHttpContextAccessor, Guid, Merchant, ClaimsPrincipal)

Updates a specific merchant.

[SwaggerOperation(null, null, Summary = "Updates a specific merchant in the system.", Description = "Updates a specific merchant in the Merchant Management System. ", OperationId = "UpdateSpecificMerchantAsync", Tags = new string[] { "Invoices Management System v1.0.0-alphaRC1" })]
[SwaggerResponse(202, "The merchant was updated successfully.", typeof(Merchant))]
[SwaggerResponse(400, "The merchant information is not valid (please respect the merchant schema).", typeof(ValidationProblemDetails))]
[SwaggerResponse(401, "You are not authorized to perform this operation.", typeof(ProblemDetails))]
[SwaggerResponse(403, "You are not authenticated. Please authenticate before hitting this endpoint.", typeof(ProblemDetails))]
[SwaggerResponse(404, "The merchant could not be updated due to the merchant not being found.", typeof(ProblemDetails))]
[SwaggerResponse(429, "You have made too many requests, slow down a little.", typeof(ProblemDetails))]
[SwaggerResponse(500, "The merchant could not be updated due to an internal service error.", typeof(ProblemDetails))]
[Authorize]
internal static Task<IResult> UpdateSpecificMerchantAsync(IInvoiceProcessingService invoiceProcessingService, IHttpContextAccessor httpContext, Guid id, Merchant merchantPayload, ClaimsPrincipal principal)

Parameters

invoiceProcessingService IInvoiceProcessingService
httpContext IHttpContextAccessor
id Guid
merchantPayload Merchant
principal ClaimsPrincipal

Returns

Task<IResult>