-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
cc59ba2
commit 556516e
Showing
10 changed files
with
240 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
import { Day, HomeworkResult, RawHomeworkResult, RawTimetableResult, Week } from "../types/result.js"; | ||
import { RawHomeworkParams, RawTimetableParams } from "../types/params.js"; | ||
/** | ||
* Class for interaction with the Edulink API | ||
*/ | ||
export declare class Edulink { | ||
/** | ||
* a variable representing if the user has authenticated | ||
* @type {boolean} | ||
*/ | ||
isAuthenticated: boolean; | ||
/** | ||
* the part of the web address which goes before .edulinkone.com | ||
* @type {string} | ||
*/ | ||
readonly schoolId: string; | ||
/** | ||
* the auth token given by edulink allowing for interactions. generated on class creation | ||
* @type {string} | ||
*/ | ||
authToken: string; | ||
/** | ||
* the name used to identify the user in the edulink backend | ||
* @type {string} | ||
*/ | ||
learner_id: string; | ||
private authParams; | ||
/** | ||
* Create an instance of the edulink API helper. | ||
* @param {string} schoolId - the part of the web address which goes before .edulinkone.com | ||
* @param {string} username - the username used to log in to edulink | ||
* @param {string} password - the password used to log in to edulink | ||
* @param {number} establishment_id - unknown usage but cannot log in without it | ||
*/ | ||
constructor(schoolId: string, username: string, password: string, establishment_id: number); | ||
/** | ||
* Send a request to the edulink API | ||
* @param {Params} params - the edulink action and any data being sent in the http request body | ||
* @private | ||
*/ | ||
private request; | ||
/** | ||
* Used to log in to edulink allowing the api to be used. | ||
* @private | ||
*/ | ||
Authenticate(): Promise<void>; | ||
/** | ||
* gets the raw edulink API timetable data | ||
* @param {RawTimetableParams} params - takes in the current date and userid/learner_id | ||
* @return {RawTimetableResult} | ||
*/ | ||
getRawTimetable(params: RawTimetableParams): Promise<RawTimetableResult>; | ||
/** | ||
* gets the data for the week edulink classes as the 'current week' | ||
* @return {Week} | ||
*/ | ||
getThisWeek(): Promise<Week>; | ||
/** | ||
* gets the data for the day edulink classes as "today" | ||
* @return {Day} | ||
*/ | ||
getToday(): Promise<Day>; | ||
/** | ||
* gets the raw edulink API homework data | ||
* @param {RawHomeworkParams} params - not sure why, but it wants a number here | ||
* @return {RawHomeworkResult} | ||
*/ | ||
getRawHomework(params: RawHomeworkParams): Promise<RawHomeworkResult>; | ||
/** | ||
* gets the homework edulink calls current | ||
* @return {HomeworkResult} | ||
*/ | ||
getCurrentHomework(): Promise<HomeworkResult>; | ||
/** | ||
* gets the homework edulink calls past | ||
* @return {HomeworkResult} | ||
*/ | ||
getPastHomework(): Promise<HomeworkResult>; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
import { Edulink } from "./API/edulink.js"; | ||
import * as EdulinkTypes from "./types/types.js"; | ||
export { EdulinkTypes }; | ||
export { Edulink }; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export {}; |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
export interface Params { | ||
action?: string; | ||
data: {}; | ||
} | ||
export interface AuthParams extends Params { | ||
data: { | ||
establishment_id: number; | ||
fcm_token_old?: string; | ||
from_app?: boolean; | ||
password: string; | ||
ui_info?: { | ||
format: number; | ||
version: string; | ||
git_sha: string; | ||
}; | ||
username: string; | ||
}; | ||
} | ||
export interface RawTimetableParams extends Params { | ||
data: { | ||
date: string; | ||
learner_id: string; | ||
}; | ||
} | ||
export interface RawHomeworkParams extends Params { | ||
data: { | ||
format: number; | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,113 @@ | ||
export interface RawResult { | ||
id: string; | ||
jsonrpc: string; | ||
result: { | ||
success: boolean; | ||
error?: boolean; | ||
}; | ||
} | ||
export interface AuthResult extends RawResult { | ||
result: { | ||
analytics_enabled: Array<any>; | ||
api_version: number; | ||
authtoken: string; | ||
success: boolean; | ||
user: User; | ||
}; | ||
} | ||
export interface RawTimetableResult extends RawResult { | ||
result: { | ||
requested_date: string; | ||
showing_from: string; | ||
showing_to: string; | ||
success: boolean; | ||
weeks: Array<Week>; | ||
}; | ||
} | ||
export interface RawHomeworkResult extends RawResult { | ||
result: { | ||
homework: { | ||
current: Array<Homework>; | ||
past: Array<Homework>; | ||
}; | ||
success: boolean; | ||
}; | ||
} | ||
export type HomeworkResult = Array<Homework>; | ||
export interface User { | ||
community_group_id: string; | ||
establishment_id: string; | ||
forename: string; | ||
form_group_id: string; | ||
gender: string; | ||
remember_password_permitted: boolean; | ||
surname: string; | ||
types: Array<string>; | ||
username: string; | ||
year_group_id: string; | ||
id: string; | ||
} | ||
export interface Homework { | ||
activity: string; | ||
attachments: Array<any>; | ||
available_date: string; | ||
available_text: string; | ||
cloneable: boolean; | ||
completed: boolean; | ||
deletable: boolean; | ||
due_date: string; | ||
due_reminder: any; | ||
due_text: string; | ||
duration: any; | ||
employee_received: any; | ||
format: number; | ||
icon: string; | ||
id: string; | ||
owner_id: string; | ||
set_by: string; | ||
source: string; | ||
status: string; | ||
subject: string; | ||
user_type: string; | ||
} | ||
export interface Week { | ||
name: string; | ||
is_current: boolean; | ||
days: Array<Day>; | ||
} | ||
export interface Day { | ||
cycle_day_id: string; | ||
date: string; | ||
is_current: boolean; | ||
lessons: Array<Lesson>; | ||
name: string; | ||
original_name: string; | ||
periods: Array<Period>; | ||
} | ||
export interface Lesson { | ||
period_id: string; | ||
room: { | ||
id: string; | ||
moved: boolean; | ||
name: string; | ||
}; | ||
teacher: { | ||
forename: string; | ||
id: string; | ||
title: string; | ||
}; | ||
teachers: string; | ||
teaching_group: { | ||
id: string; | ||
name: string; | ||
subject: string; | ||
}; | ||
} | ||
export interface Period { | ||
empty: boolean; | ||
end_time: string; | ||
external_id: string; | ||
id: string; | ||
name: string; | ||
start_time: string; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
import * as ParamTypes from "./params.js"; | ||
import * as ResultTypes from "./result.js"; | ||
export { ParamTypes, ResultTypes }; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters