CompassApi 1.4.0

dotnet add package CompassApi --version 1.4.0                
NuGet\Install-Package CompassApi -Version 1.4.0                
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="CompassApi" Version="1.4.0" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add CompassApi --version 1.4.0                
#r "nuget: CompassApi, 1.4.0"                
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install CompassApi as a Cake Addin
#addin nuget:?package=CompassApi&version=1.4.0

// Install CompassApi as a Cake Tool
#tool nuget:?package=CompassApi&version=1.4.0                

Compass Education Library

Usage

Instantiate CompassClient:

CompassClient client = new CompassClient("<school prefix>");

Make sure that <school prefix> is the text at the start of the URL for your school.
For example, if you access Compass at https://myveryawesomeschool.compass.education/ then the school prefix is myveryawesomeschool.

If you want debugging for some reason then you can do this:

CompassClient client = new CompassClient("<school prefix>", LoggingFunction);

Where LoggingFunction is a function that takes a string and returns a Task. For example you might have this:

private static Task Log(string msg) {
    Console.WriteLine(msg);
    return Task.CompletedTask;
}

From there the next step is to call client.Authenticate(username, password) to log in to Compass. Authentication returns true if successful or false otherwise.

From there you can call any client methods to get relevant data.

Examples

Here are examples of all the methods that are available. Please not that you must call client.Authenticate(username, password) before hand and these examples may not cover every argument.

Print all the classes that the user has that day:

IEnumerable<CompassClass> classes = client.GetClasses().Result;
foreach (CompassClass compassClass in classes) {
    Console.WriteLine($"{compassClass.Room} {compassClass.Name} (Roll Marked: {compassClass.RollMarked}): {compassClass.StartTime.ToShortTimeString()} - {compassClass.EndTime.ToShortTimeString()}");
}

Print the last 5 news items:

IEnumerable<CompassNewsItem> news = client.GetNewsItems(limit: 5).Result;
foreach (CompassNewsItem compassNewsItem in news) {
    Console.WriteLine($"\n{compassNewsItem.Title} - {compassNewsItem.SenderUsername}\n" +
                      $"{compassNewsItem.PostDateTime.ToLongDateString()} (Attachments: {compassNewsItem.Attachments.Length}) (Priority: {compassNewsItem.Priority})\n");
}

Print user information:

CompassUser user = client.GetUserProfile().Result;

Console.WriteLine($"Name: {user.FullName}");
Console.WriteLine($"Email: {user.Email}");
Console.WriteLine($"ID: {user.Id}");
Console.WriteLine($"Year: {user.YearLevel}");
Console.WriteLine($"Home Group: {user.HomeGroup}");
Console.WriteLine($"School: {user.SchoolWebsite}");

Print user attendance information:

CompassUser user = client.GetUserProfile().Result;

foreach (CompassUserPresenceEntry presenceEntry in user.Presence) {
    Console.WriteLine(
        $"{presenceEntry.TimePeriodName} " +
        $"({presenceEntry.TimePeriodStart.ToShortTimeString()} - {presenceEntry.TimePeriodEnd.ToShortTimeString()}):" +
        $" {presenceEntry.Status} {presenceEntry.StatusName}");
}
Product Compatible and additional computed target framework versions.
.NET net6.0 is compatible.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 was computed.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
  • net6.0

    • No dependencies.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
1.4.0 361 12/14/2022
1.3.0 292 12/13/2022
1.2.0 295 12/13/2022
1.1.0 339 7/22/2022
1.0.0 330 7/22/2022