init
This commit is contained in:
commit
e124a47765
19374 changed files with 9806149 additions and 0 deletions
84
Kreta.Client/KozpontiKreta/KozpontiClient.cs
Normal file
84
Kreta.Client/KozpontiKreta/KozpontiClient.cs
Normal file
|
@ -0,0 +1,84 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using Kreta.Client.KozpontiKreta.Model;
|
||||
using Kreta.Core.KozpontiModels.MdszModels;
|
||||
using Newtonsoft.Json;
|
||||
using RestSharp;
|
||||
|
||||
namespace Kreta.Client.KozpontiKreta
|
||||
{
|
||||
public class KozpontiClient
|
||||
{
|
||||
private readonly string baseUrl;
|
||||
private readonly string apiKey;
|
||||
|
||||
public KozpontiClient(string baseUrl, string apiKey)
|
||||
{
|
||||
this.baseUrl = baseUrl;
|
||||
this.apiKey = apiKey;
|
||||
}
|
||||
|
||||
private IRestResponse Http(Method method, string relativeUri, Dictionary<string, string> parameters = null, Object body = null)
|
||||
{
|
||||
var restRequest = new RestRequest(relativeUri, method);
|
||||
restRequest.AddHeader("ApiKey", apiKey);
|
||||
|
||||
if (parameters != null && parameters.Count > 0)
|
||||
{
|
||||
foreach (var parameter in parameters)
|
||||
{
|
||||
restRequest.AddParameter(parameter.Key, parameter.Value);
|
||||
}
|
||||
}
|
||||
|
||||
if (method == Method.POST && body != null)
|
||||
{
|
||||
restRequest.AddJsonBody(body);
|
||||
}
|
||||
|
||||
var result = new RestClient(string.Format(baseUrl)).Execute(restRequest);
|
||||
return result;
|
||||
}
|
||||
|
||||
private TResponse Http<TResponse>(Method method, string relativeUri, Dictionary<string, string> parameters = null, Object body = null)
|
||||
{
|
||||
var result = Http(method, relativeUri, parameters, body);
|
||||
var response = JsonConvert.DeserializeObject<TResponse>(result.Content);
|
||||
|
||||
return response;
|
||||
}
|
||||
|
||||
private TResponse GetAsync<TResponse>(string relativeUri, Dictionary<string, string> parameters = null)
|
||||
{
|
||||
return Http<TResponse>(Method.GET, relativeUri, parameters);
|
||||
}
|
||||
|
||||
private TResponse PostAsync<TResponse>(string relativeUri, Dictionary<string, string> parameters = null, Object body = null)
|
||||
{
|
||||
return Http<TResponse>(Method.POST, relativeUri, parameters, body);
|
||||
}
|
||||
|
||||
private void Post(string relativeUri, Dictionary<string, string> parameters = null, Object body = null)
|
||||
{
|
||||
Http(Method.POST, relativeUri, parameters, body);
|
||||
}
|
||||
|
||||
public List<MdszResponseModel> GetDiakOlimpiaList(MdszRequestModel model)
|
||||
{
|
||||
var response = PostAsync<List<MdszResponseModel>>("/api/Mdsz/external/get", null, model);
|
||||
return response;
|
||||
}
|
||||
|
||||
public KozpontiNebuloResponseModel NebuloJelenlet(KozpontiNebuloRequestModel model)
|
||||
{
|
||||
var response = PostAsync<KozpontiNebuloResponseModel>("/api/nebulo/external/megjelent", null, model);
|
||||
return response;
|
||||
}
|
||||
|
||||
public KozpontiNebuloEngedelyezettResponseModel GetBeiratkozasLetszamList(KozpontiNebuloEngedelyezettRequestModel model)
|
||||
{
|
||||
var response = PostAsync<KozpontiNebuloEngedelyezettResponseModel>("/api/Approves/external/engedelyezett", null, model);
|
||||
return response;
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue