Class 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 Portal
      org.jsoup.nodes.Document getAs​(User user, java.lang.String getUrl)
      Preforms a GET request with the authentication cookies of a User object
      java.lang.String getPsInstallURL()  
      void refreshUser​(User user)
      Refreshes the information of a User
      java.lang.String toString()  
      java.lang.String urlify​(java.lang.String extension)
      Generates a complete URL from the base install url
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
    • 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 server
        userAgent - 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 interface PowerschoolClient
        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 Portal

        Returns a new User object populated with course information

        Specified by:
        authenticate in interface PowerschoolClient
        Parameters:
        username - Username to login with
        password - 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 interface PowerschoolClient
        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 a User object
        Specified by:
        getAs in interface PowerschoolClient
        Parameters:
        user - User object to utilize
        getUrl - 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 class java.lang.Object
        Returns:
        A String formatted like "PowerschoolClient ({psInstallURL})"