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+ }
0 commit comments