mirror of
https://github.com/classchartsapi/classcharts-api-js.git
synced 2026-05-14 11:58:13 +00:00
chore: typo fixes + config files
This commit is contained in:
parent
f11c7c564d
commit
00e3a13821
17 changed files with 124 additions and 16 deletions
|
|
@ -1,5 +1,5 @@
|
||||||
dist/
|
dist/
|
||||||
docs/
|
docs/
|
||||||
node_modules/
|
node_modules/
|
||||||
.eslintrc.js
|
.eslintrc.cjs
|
||||||
tsconfig.json
|
tsconfig.json
|
||||||
5
.idea/.gitignore
generated
vendored
Normal file
5
.idea/.gitignore
generated
vendored
Normal file
|
|
@ -0,0 +1,5 @@
|
||||||
|
# Default ignored files
|
||||||
|
/shelf/
|
||||||
|
/workspace.xml
|
||||||
|
# Editor-based HTTP Client requests
|
||||||
|
/httpRequests/
|
||||||
12
.idea/classcharts-api-js.iml
generated
Normal file
12
.idea/classcharts-api-js.iml
generated
Normal file
|
|
@ -0,0 +1,12 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<module type="WEB_MODULE" version="4">
|
||||||
|
<component name="NewModuleRootManager">
|
||||||
|
<content url="file://$MODULE_DIR$">
|
||||||
|
<excludeFolder url="file://$MODULE_DIR$/.tmp" />
|
||||||
|
<excludeFolder url="file://$MODULE_DIR$/temp" />
|
||||||
|
<excludeFolder url="file://$MODULE_DIR$/tmp" />
|
||||||
|
</content>
|
||||||
|
<orderEntry type="inheritedJdk" />
|
||||||
|
<orderEntry type="sourceFolder" forTests="false" />
|
||||||
|
</component>
|
||||||
|
</module>
|
||||||
58
.idea/codeStyles/Project.xml
generated
Normal file
58
.idea/codeStyles/Project.xml
generated
Normal file
|
|
@ -0,0 +1,58 @@
|
||||||
|
<component name="ProjectCodeStyleConfiguration">
|
||||||
|
<code_scheme name="Project" version="173">
|
||||||
|
<HTMLCodeStyleSettings>
|
||||||
|
<option name="HTML_SPACE_INSIDE_EMPTY_TAG" value="true" />
|
||||||
|
<option name="HTML_ENFORCE_QUOTES" value="true" />
|
||||||
|
</HTMLCodeStyleSettings>
|
||||||
|
<JSCodeStyleSettings version="0">
|
||||||
|
<option name="FORCE_SEMICOLON_STYLE" value="true" />
|
||||||
|
<option name="SPACE_BEFORE_FUNCTION_LEFT_PARENTH" value="false" />
|
||||||
|
<option name="FORCE_QUOTE_STYlE" value="true" />
|
||||||
|
<option name="ENFORCE_TRAILING_COMMA" value="Remove" />
|
||||||
|
<option name="SPACES_WITHIN_OBJECT_LITERAL_BRACES" value="true" />
|
||||||
|
<option name="SPACES_WITHIN_IMPORTS" value="true" />
|
||||||
|
</JSCodeStyleSettings>
|
||||||
|
<TypeScriptCodeStyleSettings version="0">
|
||||||
|
<option name="FORCE_SEMICOLON_STYLE" value="true" />
|
||||||
|
<option name="SPACE_BEFORE_FUNCTION_LEFT_PARENTH" value="false" />
|
||||||
|
<option name="FORCE_QUOTE_STYlE" value="true" />
|
||||||
|
<option name="ENFORCE_TRAILING_COMMA" value="Remove" />
|
||||||
|
<option name="SPACES_WITHIN_OBJECT_LITERAL_BRACES" value="true" />
|
||||||
|
<option name="SPACES_WITHIN_IMPORTS" value="true" />
|
||||||
|
</TypeScriptCodeStyleSettings>
|
||||||
|
<VueCodeStyleSettings>
|
||||||
|
<option name="INTERPOLATION_NEW_LINE_AFTER_START_DELIMITER" value="false" />
|
||||||
|
<option name="INTERPOLATION_NEW_LINE_BEFORE_END_DELIMITER" value="false" />
|
||||||
|
</VueCodeStyleSettings>
|
||||||
|
<codeStyleSettings language="HTML">
|
||||||
|
<option name="SOFT_MARGINS" value="80" />
|
||||||
|
<indentOptions>
|
||||||
|
<option name="INDENT_SIZE" value="2" />
|
||||||
|
<option name="CONTINUATION_INDENT_SIZE" value="2" />
|
||||||
|
<option name="TAB_SIZE" value="2" />
|
||||||
|
</indentOptions>
|
||||||
|
</codeStyleSettings>
|
||||||
|
<codeStyleSettings language="JavaScript">
|
||||||
|
<option name="SOFT_MARGINS" value="80" />
|
||||||
|
<indentOptions>
|
||||||
|
<option name="INDENT_SIZE" value="2" />
|
||||||
|
<option name="CONTINUATION_INDENT_SIZE" value="2" />
|
||||||
|
<option name="TAB_SIZE" value="2" />
|
||||||
|
</indentOptions>
|
||||||
|
</codeStyleSettings>
|
||||||
|
<codeStyleSettings language="TypeScript">
|
||||||
|
<option name="SOFT_MARGINS" value="80" />
|
||||||
|
<indentOptions>
|
||||||
|
<option name="INDENT_SIZE" value="2" />
|
||||||
|
<option name="CONTINUATION_INDENT_SIZE" value="2" />
|
||||||
|
<option name="TAB_SIZE" value="2" />
|
||||||
|
</indentOptions>
|
||||||
|
</codeStyleSettings>
|
||||||
|
<codeStyleSettings language="Vue">
|
||||||
|
<option name="SOFT_MARGINS" value="80" />
|
||||||
|
<indentOptions>
|
||||||
|
<option name="CONTINUATION_INDENT_SIZE" value="2" />
|
||||||
|
</indentOptions>
|
||||||
|
</codeStyleSettings>
|
||||||
|
</code_scheme>
|
||||||
|
</component>
|
||||||
5
.idea/codeStyles/codeStyleConfig.xml
generated
Normal file
5
.idea/codeStyles/codeStyleConfig.xml
generated
Normal file
|
|
@ -0,0 +1,5 @@
|
||||||
|
<component name="ProjectCodeStyleConfiguration">
|
||||||
|
<state>
|
||||||
|
<option name="USE_PER_PROJECT_SETTINGS" value="true" />
|
||||||
|
</state>
|
||||||
|
</component>
|
||||||
6
.idea/inspectionProfiles/Project_Default.xml
generated
Normal file
6
.idea/inspectionProfiles/Project_Default.xml
generated
Normal file
|
|
@ -0,0 +1,6 @@
|
||||||
|
<component name="InspectionProjectProfileManager">
|
||||||
|
<profile version="1.0">
|
||||||
|
<option name="myName" value="Project Default" />
|
||||||
|
<inspection_tool class="Eslint" enabled="true" level="WARNING" enabled_by_default="true" />
|
||||||
|
</profile>
|
||||||
|
</component>
|
||||||
8
.idea/modules.xml
generated
Normal file
8
.idea/modules.xml
generated
Normal file
|
|
@ -0,0 +1,8 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project version="4">
|
||||||
|
<component name="ProjectModuleManager">
|
||||||
|
<modules>
|
||||||
|
<module fileurl="file://$PROJECT_DIR$/.idea/classcharts-api-js.iml" filepath="$PROJECT_DIR$/.idea/classcharts-api-js.iml" />
|
||||||
|
</modules>
|
||||||
|
</component>
|
||||||
|
</project>
|
||||||
6
.idea/prettier.xml
generated
Normal file
6
.idea/prettier.xml
generated
Normal file
|
|
@ -0,0 +1,6 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project version="4">
|
||||||
|
<component name="PrettierConfiguration">
|
||||||
|
<option name="myConfigurationMode" value="AUTOMATIC" />
|
||||||
|
</component>
|
||||||
|
</project>
|
||||||
6
.idea/vcs.xml
generated
Normal file
6
.idea/vcs.xml
generated
Normal file
|
|
@ -0,0 +1,6 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project version="4">
|
||||||
|
<component name="VcsDirectoryMappings">
|
||||||
|
<mapping directory="" vcs="Git" />
|
||||||
|
</component>
|
||||||
|
</project>
|
||||||
|
|
@ -2,7 +2,7 @@
|
||||||
<html lang="en">
|
<html lang="en">
|
||||||
<head>
|
<head>
|
||||||
<meta charset="UTF-8" />
|
<meta charset="UTF-8" />
|
||||||
<title>Classcharts-API</title>
|
<title>ClassCharts-API</title>
|
||||||
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />
|
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />
|
||||||
<!-- <meta name="description" content="Description"> -->
|
<!-- <meta name="description" content="Description"> -->
|
||||||
<meta
|
<meta
|
||||||
|
|
|
||||||
|
|
@ -7,7 +7,7 @@
|
||||||
"name": "James Cook",
|
"name": "James Cook",
|
||||||
"email": "james@jaminit.co.uk"
|
"email": "james@jaminit.co.uk"
|
||||||
},
|
},
|
||||||
"description": "A Typescript wrapper for getting information from the Classcharts API",
|
"description": "A Typescript wrapper for getting information from the ClassCharts API",
|
||||||
"keywords": [
|
"keywords": [
|
||||||
"node",
|
"node",
|
||||||
"typescript",
|
"typescript",
|
||||||
|
|
|
||||||
|
|
@ -42,13 +42,13 @@ export class BaseClient {
|
||||||
*/
|
*/
|
||||||
public lastPing = 0;
|
public lastPing = 0;
|
||||||
/**
|
/**
|
||||||
* @property API_BASE Base API URL, this is different depending if its called as a parent or student
|
* @property API_BASE Base API URL, this is different depending on if its called as a parent or student
|
||||||
* @internal
|
* @internal
|
||||||
*/
|
*/
|
||||||
protected API_BASE = "";
|
protected API_BASE = "";
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @param API_BASE Base API URL, this is different depending if its called as a parent or student
|
* @param API_BASE Base API URL, this is different depending on if its called as a parent or student
|
||||||
*/
|
*/
|
||||||
constructor(API_BASE: string) {
|
constructor(API_BASE: string) {
|
||||||
this.authCookies = [];
|
this.authCookies = [];
|
||||||
|
|
@ -57,7 +57,7 @@ export class BaseClient {
|
||||||
/**
|
/**
|
||||||
* Revalidates the session ID.
|
* Revalidates the session ID.
|
||||||
*
|
*
|
||||||
* This is called automatically when the session ID is older than 3 minutes or when intially using the .login() method
|
* This is called automatically when the session ID is older than 3 minutes or when initially using the .login() method
|
||||||
* @internal
|
* @internal
|
||||||
*/
|
*/
|
||||||
public async getNewSessionId() {
|
public async getNewSessionId() {
|
||||||
|
|
@ -75,7 +75,7 @@ export class BaseClient {
|
||||||
this.lastPing = Date.now();
|
this.lastPing = Date.now();
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* Makes a request to the Classcharts API with the required authentication headers
|
* Makes a request to the ClassCharts API with the required authentication headers
|
||||||
*
|
*
|
||||||
* @param path Path to the API endpoint
|
* @param path Path to the API endpoint
|
||||||
* @param kyOptions Ky (fetch library) request options
|
* @param kyOptions Ky (fetch library) request options
|
||||||
|
|
|
||||||
|
|
@ -24,7 +24,7 @@ export class ParentClient extends BaseClient {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Authenticates with classcharts
|
* Authenticates with ClassCharts
|
||||||
*/
|
*/
|
||||||
async login(): Promise<void> {
|
async login(): Promise<void> {
|
||||||
if (!this.email) throw new Error("Email not inputted");
|
if (!this.email) throw new Error("Email not inputted");
|
||||||
|
|
@ -33,7 +33,7 @@ export class ParentClient extends BaseClient {
|
||||||
formData.append("email", this.email);
|
formData.append("email", this.email);
|
||||||
formData.append("logintype", "existing");
|
formData.append("logintype", "existing");
|
||||||
formData.append("password", this.password);
|
formData.append("password", this.password);
|
||||||
formData.append("recaptcha-token", "no-token-avaliable");
|
formData.append("recaptcha-token", "no-token-available");
|
||||||
const headers = new Headers({
|
const headers = new Headers({
|
||||||
"Content-Type": "application/x-www-form-urlencoded",
|
"Content-Type": "application/x-www-form-urlencoded",
|
||||||
});
|
});
|
||||||
|
|
@ -45,7 +45,7 @@ export class ParentClient extends BaseClient {
|
||||||
});
|
});
|
||||||
if (response.status != 302 || !response.headers.get("set-cookie"))
|
if (response.status != 302 || !response.headers.get("set-cookie"))
|
||||||
throw new Error(
|
throw new Error(
|
||||||
"Unauthenticated: Classcharts returned an error: " +
|
"Unauthenticated: ClassCharts returned an error: " +
|
||||||
response.status +
|
response.status +
|
||||||
" " +
|
" " +
|
||||||
response.statusText
|
response.statusText
|
||||||
|
|
|
||||||
|
|
@ -8,7 +8,7 @@ import ky from "ky-universal";
|
||||||
*/
|
*/
|
||||||
export class StudentClient extends BaseClient {
|
export class StudentClient extends BaseClient {
|
||||||
/**
|
/**
|
||||||
* @property studentCode Classcharts student code
|
* @property studentCode ClassCharts student code
|
||||||
* @internal
|
* @internal
|
||||||
*/
|
*/
|
||||||
private studentCode = "";
|
private studentCode = "";
|
||||||
|
|
@ -20,7 +20,7 @@ export class StudentClient extends BaseClient {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @param studentCode Classcharts student code
|
* @param studentCode ClassCharts student code
|
||||||
* @param dateOfBirth Student's date of birth
|
* @param dateOfBirth Student's date of birth
|
||||||
*/
|
*/
|
||||||
constructor(studentCode: string, dateOfBirth?: string) {
|
constructor(studentCode: string, dateOfBirth?: string) {
|
||||||
|
|
@ -30,7 +30,7 @@ export class StudentClient extends BaseClient {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Authenticates with classcharts
|
* Authenticates with ClassCharts
|
||||||
*/
|
*/
|
||||||
async login(): Promise<void> {
|
async login(): Promise<void> {
|
||||||
if (!this.studentCode) throw new Error("Student Code not inputted");
|
if (!this.studentCode) throw new Error("Student Code not inputted");
|
||||||
|
|
@ -39,7 +39,7 @@ export class StudentClient extends BaseClient {
|
||||||
formData.append("code", this.studentCode.toUpperCase());
|
formData.append("code", this.studentCode.toUpperCase());
|
||||||
formData.append("dob", this.dateOfBirth);
|
formData.append("dob", this.dateOfBirth);
|
||||||
formData.append("remember_me", "1");
|
formData.append("remember_me", "1");
|
||||||
formData.append("recaptcha-token", "no-token-avaliable");
|
formData.append("recaptcha-token", "no-token-available");
|
||||||
const request = await ky(BASE_URL + "/student/login", {
|
const request = await ky(BASE_URL + "/student/login", {
|
||||||
method: "POST",
|
method: "POST",
|
||||||
body: formData,
|
body: formData,
|
||||||
|
|
@ -49,7 +49,7 @@ export class StudentClient extends BaseClient {
|
||||||
});
|
});
|
||||||
if (request.status != 302 || !request.headers.get("set-cookie")) {
|
if (request.status != 302 || !request.headers.get("set-cookie")) {
|
||||||
throw new Error(
|
throw new Error(
|
||||||
"Unauthenticated: Classcharts returned an error: " +
|
"Unauthenticated: ClassCharts returned an error: " +
|
||||||
request.status +
|
request.status +
|
||||||
" " +
|
" " +
|
||||||
request.statusText
|
request.statusText
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,6 @@
|
||||||
import { StudentClient } from "../src";
|
import { StudentClient } from "../src";
|
||||||
|
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
||||||
|
// @ts-ignore
|
||||||
import { code, dob } from "./config.json";
|
import { code, dob } from "./config.json";
|
||||||
import "jest-extended";
|
import "jest-extended";
|
||||||
const client = new StudentClient(code, dob);
|
const client = new StudentClient(code, dob);
|
||||||
|
|
|
||||||
|
|
@ -16,7 +16,7 @@
|
||||||
"noUnusedLocals": true,
|
"noUnusedLocals": true,
|
||||||
"noUnusedParameters": true,
|
"noUnusedParameters": true,
|
||||||
"skipLibCheck": true,
|
"skipLibCheck": true,
|
||||||
"isolatedModules": true
|
"isolatedModules": true,
|
||||||
},
|
},
|
||||||
"include": ["./src/**/*"]
|
"include": ["./src/**/*"]
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue