Skip to content

Commit 98d794c

Browse files
committed
DKT API added
1 parent 6e293e9 commit 98d794c

26 files changed

+755
-20
lines changed

DktApi.cs

Lines changed: 143 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,143 @@
1+
using System.Net.Http.Json;
2+
using System.Text.Json;
3+
4+
namespace TTMC.Kréta
5+
{
6+
public class DktApi
7+
{
8+
private HttpClient client;
9+
public DktApi(string accessToken, string acceptLanguage = "hu-HU", string? apiKey = "21ff6c25-d1da-4a68-a811-c881a6057463", string domain = "e-kreta.hu")
10+
{
11+
client = new()
12+
{
13+
BaseAddress = new($"https://kretadktapi.{domain}")
14+
};
15+
if (!string.IsNullOrEmpty(apiKey))
16+
{
17+
client.DefaultRequestHeaders.Add("apiKey", apiKey);
18+
}
19+
client.DefaultRequestHeaders.Add("Accept-Language", acceptLanguage);
20+
client.DefaultRequestHeaders.Authorization = new("Bearer", accessToken);
21+
}
22+
public HttpContent deleteHomeworkSolutionAttachment(string haziFeladatBeadasId, string id)
23+
{
24+
HttpResponseMessage resp = client.DeleteAsync($"/dktapi/intezmenyek/tanulok/orak/hazifeladatok/beadasok/{haziFeladatBeadasId}/fajlok/{id}").Result;
25+
return resp.Content;
26+
}
27+
public HttpContent deleteSolutionAttachment(string oraiFeladatBeadasId, string id)
28+
{
29+
HttpResponseMessage resp = client.DeleteAsync($"/dktapi/intezmenyek/tanulok/orak/oraifeladatok/beadasok/{oraiFeladatBeadasId}/fajlok/{id}").Result;
30+
return resp.Content;
31+
}
32+
public Classwork? getClasswork(string oraiFeladatId)
33+
{
34+
HttpResponseMessage resp = client.GetAsync($"/dktapi/intezmenyek/tanulok/orak/oraifeladatok/{oraiFeladatId}").Result;
35+
string json = resp.Content.ReadAsStringAsync().Result;
36+
return JsonSerializer.Deserialize<Classwork>(json);
37+
}
38+
public string getClassworkAttachmentUrl(string oraiFeladatId, string id)
39+
{
40+
HttpResponseMessage resp = client.GetAsync($"/dktapi/intezmenyek/tanulok/orak/oraifeladatok/{oraiFeladatId}/fajlok/{id}/url").Result;
41+
return resp.Content.ReadAsStringAsync().Result;
42+
}
43+
public List<ClassworkAttachment>? getClassworkAttachments(string id)
44+
{
45+
HttpResponseMessage resp = client.GetAsync($"/dktapi/intezmenyek/tanulok/orak/oraifeladatok/{id}/fajlok").Result;
46+
string json = resp.Content.ReadAsStringAsync().Result;
47+
return JsonSerializer.Deserialize<List<ClassworkAttachment>>(json);
48+
}
49+
public List<Classwork>? getClassworkGroups(string groupId)
50+
{
51+
HttpResponseMessage resp = client.GetAsync($"/dktapi/intezmenyek/tanulok/orak/oraifeladatok/groupok/{groupId}").Result;
52+
string json = resp.Content.ReadAsStringAsync().Result;
53+
return JsonSerializer.Deserialize<List<Classwork>>(json);
54+
}
55+
public string getClassworkSolutionAttachmentUrl(string oraiFeladatBeadasId, string id)
56+
{
57+
HttpResponseMessage resp = client.GetAsync($"/dktapi/intezmenyek/tanulok/orak/oraifeladatok/beadasok/{oraiFeladatBeadasId}/fajlok/{id}/url").Result;
58+
return resp.Content.ReadAsStringAsync().Result;
59+
}
60+
public List<ClassworkTeachingMaterial>? getClassworkTeachingMaterial(ClassworkTeachingMaterialPost classworkTeachingMaterialPost)
61+
{
62+
JsonContent jsonContent = JsonContent.Create(classworkTeachingMaterialPost, options: GlobalApi.jsonSerializerOptions);
63+
HttpResponseMessage resp = client.PostAsync($"/dktapi/intezmenyek/tanulok/orak/tananyagok", jsonContent).Result;
64+
string json = resp.Content.ReadAsStringAsync().Result;
65+
return JsonSerializer.Deserialize<List<ClassworkTeachingMaterial>>(json);
66+
}
67+
public string getHomeworkSolutionAttachmentUrl(string haziFeladatBeadasId, string id)
68+
{
69+
HttpResponseMessage resp = client.GetAsync($"/dktapi/intezmenyek/tanulok/orak/hazifeladatok/beadasok/{haziFeladatBeadasId}/fajlok/{id}/url").Result;
70+
return resp.Content.ReadAsStringAsync().Result;
71+
}
72+
public List<HomeworkSolutionAttachment>? getHomeworkSolutionAttachments(string haziFeladatBeadasId)
73+
{
74+
HttpResponseMessage resp = client.GetAsync($"/dktapi/intezmenyek/tanulok/orak/hazifeladatok/beadasok/{haziFeladatBeadasId}/fajlok").Result;
75+
string json = resp.Content.ReadAsStringAsync().Result;
76+
return JsonSerializer.Deserialize<List<HomeworkSolutionAttachment>>(json);
77+
}
78+
public LanguageTask? getLanguageTask(string groupId)
79+
{
80+
HttpResponseMessage resp = client.GetAsync($"/dktapi/intezmenyek/tanulok/orak/nyelvifeladatok/{groupId}").Result;
81+
string json = resp.Content.ReadAsStringAsync().Result;
82+
return JsonSerializer.Deserialize<LanguageTask>(json);
83+
}
84+
public LanguageTaskSubmission? getLanguageTaskSubmission(string groupId)
85+
{
86+
HttpResponseMessage resp = client.GetAsync($"/dktapi/intezmenyek/tanulok/orak/nyelvifeladatok/groupok/{groupId}/beadas").Result;
87+
string json = resp.Content.ReadAsStringAsync().Result;
88+
return JsonSerializer.Deserialize<LanguageTaskSubmission>(json);
89+
}
90+
public List<ClassworkSolutionAttachment>? getSolutionAttachments(string beadasId)
91+
{
92+
HttpResponseMessage resp = client.GetAsync($"/dktapi/intezmenyek/tanulok/orak/oraifeladatok/beadasok/{beadasId}/fajlok").Result;
93+
string json = resp.Content.ReadAsStringAsync().Result;
94+
return JsonSerializer.Deserialize<List<ClassworkSolutionAttachment>>(json);
95+
}
96+
public SubmittedClasswork? getSubmittedClasswork(string oraiFeladatId)
97+
{
98+
HttpResponseMessage resp = client.GetAsync($"/dktapi/intezmenyek/tanulok/orak/oraifeladatok/{oraiFeladatId}/beadas").Result;
99+
string json = resp.Content.ReadAsStringAsync().Result;
100+
return JsonSerializer.Deserialize<SubmittedClasswork>(json);
101+
}
102+
public SubmittedHomework? getSubmittedHomework(string haziFeladatId)
103+
{
104+
HttpResponseMessage resp = client.GetAsync($"/dktapi/intezmenyek/tanulok/orak/hazifeladatok/{haziFeladatId}/beadas").Result;
105+
string json = resp.Content.ReadAsStringAsync().Result;
106+
return JsonSerializer.Deserialize<SubmittedHomework>(json);
107+
}
108+
public string putSaveSolution(string beadasId, ClassworkSolutionPut classworkSolutionPut)
109+
{
110+
JsonContent jsonContent = JsonContent.Create(classworkSolutionPut, options: GlobalApi.jsonSerializerOptions);
111+
HttpResponseMessage resp = client.PutAsync($"/dktapi/intezmenyek/tanulok/orak/oraifeladatok/beadasok/{beadasId}", jsonContent).Result;
112+
return resp.Content.ReadAsStringAsync().Result;
113+
}
114+
public HttpContent saveHomeworkAttachment(string haziFeladatBeadasId, HomeworkSolutionAttachmentPost homeworkSolutionAttachmentPost)
115+
{
116+
JsonContent jsonContent = JsonContent.Create(homeworkSolutionAttachmentPost, options: GlobalApi.jsonSerializerOptions);
117+
HttpResponseMessage resp = client.PostAsync($"/dktapi/intezmenyek/tanulok/orak/hazifeladatok/beadasok/{haziFeladatBeadasId}/fajlok/veglegesites", jsonContent).Result;
118+
return resp.Content;
119+
}
120+
public string saveHomeworkSolution(string haziFeladatId, HomeworkSolutionPut homeworkSolutionPut)
121+
{
122+
JsonContent jsonContent = JsonContent.Create(homeworkSolutionPut, options: GlobalApi.jsonSerializerOptions);
123+
HttpResponseMessage resp = client.PutAsync($"/dktapi/intezmenyek/tanulok/orak/hazifeladatok/beadasok/{haziFeladatId}", jsonContent).Result;
124+
return resp.Content.ReadAsStringAsync().Result;
125+
}
126+
public HttpContent saveSolutionAttachment(string oraiFeladatBeadasId, ClassworkSolutionAttachmentPost classworkSolutionAttachmentPost)
127+
{
128+
JsonContent jsonContent = JsonContent.Create(classworkSolutionAttachmentPost, options: GlobalApi.jsonSerializerOptions);
129+
HttpResponseMessage resp = client.PostAsync($"/dktapi/intezmenyek/tanulok/orak/oraifeladatok/beadasok/{oraiFeladatBeadasId}/fajlok/veglegesites", jsonContent).Result;
130+
return resp.Content;
131+
}
132+
public string submitClassworkSolution(string beadasId)
133+
{
134+
HttpResponseMessage resp = client.GetAsync($"/dktapi/intezmenyek/tanulok/orak/oraifeladatok/beadasok/{beadasId}/beadas").Result;
135+
return resp.Content.ReadAsStringAsync().Result;
136+
}
137+
public string submitHomeworkSolution(string haziFeladatId)
138+
{
139+
HttpResponseMessage resp = client.GetAsync($"/dktapi/intezmenyek/tanulok/orak/hazifeladatok/beadasok/{haziFeladatId}/beadas").Result;
140+
return resp.Content.ReadAsStringAsync().Result;
141+
}
142+
}
143+
}

DktApi/Classwork.cs

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
using System.Text.Json.Serialization;
2+
3+
namespace TTMC.Kréta
4+
{
5+
public class Classwork
6+
{
7+
[JsonPropertyName("csatolasEngedelyezesTipusId")]
8+
public long? allowToAttachFileTypeId { get; set; }
9+
[JsonPropertyName("csoportId")]
10+
public long? classGroupId { get; set; }
11+
[JsonPropertyName("osztalyId")]
12+
public long? classId { get; set; }
13+
[JsonPropertyName("osztalyNev")]
14+
public string? className { get; set; }
15+
[JsonPropertyName("letrehozasIdeje")]
16+
public string? creationTimeAsString { get; set; }
17+
[JsonPropertyName("alkalmazottId")]
18+
public long? employeeId { get; set; }
19+
[JsonPropertyName("groupId")]
20+
public string? groupId { get; set; }
21+
[JsonPropertyName("id")]
22+
public long id { get; set; }
23+
[JsonPropertyName("idotartamPerc")]
24+
public int? lengthInMinutes { get; set; }
25+
[JsonPropertyName("oraDatum")]
26+
public string? lessonDateAsString { get; set; }
27+
[JsonPropertyName("oraszam")]
28+
public long? lessonNumber { get; set; }
29+
[JsonPropertyName("oraIdopont")]
30+
public string? lessonTimeAsString { get; set; }
31+
[JsonPropertyName("pontszam")]
32+
public double? score { get; set; }
33+
[JsonPropertyName("tantargyKategoriaId")]
34+
public string? subjectCategoryUid { get; set; }
35+
[JsonPropertyName("tantargyId")]
36+
public long? subjectId { get; set; }
37+
[JsonPropertyName("tantargyNev")]
38+
public string? subjectName { get; set; }
39+
[JsonPropertyName("beadandoTipusId")]
40+
public long? taskTypeId { get; set; }
41+
[JsonPropertyName("alkalmazottNev")]
42+
public string? teacherName { get; set; }
43+
[JsonPropertyName("szoveg")]
44+
public string? text { get; set; }
45+
[JsonPropertyName("cim")]
46+
public string? title { get; set; }
47+
[JsonPropertyName("egyediId")]
48+
public string? uid { get; set; }
49+
}
50+
}

DktApi/ClassworkAttachment.cs

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
using System.Text.Json.Serialization;
2+
3+
namespace TTMC.Kréta
4+
{
5+
public class ClassworkAttachment
6+
{
7+
[JsonPropertyName("feladatId")]
8+
public long classworkId { get; set; }
9+
[JsonPropertyName("kiterjesztes")]
10+
public string? extension { get; set; }
11+
[JsonPropertyName("fajlNev")]
12+
public string? fileName { get; set; }
13+
[JsonPropertyName("id")]
14+
public long id { get; set; }
15+
[JsonPropertyName("nev")]
16+
public string? name { get; set; }
17+
[JsonPropertyName("egyediId")]
18+
public string? uid { get; set; }
19+
}
20+
}
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
using System.Text.Json.Serialization;
2+
3+
namespace TTMC.Kréta
4+
{
5+
public class ClassworkSolutionAttachmentPost
6+
{
7+
[JsonPropertyName("kiterjesztes")]
8+
public string? extension { get; set; }
9+
[JsonPropertyName("fajlNev")]
10+
public string? fileName { get; set; }
11+
[JsonPropertyName("id")]
12+
public long id { get; set; }
13+
[JsonPropertyName("nev")]
14+
public string? name { get; set; }
15+
[JsonPropertyName("feladatBeadasId")]
16+
public long submittedClassworkId { get; set; }
17+
[JsonPropertyName("egyediId")]
18+
public string? uid { get; set; }
19+
}
20+
}
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
using System.Text.Json.Serialization;
2+
3+
namespace TTMC.Kréta
4+
{
5+
public class ClassworkSolutionAttachment
6+
{
7+
[JsonPropertyName("fajlId")]
8+
public string? fileId { get; set; }
9+
[JsonPropertyName("teljesFajlNev")]
10+
public string? fileName { get; set; }
11+
[JsonPropertyName("meretInBytes")]
12+
public string? sizeInBytes { get; set; }
13+
}
14+
}

DktApi/ClassworkSolutionPut.cs

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
using System.Text.Json.Serialization;
2+
3+
namespace TTMC.Kréta
4+
{
5+
public class ClassworkSolutionPut
6+
{
7+
[JsonPropertyName("osztalyId")]
8+
public long? classId { get; set; }
9+
[JsonPropertyName("feladatId")]
10+
public long classworkId { get; set; }
11+
[JsonPropertyName("datum")]
12+
public string? date { get; set; }
13+
[JsonPropertyName("alkalmazottId")]
14+
public long employeeId { get; set; }
15+
[JsonPropertyName("csoportId")]
16+
public long? groupId { get; set; }
17+
[JsonPropertyName("oraszam")]
18+
public long lessonNumber { get; set; }
19+
[JsonPropertyName("tantargyId")]
20+
public long subjectId { get; set; }
21+
[JsonPropertyName("idopont")]
22+
public string? time { get; set; }
23+
}
24+
}
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 ClassworkTeachingMaterial
6+
{
7+
[JsonPropertyName("feladatId")]
8+
public long classworkId { get; set; }
9+
[JsonPropertyName("id")]
10+
public long id { get; set; }
11+
[JsonPropertyName("link")]
12+
public string? link { get; set; }
13+
[JsonPropertyName("forrasTipusId")]
14+
public int materialTypeId { get; set; }
15+
[JsonPropertyName("cim")]
16+
public string? title { get; set; }
17+
}
18+
}
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
using System.Text.Json.Serialization;
2+
3+
namespace TTMC.Kréta
4+
{
5+
public class ClassworkTeachingMaterialPost
6+
{
7+
[JsonPropertyName("osztalyId")]
8+
public long? classId { get; set; }
9+
[JsonPropertyName("feladatId")]
10+
public long classworkId { get; set; }
11+
[JsonPropertyName("datum")]
12+
public string? date { get; set; }
13+
[JsonPropertyName("alkalmazottId")]
14+
public long employeeId { get; set; }
15+
[JsonPropertyName("csoportId")]
16+
public long? groupId { get; set; }
17+
[JsonPropertyName("oraszam")]
18+
public long lessonNumber { get; set; }
19+
[JsonPropertyName("tantargyId")]
20+
public long subjectId { get; set; }
21+
[JsonPropertyName("idopont")]
22+
public string? time { get; set; }
23+
}
24+
}
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
using System.Text.Json.Serialization;
2+
3+
namespace TTMC.Kréta
4+
{
5+
public class HomeworkSolutionAttachment
6+
{
7+
[JsonPropertyName("kiterjesztes")]
8+
public string? extension { get; set; }
9+
[JsonPropertyName("fajlNev")]
10+
public string? fileName { get; set; }
11+
[JsonPropertyName("id")]
12+
public long id { get; set; }
13+
[JsonPropertyName("nev")]
14+
public string? name { get; set; }
15+
[JsonPropertyName("feladatBeadasId")]
16+
public long submittedHomeworkId { get; set; }
17+
[JsonPropertyName("egyediId")]
18+
public string? uid { get; set; }
19+
[JsonPropertyName("feltoltoAlkalmazottId")]
20+
public long? uploaderEmployeeId { get; set; }
21+
[JsonPropertyName("feltoltoTanuloId")]
22+
public long? uploaderStudentId { get; set; }
23+
}
24+
}
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
using System.Text.Json.Serialization;
2+
3+
namespace TTMC.Kréta
4+
{
5+
public class HomeworkSolutionAttachmentPost
6+
{
7+
[JsonPropertyName("fajlId")]
8+
public string? fileId { get; set; }
9+
[JsonPropertyName("teljesFajlNev")]
10+
public string? fileName { get; set; }
11+
[JsonPropertyName("meretInBytes")]
12+
public long? sizeInBytes { get; set; }
13+
}
14+
}

0 commit comments

Comments
 (0)