{"id":4496,"date":"2021-01-27T11:05:58","date_gmt":"2021-01-27T10:05:58","guid":{"rendered":"https:\/\/solidt.eu\/site\/?p=4496"},"modified":"2022-07-25T08:31:52","modified_gmt":"2022-07-25T07:31:52","slug":"c-uniconta-code","status":"publish","type":"post","link":"https:\/\/solidt.eu\/site\/c-uniconta-code\/","title":{"rendered":"C# Uniconta Code"},"content":{"rendered":"\n<div style=\"height: 250px; position:relative; margin-bottom: 50px;\" class=\"wp-block-simple-code-block-ace\"><pre class=\"wp-block-simple-code-block-ace\" style=\"position:absolute;top:0;right:0;bottom:0;left:0\" data-mode=\"csharp\" data-theme=\"monokai\" data-fontsize=\"14\" data-lines=\"Infinity\" data-showlines=\"true\" data-copy=\"false\">public class UnicontaConnectionHelper \n{\n    public static async Task&lt;CrudAPI> GetApi (string username, string password, Guid apiKey, int companyId) {\n        var connection = new UnicontaConnection (APITarget.Live);\n        var session = new Session (connection);\n        var result = await session.LoginAsync (username, password, LoginType.API, apiKey);\n        if (result != ErrorCodes.Succes) {\n            throw new Exception (result.ToString ());\n        }\n        var company = await session.GetCompany (companyId);\n        var crudApi = new CrudAPI (session, company);\n        crudApi.ForcePrimarySQL = true;\n        return crudApi;\n    }\n    \n    public async Task&lt;CrudAPI> GetCrudAPI () {\n        string username = \"user\";\n        string password = \"pwd\";\n        int companyId = 48745;\n        Guid apiKey = Guid.Parse (\"21245d5e-22f8-4468-a198-e6b0eb5eff92\");\n        return await UnicontaConnectionHelper.GetApi (username, password, apiKey, companyId);\n    }\n}<\/pre><\/div>\n","protected":false},"excerpt":{"rendered":"","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"inline_featured_image":false,"footnotes":""},"categories":[6,4,1],"tags":[],"class_list":["post-4496","post","type-post","status-publish","format-standard","hentry","category-dotnet","category-programming","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/solidt.eu\/site\/wp-json\/wp\/v2\/posts\/4496","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/solidt.eu\/site\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/solidt.eu\/site\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/solidt.eu\/site\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/solidt.eu\/site\/wp-json\/wp\/v2\/comments?post=4496"}],"version-history":[{"count":2,"href":"https:\/\/solidt.eu\/site\/wp-json\/wp\/v2\/posts\/4496\/revisions"}],"predecessor-version":[{"id":5616,"href":"https:\/\/solidt.eu\/site\/wp-json\/wp\/v2\/posts\/4496\/revisions\/5616"}],"wp:attachment":[{"href":"https:\/\/solidt.eu\/site\/wp-json\/wp\/v2\/media?parent=4496"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/solidt.eu\/site\/wp-json\/wp\/v2\/categories?post=4496"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/solidt.eu\/site\/wp-json\/wp\/v2\/tags?post=4496"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}