init
This commit is contained in:
commit
e124a47765
19374 changed files with 9806149 additions and 0 deletions
42
Kreta.Client/Leltar/LeltarClient.cs
Normal file
42
Kreta.Client/Leltar/LeltarClient.cs
Normal file
|
@ -0,0 +1,42 @@
|
|||
using System;
|
||||
using Kreta.Client.ClientBase;
|
||||
using Kreta.Client.Leltar.Configuration;
|
||||
using Kreta.Client.Leltar.Request;
|
||||
using Newtonsoft.Json;
|
||||
using RestSharp;
|
||||
using RestSharp.Authenticators;
|
||||
|
||||
namespace Kreta.Client.Leltar
|
||||
{
|
||||
internal class LeltarClient : RestSharpClientBase, ILeltarClient
|
||||
{
|
||||
private readonly ILeltarClientConfiguration leltarClientConfiguration;
|
||||
|
||||
public LeltarClient(ILeltarClientConfiguration leltarClientConfiguration)
|
||||
{
|
||||
this.leltarClientConfiguration = leltarClientConfiguration ?? throw new ArgumentNullException(nameof(leltarClientConfiguration));
|
||||
}
|
||||
|
||||
public bool KretaUserSync(KretaUserSyncRequest request)
|
||||
{
|
||||
var restClient = new RestClient(leltarClientConfiguration.BaseUrl)
|
||||
{
|
||||
Authenticator = new HttpBasicAuthenticator(leltarClientConfiguration.Username, leltarClientConfiguration.Password)
|
||||
};
|
||||
|
||||
var relativeUri = "kreta-user-sync/action/KretaUserSyncAction";
|
||||
var restRequest = new RestRequest(relativeUri, Method.POST);
|
||||
|
||||
var parameter = JsonConvert.SerializeObject(request);
|
||||
restRequest.AddParameter("application/json;charset=utf-8", parameter, ParameterType.RequestBody);
|
||||
|
||||
var restResponse = restClient.Execute(restRequest);
|
||||
if (restResponse.StatusCode == System.Net.HttpStatusCode.OK)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue