cc nasazeni
This commit is contained in:
@@ -0,0 +1,29 @@
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Idoklad.Services;
|
||||
|
||||
namespace Idoklad.Controllers;
|
||||
|
||||
/// <summary>
|
||||
/// Account agenda: the current agenda (company) and current user. Requires iDoklad credentials
|
||||
/// (headers or environment defaults).
|
||||
/// </summary>
|
||||
[ApiController]
|
||||
[Route("account")]
|
||||
[Produces("application/json")]
|
||||
[Tags("Account")]
|
||||
public sealed class AccountController : ControllerBase
|
||||
{
|
||||
private readonly AccountService _service;
|
||||
|
||||
public AccountController(AccountService service) => _service = service;
|
||||
|
||||
/// <summary>Get information about the current agenda (company).</summary>
|
||||
[HttpGet("agenda")]
|
||||
public async Task<IActionResult> Agenda(CancellationToken ct)
|
||||
=> Ok(await _service.CurrentAgendaAsync(ct));
|
||||
|
||||
/// <summary>Get information about the current user.</summary>
|
||||
[HttpGet("user")]
|
||||
public async Task<IActionResult> CurrentUser(CancellationToken ct)
|
||||
=> Ok(await _service.CurrentUserAsync(ct));
|
||||
}
|
||||
@@ -0,0 +1,53 @@
|
||||
using IdokladSdk.Models.Contact;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Idoklad.Services;
|
||||
|
||||
namespace Idoklad.Controllers;
|
||||
|
||||
/// <summary>
|
||||
/// Contacts (customers/suppliers) agenda.
|
||||
///
|
||||
/// All endpoints require iDoklad credentials. Provide them as request headers
|
||||
/// (<c>X-ClientId</c>, <c>X-ClientSecret</c>, <c>X-ApplicationId</c>) or rely on the service
|
||||
/// environment defaults. See the Swagger description for details.
|
||||
/// </summary>
|
||||
[ApiController]
|
||||
[Route("contacts")]
|
||||
[Produces("application/json")]
|
||||
[Tags("Contacts")]
|
||||
public sealed class ContactsController : ControllerBase
|
||||
{
|
||||
private readonly ContactsService _service;
|
||||
|
||||
public ContactsController(ContactsService service) => _service = service;
|
||||
|
||||
/// <summary>List contacts (paged).</summary>
|
||||
[HttpGet]
|
||||
public async Task<IActionResult> List([FromQuery] int page = 1, [FromQuery] int pageSize = 20, CancellationToken ct = default)
|
||||
=> Ok(await _service.ListAsync(page, pageSize, ct));
|
||||
|
||||
/// <summary>Get a contact detail by id.</summary>
|
||||
[HttpGet("{id:int}")]
|
||||
public async Task<IActionResult> Detail(int id, CancellationToken ct)
|
||||
=> Ok(await _service.DetailAsync(id, ct));
|
||||
|
||||
/// <summary>Get a pre-filled default contact model for creating a new contact.</summary>
|
||||
[HttpGet("default")]
|
||||
public async Task<IActionResult> Default(CancellationToken ct)
|
||||
=> Ok(await _service.DefaultAsync(ct));
|
||||
|
||||
/// <summary>Create a new contact.</summary>
|
||||
[HttpPost]
|
||||
public async Task<IActionResult> Create([FromBody] ContactPostModel model, CancellationToken ct)
|
||||
=> Ok(await _service.CreateAsync(model, ct));
|
||||
|
||||
/// <summary>Update an existing contact (the model id identifies the contact).</summary>
|
||||
[HttpPatch]
|
||||
public async Task<IActionResult> Update([FromBody] ContactPatchModel model, CancellationToken ct)
|
||||
=> Ok(await _service.UpdateAsync(model, ct));
|
||||
|
||||
/// <summary>Delete a contact by id.</summary>
|
||||
[HttpDelete("{id:int}")]
|
||||
public async Task<IActionResult> Delete(int id, CancellationToken ct)
|
||||
=> Ok(await _service.DeleteAsync(id, ct));
|
||||
}
|
||||
@@ -0,0 +1,55 @@
|
||||
using IdokladSdk.Models.IssuedInvoice;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Idoklad.Services;
|
||||
|
||||
namespace Idoklad.Controllers;
|
||||
|
||||
/// <summary>
|
||||
/// Issued (outgoing) invoices agenda. Requires iDoklad credentials (headers or environment
|
||||
/// defaults).
|
||||
/// </summary>
|
||||
[ApiController]
|
||||
[Route("issued-invoices")]
|
||||
[Produces("application/json")]
|
||||
[Tags("IssuedInvoices")]
|
||||
public sealed class IssuedInvoicesController : ControllerBase
|
||||
{
|
||||
private readonly IssuedInvoicesService _service;
|
||||
|
||||
public IssuedInvoicesController(IssuedInvoicesService service) => _service = service;
|
||||
|
||||
/// <summary>List issued invoices (paged).</summary>
|
||||
[HttpGet]
|
||||
public async Task<IActionResult> List([FromQuery] int page = 1, [FromQuery] int pageSize = 20, CancellationToken ct = default)
|
||||
=> Ok(await _service.ListAsync(page, pageSize, ct));
|
||||
|
||||
/// <summary>Get an issued invoice detail by id.</summary>
|
||||
[HttpGet("{id:int}")]
|
||||
public async Task<IActionResult> Detail(int id, CancellationToken ct)
|
||||
=> Ok(await _service.DetailAsync(id, ct));
|
||||
|
||||
/// <summary>Get a pre-filled default model for creating a new issued invoice.</summary>
|
||||
[HttpGet("default")]
|
||||
public async Task<IActionResult> Default(CancellationToken ct)
|
||||
=> Ok(await _service.DefaultAsync(ct));
|
||||
|
||||
/// <summary>Create a new issued invoice.</summary>
|
||||
[HttpPost]
|
||||
public async Task<IActionResult> Create([FromBody] IssuedInvoicePostModel model, CancellationToken ct)
|
||||
=> Ok(await _service.CreateAsync(model, ct));
|
||||
|
||||
/// <summary>Update an existing issued invoice (the model id identifies the invoice).</summary>
|
||||
[HttpPatch]
|
||||
public async Task<IActionResult> Update([FromBody] IssuedInvoicePatchModel model, CancellationToken ct)
|
||||
=> Ok(await _service.UpdateAsync(model, ct));
|
||||
|
||||
/// <summary>Create a copy (draft) of an existing issued invoice.</summary>
|
||||
[HttpPost("{id:int}/copy")]
|
||||
public async Task<IActionResult> Copy(int id, CancellationToken ct)
|
||||
=> Ok(await _service.CopyAsync(id, ct));
|
||||
|
||||
/// <summary>Delete an issued invoice by id.</summary>
|
||||
[HttpDelete("{id:int}")]
|
||||
public async Task<IActionResult> Delete(int id, CancellationToken ct)
|
||||
=> Ok(await _service.DeleteAsync(id, ct));
|
||||
}
|
||||
@@ -0,0 +1,45 @@
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Idoklad.Configuration;
|
||||
|
||||
namespace Idoklad.Controllers;
|
||||
|
||||
/// <summary>Service metadata endpoints. These do not require iDoklad credentials.</summary>
|
||||
[ApiController]
|
||||
[Produces("application/json")]
|
||||
[Tags("Meta")]
|
||||
public sealed class MetaController : ControllerBase
|
||||
{
|
||||
private readonly IdokladSettings _settings;
|
||||
|
||||
public MetaController(IdokladSettings settings) => _settings = settings;
|
||||
|
||||
/// <summary>Liveness probe.</summary>
|
||||
[HttpGet("/health")]
|
||||
public IActionResult Health() => Ok(new { status = "ok" });
|
||||
|
||||
/// <summary>Service name, version and language.</summary>
|
||||
[HttpGet("/version")]
|
||||
public IActionResult Version() => Ok(new
|
||||
{
|
||||
app = _settings.AppName,
|
||||
version = _settings.AppVersion,
|
||||
language = "dotnet",
|
||||
sdk = "IdokladSdk 5.3.0",
|
||||
root_path = _settings.RootPath,
|
||||
});
|
||||
|
||||
/// <summary>
|
||||
/// Reports whether the service has default iDoklad credentials configured through
|
||||
/// environment variables. Per-request callers can always override them with headers.
|
||||
/// </summary>
|
||||
[HttpGet("/status")]
|
||||
public IActionResult Status() => Ok(new
|
||||
{
|
||||
default_credentials_configured = _settings.HasDefaultCredentials,
|
||||
client_id = !string.IsNullOrWhiteSpace(_settings.ClientId),
|
||||
client_secret = !string.IsNullOrWhiteSpace(_settings.ClientSecret),
|
||||
application_id = !string.IsNullOrWhiteSpace(_settings.ApplicationId),
|
||||
custom_urls = _settings.HasCustomUrls,
|
||||
idoklad_language = _settings.Language.ToString(),
|
||||
});
|
||||
}
|
||||
@@ -0,0 +1,50 @@
|
||||
using IdokladSdk.Models.ReceivedInvoice;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Idoklad.Services;
|
||||
|
||||
namespace Idoklad.Controllers;
|
||||
|
||||
/// <summary>
|
||||
/// Received (incoming) invoices agenda. Requires iDoklad credentials (headers or environment
|
||||
/// defaults).
|
||||
/// </summary>
|
||||
[ApiController]
|
||||
[Route("received-invoices")]
|
||||
[Produces("application/json")]
|
||||
[Tags("ReceivedInvoices")]
|
||||
public sealed class ReceivedInvoicesController : ControllerBase
|
||||
{
|
||||
private readonly ReceivedInvoicesService _service;
|
||||
|
||||
public ReceivedInvoicesController(ReceivedInvoicesService service) => _service = service;
|
||||
|
||||
/// <summary>List received invoices (paged).</summary>
|
||||
[HttpGet]
|
||||
public async Task<IActionResult> List([FromQuery] int page = 1, [FromQuery] int pageSize = 20, CancellationToken ct = default)
|
||||
=> Ok(await _service.ListAsync(page, pageSize, ct));
|
||||
|
||||
/// <summary>Get a received invoice detail by id.</summary>
|
||||
[HttpGet("{id:int}")]
|
||||
public async Task<IActionResult> Detail(int id, CancellationToken ct)
|
||||
=> Ok(await _service.DetailAsync(id, ct));
|
||||
|
||||
/// <summary>Get a pre-filled default model for creating a new received invoice.</summary>
|
||||
[HttpGet("default")]
|
||||
public async Task<IActionResult> Default(CancellationToken ct)
|
||||
=> Ok(await _service.DefaultAsync(ct));
|
||||
|
||||
/// <summary>Create a new received invoice.</summary>
|
||||
[HttpPost]
|
||||
public async Task<IActionResult> Create([FromBody] ReceivedInvoicePostModel model, CancellationToken ct)
|
||||
=> Ok(await _service.CreateAsync(model, ct));
|
||||
|
||||
/// <summary>Update an existing received invoice (the model id identifies the invoice).</summary>
|
||||
[HttpPatch]
|
||||
public async Task<IActionResult> Update([FromBody] ReceivedInvoicePatchModel model, CancellationToken ct)
|
||||
=> Ok(await _service.UpdateAsync(model, ct));
|
||||
|
||||
/// <summary>Delete a received invoice by id.</summary>
|
||||
[HttpDelete("{id:int}")]
|
||||
public async Task<IActionResult> Delete(int id, CancellationToken ct)
|
||||
=> Ok(await _service.DeleteAsync(id, ct));
|
||||
}
|
||||
@@ -0,0 +1,66 @@
|
||||
using IdokladSdk.Models.BankAccount;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Idoklad.Services;
|
||||
|
||||
namespace Idoklad.Controllers;
|
||||
|
||||
/// <summary>
|
||||
/// Supporting registers: bank accounts, VAT rates and numeric sequences. Requires iDoklad
|
||||
/// credentials (headers or environment defaults).
|
||||
/// </summary>
|
||||
[ApiController]
|
||||
[Route("registers")]
|
||||
[Produces("application/json")]
|
||||
[Tags("Registers")]
|
||||
public sealed class RegistersController : ControllerBase
|
||||
{
|
||||
private readonly RegistersService _service;
|
||||
|
||||
public RegistersController(RegistersService service) => _service = service;
|
||||
|
||||
// ---- Bank accounts ----
|
||||
|
||||
/// <summary>List bank accounts (paged).</summary>
|
||||
[HttpGet("bank-accounts")]
|
||||
public async Task<IActionResult> ListBankAccounts([FromQuery] int page = 1, [FromQuery] int pageSize = 20, CancellationToken ct = default)
|
||||
=> Ok(await _service.ListBankAccountsAsync(page, pageSize, ct));
|
||||
|
||||
/// <summary>Get a bank account detail by id.</summary>
|
||||
[HttpGet("bank-accounts/{id:int}")]
|
||||
public async Task<IActionResult> BankAccountDetail(int id, CancellationToken ct)
|
||||
=> Ok(await _service.BankAccountDetailAsync(id, ct));
|
||||
|
||||
/// <summary>Create a new bank account.</summary>
|
||||
[HttpPost("bank-accounts")]
|
||||
public async Task<IActionResult> CreateBankAccount([FromBody] BankAccountPostModel model, CancellationToken ct)
|
||||
=> Ok(await _service.CreateBankAccountAsync(model, ct));
|
||||
|
||||
/// <summary>Update an existing bank account (the model id identifies the account).</summary>
|
||||
[HttpPatch("bank-accounts")]
|
||||
public async Task<IActionResult> UpdateBankAccount([FromBody] BankAccountPatchModel model, CancellationToken ct)
|
||||
=> Ok(await _service.UpdateBankAccountAsync(model, ct));
|
||||
|
||||
/// <summary>Delete a bank account by id.</summary>
|
||||
[HttpDelete("bank-accounts/{id:int}")]
|
||||
public async Task<IActionResult> DeleteBankAccount(int id, CancellationToken ct)
|
||||
=> Ok(await _service.DeleteBankAccountAsync(id, ct));
|
||||
|
||||
// ---- VAT rates (read-only) ----
|
||||
|
||||
/// <summary>List VAT rates (paged).</summary>
|
||||
[HttpGet("vat-rates")]
|
||||
public async Task<IActionResult> ListVatRates([FromQuery] int page = 1, [FromQuery] int pageSize = 20, CancellationToken ct = default)
|
||||
=> Ok(await _service.ListVatRatesAsync(page, pageSize, ct));
|
||||
|
||||
/// <summary>Get a VAT rate detail by id.</summary>
|
||||
[HttpGet("vat-rates/{id:int}")]
|
||||
public async Task<IActionResult> VatRateDetail(int id, CancellationToken ct)
|
||||
=> Ok(await _service.VatRateDetailAsync(id, ct));
|
||||
|
||||
// ---- Numeric sequences (read-only) ----
|
||||
|
||||
/// <summary>List numeric (document) sequences (paged).</summary>
|
||||
[HttpGet("numeric-sequences")]
|
||||
public async Task<IActionResult> ListNumericSequences([FromQuery] int page = 1, [FromQuery] int pageSize = 20, CancellationToken ct = default)
|
||||
=> Ok(await _service.ListNumericSequencesAsync(page, pageSize, ct));
|
||||
}
|
||||
Reference in New Issue
Block a user