init
This commit is contained in:
commit
e124a47765
19374 changed files with 9806149 additions and 0 deletions
|
@ -0,0 +1,11 @@
|
|||
namespace Kreta.Client.Leltar.Configuration
|
||||
{
|
||||
public interface ILeltarClientConfiguration
|
||||
{
|
||||
string BaseUrl { get; }
|
||||
|
||||
string Username { get; }
|
||||
|
||||
string Password { get; }
|
||||
}
|
||||
}
|
|
@ -0,0 +1,16 @@
|
|||
using System.Configuration;
|
||||
|
||||
namespace Kreta.Client.Leltar.Configuration
|
||||
{
|
||||
public class LeltarClientConfiguration : ConfigurationSection, ILeltarClientConfiguration
|
||||
{
|
||||
[ConfigurationProperty(nameof(BaseUrl), IsRequired = true)]
|
||||
public string BaseUrl => (string)base[nameof(BaseUrl)];
|
||||
|
||||
[ConfigurationProperty(nameof(Username), IsRequired = true)]
|
||||
public string Username => (string)base[nameof(Username)];
|
||||
|
||||
[ConfigurationProperty(nameof(Password), IsRequired = true)]
|
||||
public string Password => (string)base[nameof(Password)];
|
||||
}
|
||||
}
|
9
Kreta.Client/Leltar/ILeltarClient.cs
Normal file
9
Kreta.Client/Leltar/ILeltarClient.cs
Normal file
|
@ -0,0 +1,9 @@
|
|||
using Kreta.Client.Leltar.Request;
|
||||
|
||||
namespace Kreta.Client.Leltar
|
||||
{
|
||||
public interface ILeltarClient
|
||||
{
|
||||
bool KretaUserSync(KretaUserSyncRequest request);
|
||||
}
|
||||
}
|
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;
|
||||
}
|
||||
}
|
||||
}
|
43
Kreta.Client/Leltar/Request/KretaUserSyncRequest.cs
Normal file
43
Kreta.Client/Leltar/Request/KretaUserSyncRequest.cs
Normal file
|
@ -0,0 +1,43 @@
|
|||
using Newtonsoft.Json;
|
||||
|
||||
namespace Kreta.Client.Leltar.Request
|
||||
{
|
||||
public class KretaUserSyncRequest
|
||||
{
|
||||
[JsonProperty(PropertyName = "user_id")]
|
||||
public string IdpEgyediAzonosito { get; set; }
|
||||
|
||||
[JsonProperty(PropertyName = "access_level")]
|
||||
public string AccessLevel => "INSTITUTE";
|
||||
|
||||
[JsonProperty(PropertyName = "roles")]
|
||||
public string[] Roles { get; set; }
|
||||
|
||||
[JsonProperty(PropertyName = "login")]
|
||||
public string LoginNev { get; set; }
|
||||
|
||||
[JsonProperty(PropertyName = "personal_id")]
|
||||
public string Azonosito { get; set; }
|
||||
|
||||
[JsonProperty(PropertyName = "display_name")]
|
||||
public string MegjelenitesiNev { get; set; }
|
||||
|
||||
[JsonProperty(PropertyName = "position")]
|
||||
public string Beosztas { get; set; }
|
||||
|
||||
[JsonProperty(PropertyName = "institute_name")]
|
||||
public string IntezmenyNeve { get; set; }
|
||||
|
||||
[JsonProperty(PropertyName = "cost_center")]
|
||||
public string FunkcioTerulet { get; set; }
|
||||
|
||||
[JsonProperty(PropertyName = "sztsz")]
|
||||
public string SztszKod { get; set; }
|
||||
|
||||
[JsonProperty(PropertyName = "kreta_id")]
|
||||
public string KretaRendszerAzonosito { get; set; }
|
||||
|
||||
[JsonProperty(PropertyName = "access_manager_name")]
|
||||
public string JogosultsagotSzerkesztoSzemelyNev { get; set; }
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue