From cddb6463cdd734b1d9d22de92d6c2688e15d0788 Mon Sep 17 00:00:00 2001 From: Robert Ivanc Date: Wed, 25 Dec 2019 21:12:23 +0100 Subject: [PATCH] getpartners --- CebelcaAPISharp.cs | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/CebelcaAPISharp.cs b/CebelcaAPISharp.cs index 32ef370..698836a 100644 --- a/CebelcaAPISharp.cs +++ b/CebelcaAPISharp.cs @@ -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 = ""; @@ -55,6 +60,25 @@ namespace CebelcaAPI } + public async Task> GetPartners() + { + var values = new Dictionary(); + 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(); + //var l = new List(); + var l = json[0].Select(x => new CebelcaPartner + { + Id = x["id"].Value(), + Name = x["name"].Value() + }).ToList(); + return l; + } + public async Task SendInvoiceByEmail(string invoiceId, string to, string subject, string content) { Thread.CurrentThread.CurrentCulture = new CultureInfo("sl-SI");