Compare commits
6 Commits
4d1c0e75e0
...
e26333ce21
| Author | SHA1 | Date | |
|---|---|---|---|
| e26333ce21 | |||
| fdbdd519cf | |||
| cddb6463cd | |||
| b038c239fd | |||
| f35effb36d | |||
| 052c559a49 |
17
.github/workflows/dotnetcore.yml
vendored
Normal file
17
.github/workflows/dotnetcore.yml
vendored
Normal file
@@ -0,0 +1,17 @@
|
||||
name: .NET Core
|
||||
|
||||
on: [push]
|
||||
|
||||
jobs:
|
||||
build:
|
||||
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v1
|
||||
- name: Setup .NET Core
|
||||
uses: actions/setup-dotnet@v1
|
||||
with:
|
||||
dotnet-version: 2.2.108
|
||||
- name: Build with dotnet
|
||||
run: dotnet build --configuration Release
|
||||
@@ -10,6 +10,11 @@ using System.Threading.Tasks;
|
||||
|
||||
namespace CebelcaAPI
|
||||
{
|
||||
public class CebelcaPartner
|
||||
{
|
||||
public string Id { get; set; }
|
||||
public string Name { get; set; }
|
||||
}
|
||||
public class CebelcaAPISharp
|
||||
{
|
||||
private string _key = "";
|
||||
@@ -34,7 +39,7 @@ namespace CebelcaAPI
|
||||
}
|
||||
}
|
||||
|
||||
public async Task<string> AddInvoiceHead(string partnerId, string idDocumentExt, DateTime dateSent, DateTime dateServed, DateTime dateToPay)
|
||||
public async Task<string> AddInvoiceHead(string partnerId, string idDocumentExt, DateTime dateSent, DateTime dateServed, DateTime dateToPay, bool paid = false)
|
||||
{
|
||||
Thread.CurrentThread.CurrentCulture = new CultureInfo("sl-SI");
|
||||
var values = new Dictionary<string, string>
|
||||
@@ -45,6 +50,11 @@ namespace CebelcaAPI
|
||||
{ "id_partner", partnerId },
|
||||
{ "id_document_ext", idDocumentExt }
|
||||
};
|
||||
if (paid)
|
||||
{
|
||||
values.Add("payment", "paid");
|
||||
values.Add("payment_act", "1");
|
||||
}
|
||||
var ret = await APICall("invoice-sent", "insert-smart-2", values);
|
||||
var json = JArray.Parse(ret);
|
||||
var retname = (json[0][0] as JObject).Properties().First().Name;
|
||||
@@ -55,6 +65,25 @@ namespace CebelcaAPI
|
||||
|
||||
}
|
||||
|
||||
public async Task<IEnumerable<CebelcaPartner>> GetPartners()
|
||||
{
|
||||
var values = new Dictionary<string, string>();
|
||||
var ret = await APICall("partner", "select-all", values);
|
||||
|
||||
var json = JArray.Parse(ret);
|
||||
var retname = (json[0][0] as JObject).Properties().First().Name;
|
||||
if (retname != "id")
|
||||
throw new Exception("Error from api: " + ret);
|
||||
var id = json[0][0]["id"].Value<string>();
|
||||
//var l = new List<CebelcaPartner>();
|
||||
var l = json[0].Select(x => new CebelcaPartner
|
||||
{
|
||||
Id = x["id"].Value<string>(),
|
||||
Name = x["name"].Value<string>()
|
||||
}).ToList();
|
||||
return l;
|
||||
}
|
||||
|
||||
public async Task SendInvoiceByEmail(string invoiceId, string to, string subject, string content)
|
||||
{
|
||||
Thread.CurrentThread.CurrentCulture = new CultureInfo("sl-SI");
|
||||
@@ -164,5 +193,30 @@ namespace CebelcaAPI
|
||||
|
||||
}
|
||||
|
||||
public async Task<string> AddPartner(string name, string email, string street, string city,
|
||||
string postal)
|
||||
{
|
||||
Thread.CurrentThread.CurrentCulture = new CultureInfo("sl-SI");
|
||||
var values = new Dictionary<string, string>
|
||||
{
|
||||
|
||||
{ "name", name },
|
||||
{ "email", email },
|
||||
{ "street", street },
|
||||
{ "city", city },
|
||||
{ "postal", postal },
|
||||
|
||||
|
||||
};
|
||||
var ret = await APICall("partner", "assure", values);
|
||||
var json = JArray.Parse(ret);
|
||||
var retname = (json[0][0] as JObject).Properties().First().Name;
|
||||
if (retname != "id")
|
||||
throw new Exception("Error from api: " + ret);
|
||||
var id = json[0][0]["id"].Value<string>();
|
||||
return id;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,2 +1,6 @@
|
||||
# CebelcaAPISharp
|
||||
|
||||
A simple library for Cebelca.biz (InvoiceFox) API.
|
||||
Currently supports creating invoice, adding items to it, issuing invoice, fiscalization and sending the invoice by email.
|
||||
|
||||
Not much error handling at the moment, not production ready, but feel free to improve :)
|
||||
|
||||
Reference in New Issue
Block a user