Package de.femtopedia.studip
Class StudIPAPI
java.lang.Object
de.femtopedia.studip.StudIPAPI
A simple-to-use API class to access the Stud.IP RestAPI.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionde.femtopedia.studip.shib.CustomAccessHttpResponsePerforms a HTTP GET Request.getAuthorizationUrl(String callback) Retrieves a Request Token and returns a authorization URL, which you have to open in a browser and approve access to your account.getContacts(String userID) Returns data about the searched user's contacts.Returns data about the searched course.getCourses(String userID) Returns data about the searched user's courses.getCourseTopFolder(String courseID) Returns the top folder object of the searched course.Returns the currently logged in user's data.<T> TPerforms a HTTP GET Request and converts the site's content into the given Object type usingGson.Returns data about the searched user's events.Returns the searched folder object for the given folder ID.de.femtopedia.studip.shib.OAuthClientReturns the currently usedOAuthClientinstance.getSchedule(String userID) Returns data about the currently logged in user's schedule.getSchedule(String userID, String semesterID) Returns data about the currently logged in user's schedule.getSemester(String semesterID) Returns data about the searched semester.Returns data about all semesters.getUserData(String userID) Returns data about the searched user.booleanReturns, whether the current session is valid or you need to re-login.voidverifyAccess(String verifyToken) Retrieves a working Access Token and saves it.
-
Constructor Details
-
StudIPAPI
Initializes a newStudIPAPIinstance.- Parameters:
consumerKey- The Consumer Key to useconsumerSecret- The Consumer Secret to use
-
-
Method Details
-
getAuthorizationUrl
Retrieves a Request Token and returns a authorization URL, which you have to open in a browser and approve access to your account. This is the first function to call in the OAuth process.- Parameters:
callback- A callback URI orOAuth.OUT_OF_BAND.- Returns:
- The Authorization URL to call
- Throws:
oauth.signpost.exception.OAuthException- if any OAuth errors occur
-
verifyAccess
Retrieves a working Access Token and saves it. This is the second function to call in the OAuth process (callgetAuthorizationUrl(String)first and authorize in a browser).- Parameters:
verifyToken- The Verification Code from the Authorization process.- Throws:
oauth.signpost.exception.OAuthException- if any OAuth errors occur
-
getOAuthClient
public de.femtopedia.studip.shib.OAuthClient getOAuthClient()Returns the currently usedOAuthClientinstance.- Returns:
- the currently used
OAuthClientinstance
-
isSessionValid
Returns, whether the current session is valid or you need to re-login.- Returns:
- true if and only if the current session is valid
- Throws:
IOException- if reading errors occuroauth.signpost.exception.OAuthException- if any OAuth errors occur
-
get
public de.femtopedia.studip.shib.CustomAccessHttpResponse get(String url) throws IOException, IllegalArgumentException, IllegalAccessException, oauth.signpost.exception.OAuthException Performs a HTTP GET Request.- Parameters:
url- The URL to get- Returns:
- A
CustomAccessHttpResponserepresenting the result - Throws:
IOException- if reading errors occurIllegalArgumentException- if the header values are brokenIllegalAccessException- if the session isn't validoauth.signpost.exception.OAuthException- if any OAuth errors occur
-
getData
public <T> T getData(String apiUrl, Class<T> objClass) throws IOException, IllegalArgumentException, IllegalAccessException, oauth.signpost.exception.OAuthException Performs a HTTP GET Request and converts the site's content into the given Object type usingGson.- Type Parameters:
T- The wanted Generic type- Parameters:
apiUrl- The URL to getobjClass- The class to cast to- Returns:
- the parsed and converted object
- Throws:
IOException- if reading errors occurIllegalArgumentException- if the header values are brokenIllegalAccessException- if the session isn't validoauth.signpost.exception.OAuthException- if any OAuth errors occur
-
getCurrentUserData
public User getCurrentUserData() throws IOException, IllegalArgumentException, IllegalAccessException, oauth.signpost.exception.OAuthExceptionReturns the currently logged in user's data.- Returns:
- the parsed and converted
Userobject - Throws:
IOException- if reading errors occurIllegalArgumentException- if the header values are brokenIllegalAccessException- if the session isn't validoauth.signpost.exception.OAuthException- if any OAuth errors occur
-
getUserData
public User getUserData(String userID) throws IOException, IllegalArgumentException, IllegalAccessException, oauth.signpost.exception.OAuthException Returns data about the searched user.- Parameters:
userID- The user to search for- Returns:
- the parsed and converted
Userobject - Throws:
IOException- if reading errors occurIllegalArgumentException- if the header values are brokenIllegalAccessException- if the session isn't validoauth.signpost.exception.OAuthException- if any OAuth errors occur
-
getContacts
public Contacts getContacts(String userID) throws IOException, IllegalArgumentException, IllegalAccessException, oauth.signpost.exception.OAuthException Returns data about the searched user's contacts.- Parameters:
userID- The user to search for- Returns:
- the parsed and converted
Contactsobject - Throws:
IOException- if reading errors occurIllegalArgumentException- if the header values are brokenIllegalAccessException- if the session isn't validoauth.signpost.exception.OAuthException- if any OAuth errors occur
-
getEvents
public Events getEvents(String userID) throws IOException, IllegalArgumentException, IllegalAccessException, oauth.signpost.exception.OAuthException Returns data about the searched user's events.- Parameters:
userID- The user to search for- Returns:
- the parsed and converted
Eventsobject - Throws:
IOException- if reading errors occurIllegalArgumentException- if the header values are brokenIllegalAccessException- if the session isn't validoauth.signpost.exception.OAuthException- if any OAuth errors occur
-
getCourse
public Course getCourse(String courseID) throws IOException, IllegalArgumentException, IllegalAccessException, oauth.signpost.exception.OAuthException Returns data about the searched course.- Parameters:
courseID- The course to search for- Returns:
- the parsed and converted
Courseobject - Throws:
IOException- if reading errors occurIllegalArgumentException- if the header values are brokenIllegalAccessException- if the session isn't validoauth.signpost.exception.OAuthException- if any OAuth errors occur
-
getCourses
public Courses getCourses(String userID) throws IOException, IllegalArgumentException, IllegalAccessException, oauth.signpost.exception.OAuthException Returns data about the searched user's courses.- Parameters:
userID- The user to search for- Returns:
- the parsed and converted
Coursesobject - Throws:
IOException- if reading errors occurIllegalArgumentException- if the header values are brokenIllegalAccessException- if the session isn't validoauth.signpost.exception.OAuthException- if any OAuth errors occur
-
getCourseTopFolder
public Folder getCourseTopFolder(String courseID) throws IOException, IllegalArgumentException, IllegalAccessException, oauth.signpost.exception.OAuthException Returns the top folder object of the searched course.- Parameters:
courseID- The course to search for- Returns:
- the parsed and converted
Folderobject - Throws:
IOException- if reading errors occurIllegalArgumentException- if the header values are brokenIllegalAccessException- if the session isn't validoauth.signpost.exception.OAuthException- if any OAuth errors occur
-
getFolder
public Folder getFolder(String folderID) throws IOException, IllegalArgumentException, IllegalAccessException, oauth.signpost.exception.OAuthException Returns the searched folder object for the given folder ID.- Parameters:
folderID- The folder to search for- Returns:
- the parsed and converted
Folderobject - Throws:
IOException- if reading errors occurIllegalArgumentException- if the header values are brokenIllegalAccessException- if the session isn't validoauth.signpost.exception.OAuthException- if any OAuth errors occur
-
getSemesters
public Semesters getSemesters() throws IOException, IllegalArgumentException, IllegalAccessException, oauth.signpost.exception.OAuthExceptionReturns data about all semesters.- Returns:
- the parsed and converted
Semestersobject - Throws:
IOException- if reading errors occurIllegalArgumentException- if the header values are brokenIllegalAccessException- if the session isn't validoauth.signpost.exception.OAuthException- if any OAuth errors occur
-
getSemester
public Semester getSemester(String semesterID) throws IOException, IllegalArgumentException, IllegalAccessException, oauth.signpost.exception.OAuthException Returns data about the searched semester.- Parameters:
semesterID- The semester to search for- Returns:
- the parsed and converted
Semesterobject - Throws:
IOException- if reading errors occurIllegalArgumentException- if the header values are brokenIllegalAccessException- if the session isn't validoauth.signpost.exception.OAuthException- if any OAuth errors occur
-
getSchedule
public Schedule getSchedule(String userID) throws IOException, IllegalArgumentException, IllegalAccessException, oauth.signpost.exception.OAuthException Returns data about the currently logged in user's schedule.- Parameters:
userID- The user to search for- Returns:
- the parsed and converted
Scheduleobject - Throws:
IOException- if reading errors occurIllegalArgumentException- if the header values are brokenIllegalAccessException- if the session isn't validoauth.signpost.exception.OAuthException- if any OAuth errors occur
-
getSchedule
public Schedule getSchedule(String userID, String semesterID) throws IOException, IllegalArgumentException, IllegalAccessException, oauth.signpost.exception.OAuthException Returns data about the currently logged in user's schedule.- Parameters:
userID- The user to search forsemesterID- The semester to search for- Returns:
- the parsed and converted
Scheduleobject - Throws:
IOException- if reading errors occurIllegalArgumentException- if the header values are brokenIllegalAccessException- if the session isn't validoauth.signpost.exception.OAuthException- if any OAuth errors occur
-