Add basic getting school free days in API

This commit is contained in:
Kacper Ziubryniewicz 2019-09-24 21:00:47 +02:00
parent a4db208dfd
commit e344be0fa1
2 changed files with 29 additions and 2 deletions

View File

@ -199,6 +199,7 @@ public class Librus implements EdziennikInterface {
private boolean enableDescriptiveGrades = false; private boolean enableDescriptiveGrades = false;
private boolean enableTextGrades = false; private boolean enableTextGrades = false;
private boolean enableBehaviourGrades = true; private boolean enableBehaviourGrades = true;
private long unitId = -1;
private int startPointsSemester1 = 0; private int startPointsSemester1 = 0;
private int startPointsSemester2 = 0; private int startPointsSemester2 = 0;
@ -346,6 +347,7 @@ public class Librus implements EdziennikInterface {
targetEndpoints.add("Events"); targetEndpoints.add("Events");
targetEndpoints.add("CustomTypes"); targetEndpoints.add("CustomTypes");
targetEndpoints.add("PtMeetings"); targetEndpoints.add("PtMeetings");
targetEndpoints.add("SchoolFreeDays");
break; break;
case FEATURE_GRADES: case FEATURE_GRADES:
targetEndpoints.add("SavedGradeCategories"); targetEndpoints.add("SavedGradeCategories");
@ -534,6 +536,9 @@ public class Librus implements EdziennikInterface {
case "TeacherFreeDays": case "TeacherFreeDays":
getTeacherFreeDays(); getTeacherFreeDays();
break; break;
case "SchoolFreeDays":
getSchoolFreeDays();
break;
case "MessagesLogin": case "MessagesLogin":
getMessagesLogin(); getMessagesLogin();
break; break;
@ -1403,7 +1408,8 @@ public class Librus implements EdziennikInterface {
} }
JsonElement unit = myClass.get("Unit"); JsonElement unit = myClass.get("Unit");
if (unit != null && !(unit instanceof JsonNull)) { if (unit != null && !(unit instanceof JsonNull)) {
profile.putStudentData("unitId", unit.getAsJsonObject().get("Id").getAsLong()); unitId = unit.getAsJsonObject().get("Id").getAsLong();
profile.putStudentData("unitId", unitId);
} }
r("finish", "Classes"); r("finish", "Classes");
} }
@ -3071,6 +3077,26 @@ public class Librus implements EdziennikInterface {
}); });
} }
private void getSchoolFreeDays() {
callback.onActionStarted(R.string.sync_action_syncing_school_free_days);
apiRequest("SchoolFreeDays" + (unitId != -1 ? "?unit=" + unitId : ""), data -> {
if (data == null) {
r("finish", "SchoolFreeDays");
return;
}
try {
JsonArray jFreeDays = data.get("SchoolFreeDays").getAsJsonArray();
for (JsonElement freeDayEl: jFreeDays) {
continue;
}
r("finish", "SchoolFreeDays");
} catch (Exception e) {
finishWithError(new AppError(TAG, 3069, CODE_OTHER, e, data));
}
});
}
private void getMessagesLogin() { private void getMessagesLogin() {
if (synergiaPassword == null) { if (synergiaPassword == null) {
// skip messages // skip messages
@ -3668,4 +3694,4 @@ public class Librus implements EdziennikInterface {
public MessagesComposeInfo getComposeInfo(@NonNull ProfileFull profile) { public MessagesComposeInfo getComposeInfo(@NonNull ProfileFull profile) {
return new MessagesComposeInfo(0, 0, 150, 20000); return new MessagesComposeInfo(0, 0, 150, 20000);
} }
} }

View File

@ -908,4 +908,5 @@
<string name="settings_about_discord_text">Serwer Discord</string> <string name="settings_about_discord_text">Serwer Discord</string>
<string name="settings_about_discord_subtext">Dołącz do naszego serwera Discord!</string> <string name="settings_about_discord_subtext">Dołącz do naszego serwera Discord!</string>
<string name="menu_debug">Debugowanie</string> <string name="menu_debug">Debugowanie</string>
<string name="sync_action_syncing_school_free_days">Pobieranie dni wolnych szkoły</string>
</resources> </resources>