Skip to main content

ServiceApi Usage

Required Libraries

using System; using System.Collections.Generic; using Bimser.CSP.FormControls.Common; using Bimser.CSP.FormControls.Events; using Bimser.Synergy.ServiceAPI; using Bimser.Synergy.ServiceAPI.Models.Authentication; using Bimser.CSP.DataSource.Api.Models; using Newtonsoft.Json;

Codes

protected LoginWithTokenAuthenticationParameters Credentials { Get { return new LoginWithTokenAuthenticationParameters { EncryptedData = Session.EncryptedData, Language = Session.Language, Token = Session.Token }; } } internal static HttpClientOptions _httpClientOptions; internal static string WebInterfaceUrl { Get { if (_httpClientOptions == null) { string envVar = Environment.GetEnvironmentVariable("HTTP_CLIENT_OPTIONS"); _httpClientOptions = JsonConvert.DeserializeObject<HttpClientOptions>(envVar); } return _httpClientOptions.WebInterfaceUrl; } }

private ServiceAPI _serviceApi; protected ServiceAPI ServiceApi { Get { if(_serviceApi == null) { _serviceApi = new ServiceAPI(Credentials,WebInterfaceUrl); }

return _serviceApi; } }

Example Usage

With the following code, as an example, a form can be created with ServiceApi.

ServiceApi.FormManager.Create("projectName","formName",123);

(Parameters: project name, form name, documentId)