Package org.dnsge.powerschoolapi.client
Class DefaultPowerschoolClient
- java.lang.Object
-
- org.dnsge.powerschoolapi.client.DefaultPowerschoolClient
-
- All Implemented Interfaces:
PowerschoolClient
public final class DefaultPowerschoolClient extends java.lang.Object implements PowerschoolClient
Client to interface with a Powerschool Student Portal- Version:
- 1.0.3
-
-
Constructor Summary
Constructors Constructor Description DefaultPowerschoolClient(java.lang.String psInstallURL)
Constructor for new PowerschoolClient with a default UserAgent in the format of "powerschoolapi/{version identifier}"DefaultPowerschoolClient(java.lang.String psInstallURL, java.lang.String userAgent)
Constructor for new PowerschoolClient with a UserAgent
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description User
authenticate(java.lang.String username, java.lang.String password)
Logs in a user to a Powerschool Student Portalorg.jsoup.nodes.Document
getAs(User user, java.lang.String getUrl)
Preforms a GET request with the authentication cookies of aUser
objectjava.lang.String
getPsInstallURL()
void
refreshUser(User user)
Refreshes the information of a Userjava.lang.String
toString()
java.lang.String
urlify(java.lang.String extension)
Generates a complete URL from the base install url
-
-
-
Constructor Detail
-
DefaultPowerschoolClient
public DefaultPowerschoolClient(java.lang.String psInstallURL)
Constructor for new PowerschoolClient with a default UserAgent in the format of "powerschoolapi/{version identifier}"- Parameters:
psInstallURL
- Install URL of the Powerschool server
-
DefaultPowerschoolClient
public DefaultPowerschoolClient(java.lang.String psInstallURL, java.lang.String userAgent)
Constructor for new PowerschoolClient with a UserAgent- Parameters:
psInstallURL
- Install URL of the Powerschool serveruserAgent
- UserAgent to use in requests
-
-
Method Detail
-
urlify
public java.lang.String urlify(java.lang.String extension)
Generates a complete URL from the base install url- Specified by:
urlify
in interfacePowerschoolClient
- Parameters:
extension
- Extension of the base install url- Returns:
- Extended URL
-
authenticate
public User authenticate(java.lang.String username, java.lang.String password) throws java.io.IOException
Logs in a user to a Powerschool Student PortalReturns a new
User
object populated with course information- Specified by:
authenticate
in interfacePowerschoolClient
- Parameters:
username
- Username to login withpassword
- Password to login with- Returns:
User
object- Throws:
java.io.IOException
- if something goes wrong
-
refreshUser
public void refreshUser(User user) throws java.io.IOException
Refreshes the information of a User- Specified by:
refreshUser
in interfacePowerschoolClient
- Parameters:
user
- User to update- Throws:
java.io.IOException
- if something goes wrong
-
getAs
public org.jsoup.nodes.Document getAs(User user, java.lang.String getUrl)
Preforms a GET request with the authentication cookies of aUser
object- Specified by:
getAs
in interfacePowerschoolClient
- Parameters:
user
- User object to utilizegetUrl
- Non-URLified url to get- Returns:
Document
object from GET request- See Also:
Document
-
getPsInstallURL
public java.lang.String getPsInstallURL()
- Returns:
- Powerschool Install URL
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
- Returns:
- A
String
formatted like"PowerschoolClient ({psInstallURL})"
-
-