-
-
Notifications
You must be signed in to change notification settings - Fork 1
Getting Started
RootAtKali edited this page Jun 7, 2020
·
1 revision
This is a simple guide to help you get started with MashovAPI. It is written in Java, but any JVM language can be used.
MashovAPI is available on Bintray's jcenter repo. You can find the current version by looking in the main page.
First, import the following packages:
import de.faceco.mashovapi.*;
import de.faceco.mashovapi.components.*;Then, you can initialize your API:
API api = API.getInstance(); // The Mashov API is a singleton object.After initialization, you should select a school. If you know your school ID, use:
int schoolId = 000000;
api.fetchSchool(schoolId);Or alternatively, you can get the entire list of schools and select one on your own:
School[] schools = api.getAllSchools();
// ...
api.setSchool(schools[i]);Now you can log in using your credentials:
int year = 2020;
String user = "username";
String pass = "password";
LoginResponse lr = api.login(year, user, pass);
LoginInfo li;
if (lr instanceof LoginInfo) {
li = (LoginInfo) lr;
} else {
LoginFailed fail = (LoginFailed) lr;
System.out.println(fail.getErrorCode());
}