Skip to content

Commit 075eeb4

Browse files
committed
EAdmin API added
1 parent 98d794c commit 075eeb4

39 files changed

+955
-49
lines changed

DktApi.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ public string getClassworkSolutionAttachmentUrl(string oraiFeladatBeadasId, stri
5959
}
6060
public List<ClassworkTeachingMaterial>? getClassworkTeachingMaterial(ClassworkTeachingMaterialPost classworkTeachingMaterialPost)
6161
{
62-
JsonContent jsonContent = JsonContent.Create(classworkTeachingMaterialPost, options: GlobalApi.jsonSerializerOptions);
62+
JsonContent jsonContent = JsonContent.Create(classworkTeachingMaterialPost, options: Engine.jsonSerializerOptions);
6363
HttpResponseMessage resp = client.PostAsync($"/dktapi/intezmenyek/tanulok/orak/tananyagok", jsonContent).Result;
6464
string json = resp.Content.ReadAsStringAsync().Result;
6565
return JsonSerializer.Deserialize<List<ClassworkTeachingMaterial>>(json);
@@ -107,25 +107,25 @@ public string getHomeworkSolutionAttachmentUrl(string haziFeladatBeadasId, strin
107107
}
108108
public string putSaveSolution(string beadasId, ClassworkSolutionPut classworkSolutionPut)
109109
{
110-
JsonContent jsonContent = JsonContent.Create(classworkSolutionPut, options: GlobalApi.jsonSerializerOptions);
110+
JsonContent jsonContent = JsonContent.Create(classworkSolutionPut, options: Engine.jsonSerializerOptions);
111111
HttpResponseMessage resp = client.PutAsync($"/dktapi/intezmenyek/tanulok/orak/oraifeladatok/beadasok/{beadasId}", jsonContent).Result;
112112
return resp.Content.ReadAsStringAsync().Result;
113113
}
114114
public HttpContent saveHomeworkAttachment(string haziFeladatBeadasId, HomeworkSolutionAttachmentPost homeworkSolutionAttachmentPost)
115115
{
116-
JsonContent jsonContent = JsonContent.Create(homeworkSolutionAttachmentPost, options: GlobalApi.jsonSerializerOptions);
116+
JsonContent jsonContent = JsonContent.Create(homeworkSolutionAttachmentPost, options: Engine.jsonSerializerOptions);
117117
HttpResponseMessage resp = client.PostAsync($"/dktapi/intezmenyek/tanulok/orak/hazifeladatok/beadasok/{haziFeladatBeadasId}/fajlok/veglegesites", jsonContent).Result;
118118
return resp.Content;
119119
}
120120
public string saveHomeworkSolution(string haziFeladatId, HomeworkSolutionPut homeworkSolutionPut)
121121
{
122-
JsonContent jsonContent = JsonContent.Create(homeworkSolutionPut, options: GlobalApi.jsonSerializerOptions);
122+
JsonContent jsonContent = JsonContent.Create(homeworkSolutionPut, options: Engine.jsonSerializerOptions);
123123
HttpResponseMessage resp = client.PutAsync($"/dktapi/intezmenyek/tanulok/orak/hazifeladatok/beadasok/{haziFeladatId}", jsonContent).Result;
124124
return resp.Content.ReadAsStringAsync().Result;
125125
}
126126
public HttpContent saveSolutionAttachment(string oraiFeladatBeadasId, ClassworkSolutionAttachmentPost classworkSolutionAttachmentPost)
127127
{
128-
JsonContent jsonContent = JsonContent.Create(classworkSolutionAttachmentPost, options: GlobalApi.jsonSerializerOptions);
128+
JsonContent jsonContent = JsonContent.Create(classworkSolutionAttachmentPost, options: Engine.jsonSerializerOptions);
129129
HttpResponseMessage resp = client.PostAsync($"/dktapi/intezmenyek/tanulok/orak/oraifeladatok/beadasok/{oraiFeladatBeadasId}/fajlok/veglegesites", jsonContent).Result;
130130
return resp.Content;
131131
}

EAdminApi.cs

Lines changed: 191 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
using System.Text.Json;
1+
using System.Net.Http.Json;
2+
using System.Text.Json;
23

34
namespace TTMC.Kréta
45
{
@@ -14,39 +15,210 @@ public EAdminApi(string accessToken, string domain = "e-kreta.hu")
1415
client.DefaultRequestHeaders.Add("X-Uzenet-Lokalizacio", "hu-HU");
1516
client.DefaultRequestHeaders.Authorization = new("Bearer", accessToken);
1617
}
17-
private TemporaryFile uploadAttachment(string url, Stream stream, string fileName)
18+
public TemporaryFile createAttachment(Stream stream, string fileName)
1819
{
1920
MultipartFormDataContent multipartFormDataContent = new();
2021
StreamContent streamContent = new(stream);
2122
multipartFormDataContent.Add(streamContent, "fajl", fileName);
22-
HttpResponseMessage resp = client.PostAsync(url, multipartFormDataContent).Result;
23+
HttpResponseMessage resp = client.PostAsync("/api/v1/ideiglenesfajlok", multipartFormDataContent).Result;
2324
string json = resp.Content.ReadAsStringAsync().Result;
2425
return Deserialize<TemporaryFile>(json);
2526
}
26-
private TemporaryFile uploadAttachment(string url, byte[] data, string fileName)
27+
public HttpContent createRectification(string ugyId, RectificationPost rectificationPost)
2728
{
28-
MultipartFormDataContent multipartFormDataContent = new();
29-
ByteArrayContent byteArrayContent = new(data);
30-
multipartFormDataContent.Add(byteArrayContent, "fajl", fileName);
31-
HttpResponseMessage resp = client.PostAsync(url, multipartFormDataContent).Result;
29+
JsonContent jsonContent = JsonContent.Create(rectificationPost, options: Engine.jsonSerializerOptions);
30+
HttpResponseMessage resp = client.PostAsync($"/api/v1/ugy/kerelmek/{ugyId}", jsonContent).Result;
31+
return resp.Content;
32+
}
33+
public HttpContent createTmgiCase(TmgiCasePost tmgiCasePost)
34+
{
35+
JsonContent jsonContent = JsonContent.Create(tmgiCasePost, options: Engine.jsonSerializerOptions);
36+
HttpResponseMessage resp = client.PostAsync($"/api/v1/ugy/kerelmek", jsonContent).Result;
37+
return resp.Content;
38+
}
39+
public HttpContent deleteMessagePermanently(bool isKuka, params long[] postaladaElemAzonositok)
40+
{
41+
string temp = string.Empty;
42+
foreach (long value in postaladaElemAzonositok)
43+
{
44+
temp += "," + postaladaElemAzonositok;
45+
}
46+
HttpResponseMessage resp = client.DeleteAsync($"/api/v1/kommunikacio/postaladaelemek/torles?isKuka={isKuka}&postaladaElemAzonositok={temp[1..]}").Result;
47+
return resp.Content;
48+
}
49+
public HttpContent downloadAttachment(string url)
50+
{
51+
HttpResponseMessage resp = client.GetAsync($"/api/v1/{url}").Result;
52+
return resp.Content;
53+
}
54+
public List<AccessControlSystemItem> getAccessControlSystemEvents()
55+
{
56+
HttpResponseMessage resp = client.GetAsync($"/api/v1/belepteto/kartyaesemenyek/sajat").Result;
3257
string json = resp.Content.ReadAsStringAsync().Result;
33-
return Deserialize<TemporaryFile>(json);
58+
return Deserialize<List<AccessControlSystemItem>>(json);
3459
}
35-
private TemporaryFile createAttachment(Stream stream, string fileName)
60+
public List<KretaClass> getAddressableClasses(string cimzettKod)
3661
{
37-
MultipartFormDataContent multipartFormDataContent = new();
38-
StreamContent streamContent = new(stream);
39-
multipartFormDataContent.Add(streamContent, "fajl", fileName);
40-
HttpResponseMessage resp = client.PostAsync("api/v1/ideiglenesfajlok", multipartFormDataContent).Result;
62+
HttpResponseMessage resp = client.GetAsync($"/api/v1/kommunikacio/osztalyok/cimezheto?cimzettKod={cimzettKod}").Result;
4163
string json = resp.Content.ReadAsStringAsync().Result;
42-
return Deserialize<TemporaryFile>(json);
64+
return Deserialize<List<KretaClass>>(json);
65+
}
66+
public List<GuardianEAdmin> getAddressableGuardiansForClass(long osztalyKretaAzonosito)
67+
{
68+
HttpResponseMessage resp = client.GetAsync($"/api/v1/kreta/gondviselok/osztaly/{osztalyKretaAzonosito}").Result;
69+
string json = resp.Content.ReadAsStringAsync().Result;
70+
return Deserialize<List<GuardianEAdmin>>(json);
71+
}
72+
public List<GuardianEAdmin> getAddressableSzmkRepesentative()
73+
{
74+
HttpResponseMessage resp = client.GetAsync($"/api/v1/kommunikacio/szmkkepviselok/cimezheto").Result;
75+
string json = resp.Content.ReadAsStringAsync().Result;
76+
return Deserialize<List<GuardianEAdmin>>(json);
77+
}
78+
public List<AddresseeType> getAddressableType()
79+
{
80+
HttpResponseMessage resp = client.GetAsync($"/api/v1/kommunikacio/cimezhetotipusok").Result;
81+
string json = resp.Content.ReadAsStringAsync().Result;
82+
return Deserialize<List<AddresseeType>>(json);
83+
}
84+
public List<AddresseeType> getAddresseeType()
85+
{
86+
HttpResponseMessage resp = client.GetAsync($"/api/v1/adatszotarak/cimzetttipusok").Result;
87+
string json = resp.Content.ReadAsStringAsync().Result;
88+
return Deserialize<List<AddresseeType>>(json);
89+
}
90+
public List<EmployeeDetails> getAdministrators()
91+
{
92+
HttpResponseMessage resp = client.GetAsync($"/api/v1/kreta/alkalmazottak/adminisztrator").Result;
93+
string json = resp.Content.ReadAsStringAsync().Result;
94+
return Deserialize<List<EmployeeDetails>>(json);
95+
}
96+
public Case getCase(string ugyId)
97+
{
98+
HttpResponseMessage resp = client.GetAsync($"/api/v1/ugy/kerelmek/{ugyId}").Result;
99+
string json = resp.Content.ReadAsStringAsync().Result;
100+
return Deserialize<Case>(json);
101+
}
102+
public List<Type> getCaseTypes()
103+
{
104+
HttpResponseMessage resp = client.GetAsync($"/api/v1/adatszotarak/kerelemtipusok").Result;
105+
string json = resp.Content.ReadAsStringAsync().Result;
106+
return Deserialize<List<Type>>(json);
107+
}
108+
public List<Case> getCases()
109+
{
110+
HttpResponseMessage resp = client.GetAsync($"/api/v1/ugy/kerelmek").Result;
111+
string json = resp.Content.ReadAsStringAsync().Result;
112+
return Deserialize<List<Case>>(json);
113+
}
114+
public Child getChildData()
115+
{
116+
HttpResponseMessage resp = client.GetAsync($"/api/v1/kreta/gyerekemadatok").Result;
117+
string json = resp.Content.ReadAsStringAsync().Result;
118+
return Deserialize<Child>(json);
119+
}
120+
public List<EmployeeDetails> getClassMasters()
121+
{
122+
HttpResponseMessage resp = client.GetAsync($"/api/v1/kreta/alkalmazottak/oszalyfonok").Result;
123+
string json = resp.Content.ReadAsStringAsync().Result;
124+
return Deserialize<List<EmployeeDetails>>(json);
43125
}
44-
private TemporaryFile createAttachment(byte[] data, string fileName)
126+
public CurrentInstitutionDetails getCurrentInstitutionDetails()
127+
{
128+
HttpResponseMessage resp = client.GetAsync($"/api/v1/ugy/aktualisIntezmenyAdatok").Result;
129+
string json = resp.Content.ReadAsStringAsync().Result;
130+
return Deserialize<CurrentInstitutionDetails>(json);
131+
}
132+
public List<string> getCurrentInstitutionModules()
133+
{
134+
HttpResponseMessage resp = client.GetAsync($"/api/v1/intezmenyek/sajat/modulok").Result;
135+
string json = resp.Content.ReadAsStringAsync().Result;
136+
return Deserialize<List<string>>(json);
137+
}
138+
public List<EmployeeDetails> getDirectors()
139+
{
140+
HttpResponseMessage resp = client.GetAsync($"/api/v1/kreta/alkalmazottak/igazgatosag").Result;
141+
string json = resp.Content.ReadAsStringAsync().Result;
142+
return Deserialize<List<EmployeeDetails>>(json);
143+
}
144+
public MailboxItem getMessage(long azonosito)
145+
{
146+
HttpResponseMessage resp = client.GetAsync($"/api/v1/kommunikacio/postaladaelemek/{azonosito}").Result;
147+
string json = resp.Content.ReadAsStringAsync().Result;
148+
return Deserialize<MailboxItem>(json);
149+
}
150+
public MessageLimitations getMessageLimitations()
151+
{
152+
HttpResponseMessage resp = client.GetAsync($"/api/v1/kommunikacio/uzenetek/kuldhetok/korlat").Result;
153+
string json = resp.Content.ReadAsStringAsync().Result;
154+
return Deserialize<MessageLimitations>(json);
155+
}
156+
public List<MailboxItem> getMessages()
157+
{
158+
HttpResponseMessage resp = client.GetAsync($"/api/v1/kommunikacio/postaladaelemek/sajat").Result;
159+
string json = resp.Content.ReadAsStringAsync().Result;
160+
return Deserialize<List<MailboxItem>>(json);
161+
}
162+
public Signer getSigner(int kerelemAzonosito, int kretaAzonosito)
163+
{
164+
HttpResponseMessage resp = client.GetAsync($"/api/v1/ugy/alkalmazott/{kerelemAzonosito}/{kretaAzonosito}").Result;
165+
string json = resp.Content.ReadAsStringAsync().Result;
166+
return Deserialize<Signer>(json);
167+
}
168+
public Status getStatus()
169+
{
170+
HttpResponseMessage resp = client.GetAsync($"/api/v1/status").Result;
171+
string json = resp.Content.ReadAsStringAsync().Result;
172+
return Deserialize<Status>(json);
173+
}
174+
public List<Guardian> getSzmk()
175+
{
176+
HttpResponseMessage resp = client.GetAsync($"/api/v1/kommunikacio/szmkkepviselok/cimezheto").Result;
177+
string json = resp.Content.ReadAsStringAsync().Result;
178+
return Deserialize<List<Guardian>>(json);
179+
}
180+
public List<EmployeeDetails> getTeachers()
181+
{
182+
HttpResponseMessage resp = client.GetAsync($"/api/v1/kreta/alkalmazottak/tanar").Result;
183+
string json = resp.Content.ReadAsStringAsync().Result;
184+
return Deserialize<List<EmployeeDetails>>(json);
185+
}
186+
public List<Type> getTmgiCaseTypes()
187+
{
188+
HttpResponseMessage resp = client.GetAsync($"/api/v1/adatszotarak/tmgiigazolastipusok").Result;
189+
string json = resp.Content.ReadAsStringAsync().Result;
190+
return Deserialize<List<Type>>(json);
191+
}
192+
public int getUnreadMessagesCount()
193+
{
194+
HttpResponseMessage resp = client.GetAsync($"/api/v1/kommunikacio/postaladaelemek/olvasatlanokszama").Result;
195+
string json = resp.Content.ReadAsStringAsync().Result;
196+
return Deserialize<int>(json);
197+
}
198+
public HttpContent readMessage(ReadMessageRequest readMessageRequest)
199+
{
200+
JsonContent jsonContent = JsonContent.Create(readMessageRequest, options: Engine.jsonSerializerOptions);
201+
HttpResponseMessage resp = client.PostAsync($"/api/v1/kommunikacio/postaladaelemek/olvasott", jsonContent).Result;
202+
return resp.Content;
203+
}
204+
public HttpContent sendMessage(Message message)
205+
{
206+
JsonContent jsonContent = JsonContent.Create(message, options: Engine.jsonSerializerOptions);
207+
HttpResponseMessage resp = client.PostAsync($"/api/v1/kommunikacio/uzenetek", jsonContent).Result;
208+
return resp.Content;
209+
}
210+
public HttpContent sendMessageToBin(SendMessageToBinRequest sendMessageToBinRequest)
211+
{
212+
JsonContent jsonContent = JsonContent.Create(sendMessageToBinRequest, options: Engine.jsonSerializerOptions);
213+
HttpResponseMessage resp = client.PostAsync($"/api/v1/kommunikacio/postaladaelemek/kuka", jsonContent).Result;
214+
return resp.Content;
215+
}
216+
public TemporaryFile uploadAttachment(string url, Stream stream, string fileName)
45217
{
46218
MultipartFormDataContent multipartFormDataContent = new();
47-
ByteArrayContent byteArrayContent = new(data);
48-
multipartFormDataContent.Add(byteArrayContent, "fajl", fileName);
49-
HttpResponseMessage resp = client.PostAsync("api/v1/ideiglenesfajlok", multipartFormDataContent).Result;
219+
StreamContent streamContent = new(stream);
220+
multipartFormDataContent.Add(streamContent, "fajl", fileName);
221+
HttpResponseMessage resp = client.PostAsync(url, multipartFormDataContent).Result;
50222
string json = resp.Content.ReadAsStringAsync().Result;
51223
return Deserialize<TemporaryFile>(json);
52224
}
@@ -75,12 +247,6 @@ private T Deserialize<T>(string json)
75247
}
76248
}
77249
}
78-
public class TemporaryFile
79-
{
80-
public string? fajlAzonosito { get; set; }
81-
public string? utvonal { get; set; }
82-
public long fajlMeretByteLength { get; set; }
83-
}
84250
public class EAdminException
85251
{
86252
public string? uzenet { get; set; }
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
using System.Text.Json.Serialization;
2+
3+
namespace TTMC.Kréta
4+
{
5+
public class AccessControlSystemItem
6+
{
7+
[JsonPropertyName("megjegyzes")]
8+
public string? commentText { get; set; }
9+
[JsonPropertyName("irany")]
10+
public string? directionText { get; set; }
11+
[JsonPropertyName("azonosito")]
12+
public long id { get; set; }
13+
[JsonPropertyName("idopont")]
14+
public string? recordDateAsString { get; set; }
15+
}
16+
}

EAdminApi/Addressee.cs

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
using System.Text.Json.Serialization;
2+
3+
namespace TTMC.Kréta
4+
{
5+
public class Addressee
6+
{
7+
[JsonPropertyName("azonosito")]
8+
public long id { get; set; }
9+
[JsonPropertyName("kretaAzonosito")]
10+
public long kretaId { get; set; }
11+
[JsonPropertyName("nev")]
12+
public string? name { get; set; }
13+
[JsonPropertyName("tipus")]
14+
public Type? type { get; set; }
15+
public class Type
16+
{
17+
[JsonPropertyName("kod")]
18+
public string? typeCode { get; set; }
19+
[JsonPropertyName("leiras")]
20+
public string? typeDescription { get; set; }
21+
[JsonPropertyName("azonosito")]
22+
public long typeId { get; set; }
23+
[JsonPropertyName("nev")]
24+
public string? typeName { get; set; }
25+
[JsonPropertyName("rovidNev")]
26+
public string? typeShortName { get; set; }
27+
}
28+
}
29+
}

EAdminApi/AddresseeType.cs

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
using System.Text.Json.Serialization;
2+
3+
namespace TTMC.Kréta
4+
{
5+
public class AddresseeType
6+
{
7+
[JsonPropertyName("kod")]
8+
public string? code { get; set; }
9+
[JsonPropertyName("leiras")]
10+
public string? description { get; set; }
11+
[JsonPropertyName("azonosito")]
12+
public long? id { get; set; }
13+
[JsonPropertyName("nev")]
14+
public string? name { get; set; }
15+
[JsonPropertyName("rovidNev")]
16+
public string? shortName { get; set; }
17+
}
18+
}

EAdminApi/Administrator.cs

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
using System.Text.Json.Serialization;
2+
3+
namespace TTMC.Kréta
4+
{
5+
public class Applicants
6+
{
7+
[JsonPropertyName("felhasznaloNev")]
8+
public string? fileName { get; set; }
9+
[JsonPropertyName("azonosito")]
10+
public int id { get; set; }
11+
[JsonPropertyName("nev")]
12+
public string? shortName { get; set; }
13+
[JsonPropertyName("titulus")]
14+
public string? title { get; set; }
15+
[JsonPropertyName("kretaFelhasznaloAzonosito")]
16+
public int userId { get; set; }
17+
18+
}
19+
}

EAdminApi/Applicants.cs

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
using System.Text.Json.Serialization;
2+
3+
namespace TTMC.Kréta
4+
{
5+
public class Administrator
6+
{
7+
[JsonPropertyName("azonosito")]
8+
public int id { get; set; }
9+
[JsonPropertyName("nev")]
10+
public string? shortName { get; set; }
11+
[JsonPropertyName("titulus")]
12+
public string? title { get; set; }
13+
[JsonPropertyName("kretaFelhasznaloAzonosito")]
14+
public int userId { get; set; }
15+
[JsonPropertyName("felhasznaloNev")]
16+
public string? userName { get; set; }
17+
}
18+
}

0 commit comments

Comments
 (0)