From 0f8f0a5027160c0a1643dbb12ca016d659fcb046 Mon Sep 17 00:00:00 2001 From: James Cook Date: Tue, 23 Nov 2021 22:23:23 +0000 Subject: [PATCH] feat: i know how to use optional arguments --- .npmignore | 1 - docs/assets/highlight.css | 49 +++++++++++++++++++ docs/classes/client.ClasschartsClient.html | 26 +++++----- docs/index.html | 7 +++ docs/interfaces/types.ActivityResponse.html | 2 +- .../types.ActivityTimelinePoint.html | 2 +- docs/interfaces/types.BehaviourPoint.html | 2 +- docs/interfaces/types.GetActivityOptions.html | 2 +- .../interfaces/types.GetBehaviourOptions.html | 2 +- docs/interfaces/types.GetHomeworkOptions.html | 2 +- docs/interfaces/types.GetLessonsOptions.html | 2 +- docs/interfaces/types.Homework.html | 2 +- docs/interfaces/types.Lesson.html | 2 +- docs/interfaces/types.Student.html | 2 +- docs/modules/api.html | 2 +- docs/modules/consts.html | 2 +- docs/modules/types.html | 2 +- package.json | 8 +-- src/api.ts | 18 +++---- src/client.ts | 10 ++-- src/release.ts | 29 ----------- src/tests/test.ts | 8 +-- src/types.d.ts | 10 ++-- 23 files changed, 110 insertions(+), 82 deletions(-) delete mode 100644 .npmignore delete mode 100644 src/release.ts diff --git a/.npmignore b/.npmignore deleted file mode 100644 index d34eb4f..0000000 --- a/.npmignore +++ /dev/null @@ -1 +0,0 @@ -release.js \ No newline at end of file diff --git a/docs/assets/highlight.css b/docs/assets/highlight.css index a13094d..15a6593 100644 --- a/docs/assets/highlight.css +++ b/docs/assets/highlight.css @@ -1,22 +1,71 @@ :root { + --light-hl-0: #AF00DB; + --dark-hl-0: #C586C0; + --light-hl-1: #000000; + --dark-hl-1: #D4D4D4; + --light-hl-2: #001080; + --dark-hl-2: #9CDCFE; + --light-hl-3: #A31515; + --dark-hl-3: #CE9178; + --light-hl-4: #0000FF; + --dark-hl-4: #569CD6; + --light-hl-5: #795E26; + --dark-hl-5: #DCDCAA; + --light-hl-6: #0070C1; + --dark-hl-6: #4FC1FF; --light-code-background: #FFFFFF; --dark-code-background: #1E1E1E; } @media (prefers-color-scheme: light) { :root { + --hl-0: var(--light-hl-0); + --hl-1: var(--light-hl-1); + --hl-2: var(--light-hl-2); + --hl-3: var(--light-hl-3); + --hl-4: var(--light-hl-4); + --hl-5: var(--light-hl-5); + --hl-6: var(--light-hl-6); --code-background: var(--light-code-background); } } @media (prefers-color-scheme: dark) { :root { + --hl-0: var(--dark-hl-0); + --hl-1: var(--dark-hl-1); + --hl-2: var(--dark-hl-2); + --hl-3: var(--dark-hl-3); + --hl-4: var(--dark-hl-4); + --hl-5: var(--dark-hl-5); + --hl-6: var(--dark-hl-6); --code-background: var(--dark-code-background); } } body.light { + --hl-0: var(--light-hl-0); + --hl-1: var(--light-hl-1); + --hl-2: var(--light-hl-2); + --hl-3: var(--light-hl-3); + --hl-4: var(--light-hl-4); + --hl-5: var(--light-hl-5); + --hl-6: var(--light-hl-6); --code-background: var(--light-code-background); } body.dark { + --hl-0: var(--dark-hl-0); + --hl-1: var(--dark-hl-1); + --hl-2: var(--dark-hl-2); + --hl-3: var(--dark-hl-3); + --hl-4: var(--dark-hl-4); + --hl-5: var(--dark-hl-5); + --hl-6: var(--dark-hl-6); --code-background: var(--dark-code-background); } +.hl-0 { color: var(--hl-0); } +.hl-1 { color: var(--hl-1); } +.hl-2 { color: var(--hl-2); } +.hl-3 { color: var(--hl-3); } +.hl-4 { color: var(--hl-4); } +.hl-5 { color: var(--hl-5); } +.hl-6 { color: var(--hl-6); } pre, code { background: var(--code-background); } diff --git a/docs/classes/client.ClasschartsClient.html b/docs/classes/client.ClasschartsClient.html index e325905..f8bc9d6 100644 --- a/docs/classes/client.ClasschartsClient.html +++ b/docs/classes/client.ClasschartsClient.html @@ -1,32 +1,32 @@ ClasschartsClient | classcharts-api
Options
All
  • Public
  • Public/Protected
  • All
Menu

The base client

-

Hierarchy

  • ClasschartsClient

Index

Constructors

constructor

  • new ClasschartsClient(studentCode: string, dateOfBirth: null | string): ClasschartsClient

Hierarchy

  • ClasschartsClient

Index

Constructors

constructor

  • Parameters

    • studentCode: string

      Classcharts student code

      -
    • dateOfBirth: null | string
      +
    • Optional dateOfBirth: string

      Student's date of birth

      -

    Returns ClasschartsClient

Properties

Private authCookies

authCookies: undefined | string[]

dateOfBirth

dateOfBirth: string = ''

Private sessionId

sessionId: string = ''

studentCode

studentCode: string = ''

studentId

studentId: number = 0

studentName

studentName: string = ''

Methods

getActivity

Returns ClasschartsClient

Properties

Private authCookies

authCookies: undefined | string[]

dateOfBirth

dateOfBirth: string = ''

Private sessionId

sessionId: string = ''

studentCode

studentCode: string = ''

studentId

studentId: number = 0

studentName

studentName: string = ''

Methods

getActivity

getBehaviour

getBehaviour

getLessons

getLessons

getStudentInfo

getStudentInfo

  • Gets general information about the logged in student

    Returns Promise<Student>

    Student object

    -

init

  • init(): Promise<void>

init

  • init(): Promise<void>
  • Initialises the client and authenticates with classcharts

    -

    Returns Promise<void>

listHomeworks

listHomeworks

Private makeAuthedRequest

  • makeAuthedRequest(path: string, options: Omit<RequestOptions, "origin" | "path">): Promise<any>
  • Parameters

    • path: string
    • options: Omit<RequestOptions, "origin" | "path">

    Returns Promise<any>

Generated using TypeDoc

\ No newline at end of file +

Private makeAuthedRequest

Generated using TypeDoc

\ No newline at end of file diff --git a/docs/index.html b/docs/index.html index e5d006f..72dfca2 100644 --- a/docs/index.html +++ b/docs/index.html @@ -3,4 +3,11 @@

Classcharts API

A very WIP client for the classcharts API

+

Documentation

+ + +

Examples

+
+
import { ClasschartsClient } from 'classcharts-api'
async function main() {
const client = new ClasschartsClient('classchartsCode', '01/1/2000')
await client.init()
console.log(
await client.getBehaviour({
displayDate: 'due_date',
fromDate: '20/01/2000',
toDate: '01/02/2000',
})
)
console.log(await client.getActivity(null))
console.log(await client.getStudentInfo())
console.log(await client.getActivity(null))
console.log(await client.getActivity(null))
}

main() +

Generated using TypeDoc

\ No newline at end of file diff --git a/docs/interfaces/types.ActivityResponse.html b/docs/interfaces/types.ActivityResponse.html index 45e5b86..aa5dc19 100644 --- a/docs/interfaces/types.ActivityResponse.html +++ b/docs/interfaces/types.ActivityResponse.html @@ -1 +1 @@ -ActivityResponse | classcharts-api
Options
All
  • Public
  • Public/Protected
  • All
Menu

Interface ActivityResponse

Hierarchy

  • ActivityResponse

Index

Properties

negative_reasons

negative_reasons: Record<string, string>

other_negative

other_negative: any[]

other_negative_count

other_negative_count: any[]

other_positive

other_positive: any[]

other_positive_count

other_positive_count: any[]

positiveReasons

positiveReasons: Record<string, string>

timeline

Generated using TypeDoc

\ No newline at end of file +ActivityResponse | classcharts-api
Options
All
  • Public
  • Public/Protected
  • All
Menu

Interface ActivityResponse

Hierarchy

  • ActivityResponse

Index

Properties

negative_reasons

negative_reasons: Record<string, string>

other_negative

other_negative: any[]

other_negative_count

other_negative_count: any[]

other_positive

other_positive: any[]

other_positive_count

other_positive_count: any[]

positiveReasons

positiveReasons: Record<string, string>

timeline

Generated using TypeDoc

\ No newline at end of file diff --git a/docs/interfaces/types.ActivityTimelinePoint.html b/docs/interfaces/types.ActivityTimelinePoint.html index cb60f45..b7d732f 100644 --- a/docs/interfaces/types.ActivityTimelinePoint.html +++ b/docs/interfaces/types.ActivityTimelinePoint.html @@ -1 +1 @@ -ActivityTimelinePoint | classcharts-api
Options
All
  • Public
  • Public/Protected
  • All
Menu

Interface ActivityTimelinePoint

Hierarchy

  • ActivityTimelinePoint

Index

Properties

end

end: string

name

name: string

negative

negative: number

positive

positive: number

start

start: string

Generated using TypeDoc

\ No newline at end of file +ActivityTimelinePoint | classcharts-api
Options
All
  • Public
  • Public/Protected
  • All
Menu

Interface ActivityTimelinePoint

Hierarchy

  • ActivityTimelinePoint

Index

Properties

end

end: string

name

name: string

negative

negative: number

positive

positive: number

start

start: string

Generated using TypeDoc

\ No newline at end of file diff --git a/docs/interfaces/types.BehaviourPoint.html b/docs/interfaces/types.BehaviourPoint.html index 914ee1c..e27de60 100644 --- a/docs/interfaces/types.BehaviourPoint.html +++ b/docs/interfaces/types.BehaviourPoint.html @@ -1 +1 @@ -BehaviourPoint | classcharts-api
Options
All
  • Public
  • Public/Protected
  • All
Menu

Interface BehaviourPoint

Hierarchy

  • BehaviourPoint

Index

Properties

_can_delete

_can_delete: string

detention_date

detention_date: null | string

detention_location

detention_location: null | string

detention_time

detention_time: null | string

detention_type

detention_type: null | string

id

id: number

lesson_name

lesson_name: string

note

note: string

polarity

polarity: string

pupil_name

pupil_name: string

reason

reason: string

room_name

room_name: null | string

score

score: number

style

style: { border_color: null | string; custom_class: null | string }

Type declaration

  • border_color: null | string
  • custom_class: null | string

teacher_name

teacher_name: string

timestamp

timestamp: string

timestamp_custom_time

timestamp_custom_time: null | string

type

type: string

Generated using TypeDoc

\ No newline at end of file +BehaviourPoint | classcharts-api
Options
All
  • Public
  • Public/Protected
  • All
Menu

Interface BehaviourPoint

Hierarchy

  • BehaviourPoint

Index

Properties

_can_delete

_can_delete: string

detention_date

detention_date: null | string

detention_location

detention_location: null | string

detention_time

detention_time: null | string

detention_type

detention_type: null | string

id

id: number

lesson_name

lesson_name: string

note

note: string

polarity

polarity: string

pupil_name

pupil_name: string

reason

reason: string

room_name

room_name: null | string

score

score: number

style

style: { border_color: null | string; custom_class: null | string }

Type declaration

  • border_color: null | string
  • custom_class: null | string

teacher_name

teacher_name: string

timestamp

timestamp: string

timestamp_custom_time

timestamp_custom_time: null | string

type

type: string

Generated using TypeDoc

\ No newline at end of file diff --git a/docs/interfaces/types.GetActivityOptions.html b/docs/interfaces/types.GetActivityOptions.html index ffddbac..28801cc 100644 --- a/docs/interfaces/types.GetActivityOptions.html +++ b/docs/interfaces/types.GetActivityOptions.html @@ -1 +1 @@ -GetActivityOptions | classcharts-api
Options
All
  • Public
  • Public/Protected
  • All
Menu

Interface GetActivityOptions

Hierarchy

  • GetActivityOptions

Index

Properties

Properties

from

from: undefined | string

to

to: undefined | string

Generated using TypeDoc

\ No newline at end of file +GetActivityOptions | classcharts-api
Options
All
  • Public
  • Public/Protected
  • All
Menu

Interface GetActivityOptions

Hierarchy

  • GetActivityOptions

Index

Properties

Properties

Optional from

from?: string

Optional to

to?: string

Generated using TypeDoc

\ No newline at end of file diff --git a/docs/interfaces/types.GetBehaviourOptions.html b/docs/interfaces/types.GetBehaviourOptions.html index a5d52fd..97ca422 100644 --- a/docs/interfaces/types.GetBehaviourOptions.html +++ b/docs/interfaces/types.GetBehaviourOptions.html @@ -1 +1 @@ -GetBehaviourOptions | classcharts-api
Options
All
  • Public
  • Public/Protected
  • All
Menu

Interface GetBehaviourOptions

Hierarchy

  • GetBehaviourOptions

Index

Properties

Properties

from

from: undefined | string

last_id

last_id: undefined | string

to

to: undefined | string

Generated using TypeDoc

\ No newline at end of file +GetBehaviourOptions | classcharts-api
Options
All
  • Public
  • Public/Protected
  • All
Menu

Interface GetBehaviourOptions

Hierarchy

  • GetBehaviourOptions

Index

Properties

Properties

Optional from

from?: string

Optional last_id

last_id?: string

Optional to

to?: string

Generated using TypeDoc

\ No newline at end of file diff --git a/docs/interfaces/types.GetHomeworkOptions.html b/docs/interfaces/types.GetHomeworkOptions.html index 5b72060..7fe094a 100644 --- a/docs/interfaces/types.GetHomeworkOptions.html +++ b/docs/interfaces/types.GetHomeworkOptions.html @@ -1 +1 @@ -GetHomeworkOptions | classcharts-api
Options
All
  • Public
  • Public/Protected
  • All
Menu

Interface GetHomeworkOptions

Hierarchy

  • GetHomeworkOptions

Index

Properties

displayDate

displayDate: DisplayDate

fromDate

fromDate: string

toDate

toDate: string

Generated using TypeDoc

\ No newline at end of file +GetHomeworkOptions | classcharts-api
Options
All
  • Public
  • Public/Protected
  • All
Menu

Interface GetHomeworkOptions

Hierarchy

  • GetHomeworkOptions

Index

Properties

displayDate

displayDate: DisplayDate

fromDate

fromDate: string

toDate

toDate: string

Generated using TypeDoc

\ No newline at end of file diff --git a/docs/interfaces/types.GetLessonsOptions.html b/docs/interfaces/types.GetLessonsOptions.html index 2cfc58f..944c380 100644 --- a/docs/interfaces/types.GetLessonsOptions.html +++ b/docs/interfaces/types.GetLessonsOptions.html @@ -1 +1 @@ -GetLessonsOptions | classcharts-api
Options
All
  • Public
  • Public/Protected
  • All
Menu

Interface GetLessonsOptions

Hierarchy

  • GetLessonsOptions

Index

Properties

Properties

date

date: string

Generated using TypeDoc

\ No newline at end of file +GetLessonsOptions | classcharts-api
Options
All
  • Public
  • Public/Protected
  • All
Menu

Interface GetLessonsOptions

Hierarchy

  • GetLessonsOptions

Index

Properties

Properties

date

date: string

Generated using TypeDoc

\ No newline at end of file diff --git a/docs/interfaces/types.Homework.html b/docs/interfaces/types.Homework.html index 4ed3a82..c0e4b6e 100644 --- a/docs/interfaces/types.Homework.html +++ b/docs/interfaces/types.Homework.html @@ -1 +1 @@ -Homework | classcharts-api
Options
All
  • Public
  • Public/Protected
  • All
Menu

Hierarchy

  • Homework

Index

Properties

completion_time_unit

completion_time_unit: string

completion_time_value

completion_time_value: string

description

description: string

due_date

due_date: string

homework_type

homework_type: string

id

id: number

issue_date

issue_date: string

lesson

lesson: string

meta_title

meta_title: string

publish_time

publish_time: string

status

status: { allow_attachments: string; attachments: any[]; first_seen_date: string; has_feedback: boolean; id: number; last_seen_date: string; mark: null; mark_relative: number; state: null; ticked: boolean }

Type declaration

  • allow_attachments: string
  • attachments: any[]
  • first_seen_date: string
  • has_feedback: boolean
  • id: number
  • last_seen_date: string
  • mark: null
  • mark_relative: number
  • state: null
  • ticked: boolean

subject

subject: string

teacher

teacher: string

title

title: string

validated_attachments

validated_attachments: any[]

validated_links

validated_links: any[]

Generated using TypeDoc

\ No newline at end of file +Homework | classcharts-api
Options
All
  • Public
  • Public/Protected
  • All
Menu

Hierarchy

  • Homework

Index

Properties

completion_time_unit

completion_time_unit: string

completion_time_value

completion_time_value: string

description

description: string

due_date

due_date: string

homework_type

homework_type: string

id

id: number

issue_date

issue_date: string

lesson

lesson: string

meta_title

meta_title: string

publish_time

publish_time: string

status

status: { allow_attachments: string; attachments: any[]; first_seen_date: string; has_feedback: boolean; id: number; last_seen_date: string; mark: null; mark_relative: number; state: null; ticked: boolean }

Type declaration

  • allow_attachments: string
  • attachments: any[]
  • first_seen_date: string
  • has_feedback: boolean
  • id: number
  • last_seen_date: string
  • mark: null
  • mark_relative: number
  • state: null
  • ticked: boolean

subject

subject: string

teacher

teacher: string

title

title: string

validated_attachments

validated_attachments: any[]

validated_links

validated_links: any[]

Generated using TypeDoc

\ No newline at end of file diff --git a/docs/interfaces/types.Lesson.html b/docs/interfaces/types.Lesson.html index b68977c..7acf8a2 100644 --- a/docs/interfaces/types.Lesson.html +++ b/docs/interfaces/types.Lesson.html @@ -1 +1 @@ -Lesson | classcharts-api
Options
All
  • Public
  • Public/Protected
  • All
Menu

Hierarchy

  • Lesson

Index

Properties

date

date: string

end_time

end_time: string

is_alternative_lesson

is_alternative_lesson: boolean

key

key: number

lesson_name

lesson_name: string

note

note: string

note_abstract

note_abstract: string

period_name

period_name: string

period_number

period_number: string

pupil_note

pupil_note: string

pupil_note_abstract

pupil_note_abstract: string

pupil_note_raw

pupil_note_raw: string

room_name

room_name: string

start_time

start_time: string

subject_name

subject_name: string

teacher_name

teacher_name: string

Generated using TypeDoc

\ No newline at end of file +Lesson | classcharts-api
Options
All
  • Public
  • Public/Protected
  • All
Menu

Hierarchy

  • Lesson

Index

Properties

date

date: string

end_time

end_time: string

is_alternative_lesson

is_alternative_lesson: boolean

key

key: number

lesson_name

lesson_name: string

note

note: string

note_abstract

note_abstract: string

period_name

period_name: string

period_number

period_number: string

pupil_note

pupil_note: string

pupil_note_abstract

pupil_note_abstract: string

pupil_note_raw

pupil_note_raw: string

room_name

room_name: string

start_time

start_time: string

subject_name

subject_name: string

teacher_name

teacher_name: string

Generated using TypeDoc

\ No newline at end of file diff --git a/docs/interfaces/types.Student.html b/docs/interfaces/types.Student.html index c01d994..fde429a 100644 --- a/docs/interfaces/types.Student.html +++ b/docs/interfaces/types.Student.html @@ -1 +1 @@ -Student | classcharts-api
Options
All
  • Public
  • Public/Protected
  • All
Menu

Hierarchy

  • Student

Index

Properties

allow_pupils_add_timetable_notes

allow_pupils_add_timetable_notes: boolean

announcements_count

announcements_count: number

avatar_url

avatar_url: string

can_upload_attachments

can_upload_attachments: null | string

detention_alias_plural_uc

detention_alias_plural_uc: string

display_absences

display_absences: boolean

display_activity

display_activity: boolean

display_announcements

display_announcements: boolean

display_attendance

display_attendance: boolean

display_attendance_percentage

display_attendance_percentage: boolean

display_attendance_type

display_attendance_type: string

display_avatars

display_avatars: boolean

display_behaviour

display_behaviour: boolean

display_classes

display_classes: boolean

display_concern_submission

display_concern_submission: boolean

display_custom_fields

display_custom_fields: boolean

display_detentions

display_detentions: boolean

display_event_badges

display_event_badges: boolean

display_homework

display_homework: boolean

display_mental_health

display_mental_health: boolean

display_parent_behaviour

display_parent_behaviour: boolean

display_report_cards

display_report_cards: boolean

display_rewards

display_rewards: boolean

display_timetable

display_timetable: boolean

display_two_way_communications

display_two_way_communications: boolean

first_name

first_name: string

has_birthday

has_birthday: boolean

has_new_survey

has_new_survey: boolean

id

id: number

is_disabled

is_disabled: boolean

last_name

last_name: string

messages_count

messages_count: number

name

name: string

pupil_concerns_help_text

pupil_concerns_help_text: string

pusher_channel_name

pusher_channel_name: string

survey_id

survey_id: null | number

Generated using TypeDoc

\ No newline at end of file +Student | classcharts-api
Options
All
  • Public
  • Public/Protected
  • All
Menu

Hierarchy

  • Student

Index

Properties

allow_pupils_add_timetable_notes

allow_pupils_add_timetable_notes: boolean

announcements_count

announcements_count: number

avatar_url

avatar_url: string

can_upload_attachments

can_upload_attachments: null | string

detention_alias_plural_uc

detention_alias_plural_uc: string

display_absences

display_absences: boolean

display_activity

display_activity: boolean

display_announcements

display_announcements: boolean

display_attendance

display_attendance: boolean

display_attendance_percentage

display_attendance_percentage: boolean

display_attendance_type

display_attendance_type: string

display_avatars

display_avatars: boolean

display_behaviour

display_behaviour: boolean

display_classes

display_classes: boolean

display_concern_submission

display_concern_submission: boolean

display_custom_fields

display_custom_fields: boolean

display_detentions

display_detentions: boolean

display_event_badges

display_event_badges: boolean

display_homework

display_homework: boolean

display_mental_health

display_mental_health: boolean

display_parent_behaviour

display_parent_behaviour: boolean

display_report_cards

display_report_cards: boolean

display_rewards

display_rewards: boolean

display_timetable

display_timetable: boolean

display_two_way_communications

display_two_way_communications: boolean

first_name

first_name: string

has_birthday

has_birthday: boolean

has_new_survey

has_new_survey: boolean

id

id: number

is_disabled

is_disabled: boolean

last_name

last_name: string

messages_count

messages_count: number

name

name: string

pupil_concerns_help_text

pupil_concerns_help_text: string

pusher_channel_name

pusher_channel_name: string

survey_id

survey_id: null | number

Generated using TypeDoc

\ No newline at end of file diff --git a/docs/modules/api.html b/docs/modules/api.html index 4eb82ed..f2c2859 100644 --- a/docs/modules/api.html +++ b/docs/modules/api.html @@ -1 +1 @@ -api | classcharts-api
Options
All
  • Public
  • Public/Protected
  • All
Menu

Index

Functions

getActivity

getBehaviour

getLessons

getStudentInfo

  • getStudentInfo(studentCode: string, dateOfBirth: null | string): Promise<Student>
  • Parameters

    • studentCode: string
    • dateOfBirth: null | string

    Returns Promise<Student>

listHomeworks

Generated using TypeDoc

\ No newline at end of file +api | classcharts-api
Options
All
  • Public
  • Public/Protected
  • All
Menu

Index

Functions

getActivity

getBehaviour

getLessons

getStudentInfo

  • getStudentInfo(studentCode: string, dateOfBirth?: string): Promise<Student>
  • Parameters

    • studentCode: string
    • Optional dateOfBirth: string

    Returns Promise<Student>

listHomeworks

Generated using TypeDoc

\ No newline at end of file diff --git a/docs/modules/consts.html b/docs/modules/consts.html index fd9e5c1..0aa29a7 100644 --- a/docs/modules/consts.html +++ b/docs/modules/consts.html @@ -1 +1 @@ -consts | classcharts-api
Options
All
  • Public
  • Public/Protected
  • All
Menu

Index

Variables

API_BASE

API_BASE: string = ...

BASE_URL

BASE_URL: "https://www.classcharts.com" = 'https://www.classcharts.com'

Generated using TypeDoc

\ No newline at end of file +consts | classcharts-api
Options
All
  • Public
  • Public/Protected
  • All
Menu

Index

Variables

API_BASE

API_BASE: string = ...

BASE_URL

BASE_URL: "https://www.classcharts.com" = 'https://www.classcharts.com'

Generated using TypeDoc

\ No newline at end of file diff --git a/docs/modules/types.html b/docs/modules/types.html index 5e3ee14..f6a4b08 100644 --- a/docs/modules/types.html +++ b/docs/modules/types.html @@ -1 +1 @@ -types | classcharts-api
Options
All
  • Public
  • Public/Protected
  • All
Menu

Generated using TypeDoc

\ No newline at end of file +types | classcharts-api
Options
All
  • Public
  • Public/Protected
  • All
Menu

Generated using TypeDoc

\ No newline at end of file diff --git a/package.json b/package.json index 0822d01..5d137cb 100644 --- a/package.json +++ b/package.json @@ -5,9 +5,8 @@ "repository": { "url": "https://github.com/jamesatjaminit/classcharts-api" }, - "main": "./index.js", + "main": "./dist/index.js", "scripts": { - "buildReady": "pnpm tsc && node dist/release.js", "generateDocs": "pnpm typedoc --entryPointStrategy expand ./src" }, "author": "", @@ -15,10 +14,13 @@ "dependencies": { "undici": "^4.9.2" }, + "files": [ + "dist/**" + ], "devDependencies": { "@types/node": "^16.11.6", "typedoc": "^0.22.7", "typescript": "^4.4.4" }, - "types": "./types.d.ts" + "types": "./dist/index.d.ts" } \ No newline at end of file diff --git a/src/api.ts b/src/api.ts index 99e97c2..bfdbce9 100644 --- a/src/api.ts +++ b/src/api.ts @@ -16,39 +16,39 @@ import { } from './types' export async function getStudentInfo( studentCode: string, - dateOfBirth: string | null + dateOfBirth?: string ): Promise { const client = new ClasschartsClient(studentCode, dateOfBirth) return await client.getStudentInfo() } export async function getActivity( studentCode: string, - dateOfBirth: string | null, - options: GetActivityOptions | null + dateOfBirth?: string, + options?: GetActivityOptions ): Promise { const client = new ClasschartsClient(studentCode, dateOfBirth) return await client.getActivity(options) } export async function getBehaviour( studentCode: string, - dateOfBirth: string | null, - options: GetBehaviourOptions | null + dateOfBirth?: string, + options?: GetBehaviourOptions ): Promise { const client = new ClasschartsClient(studentCode, dateOfBirth) return await client.getBehaviour(options) } export async function listHomeworks( studentCode: string, - dateOfBirth: string | null, - options: GetHomeworkOptions | null + dateOfBirth?: string, + options?: GetHomeworkOptions ): Promise { const client = new ClasschartsClient(studentCode, dateOfBirth) return await client.listHomeworks(options) } export async function getLessons( studentCode: string, - dateOfBirth: string | null, - options: GetLessonsOptions + dateOfBirth?: string, + options?: GetLessonsOptions ): Promise { const client = new ClasschartsClient(studentCode, dateOfBirth) return await client.getLessons(options) diff --git a/src/client.ts b/src/client.ts index dcf0ff7..9f75d0c 100644 --- a/src/client.ts +++ b/src/client.ts @@ -28,7 +28,7 @@ export class ClasschartsClient { * @param studentCode Classcharts student code * @param dateOfBirth Student's date of birth */ - constructor(studentCode: string, dateOfBirth: string) { + constructor(studentCode: string, dateOfBirth?: string) { this.studentCode = String(studentCode) this.dateOfBirth = String(dateOfBirth) } @@ -110,7 +110,7 @@ export class ClasschartsClient { * @returns Activity data */ async getActivity( - options: GetActivityOptions | null + options?: GetActivityOptions ): Promise { const params = new URLSearchParams() options?.from && params.append('form', options?.from) @@ -128,7 +128,7 @@ export class ClasschartsClient { * @returns Array of behaviour points */ async getBehaviour( - options: GetBehaviourOptions | null + options?: GetBehaviourOptions ): Promise { const params = new URLSearchParams() options?.from && params.append('form', options?.from) @@ -147,7 +147,7 @@ export class ClasschartsClient { * @returns Array of homeworks */ async listHomeworks( - options: GetHomeworkOptions | null + options?: GetHomeworkOptions ): Promise { if (!this.authCookies) throw new Error('Not authenticated') const params = new URLSearchParams() @@ -176,7 +176,7 @@ export class ClasschartsClient { * @param options GetLessonsOptions * @returns Array of lessons */ - async getLessons(options: GetLessonsOptions): Promise { + async getLessons(options?: GetLessonsOptions): Promise { if (!this.authCookies) throw new Error('Not authenticated') if (!options?.date) throw new Error('No date specified') const params = new URLSearchParams() diff --git a/src/release.ts b/src/release.ts deleted file mode 100644 index ea9449b..0000000 --- a/src/release.ts +++ /dev/null @@ -1,29 +0,0 @@ -import fs from 'fs' - -// DO NOT DELETE THIS FILE -// This file is used by build system to build a clean npm package with the compiled js files in the root of the package. -// It will not be included in the npm package. - -function main() { - const source = fs - .readFileSync(__dirname + '/../package.json') - .toString('utf-8') - const sourceObj = JSON.parse(source) - sourceObj.scripts = {} - sourceObj.devDependencies = {} - if (sourceObj.main.startsWith('dist/')) { - sourceObj.main = sourceObj.main.slice(5) - } - fs.writeFileSync( - __dirname + '/package.json', - Buffer.from(JSON.stringify(sourceObj, null, 2), 'utf-8') - ) - fs.writeFileSync( - __dirname + '/version.txt', - Buffer.from(sourceObj.version, 'utf-8') - ) - fs.copyFileSync(__dirname + '/../.npmignore', __dirname + '/.npmignore') - fs.copyFileSync(__dirname + '/../README.MD', __dirname + '/README.MD') -} - -main() diff --git a/src/tests/test.ts b/src/tests/test.ts index 031a71d..d09ed70 100644 --- a/src/tests/test.ts +++ b/src/tests/test.ts @@ -1,10 +1,10 @@ import { ClasschartsClient } from '../client' const { code, dob } = require('../../src/tests/config.json') async function main() { - const client = new ClasschartsClient(code, dob) - await client.init() - console.log(await client.getBehaviour(null)) - console.log(await client.getActivity(null)) + const client = new ClasschartsClient(code, dob) + await client.init() + console.log(await client.getBehaviour()) + console.log(await client.getActivity()) } main() diff --git a/src/types.d.ts b/src/types.d.ts index 30430ad..e76b99f 100644 --- a/src/types.d.ts +++ b/src/types.d.ts @@ -37,8 +37,8 @@ export interface Student { detention_alias_plural_uc: string } export interface GetActivityOptions { - from: string | undefined - to: string | undefined + from?: string + to?: string } export interface ActivityTimelinePoint { positive: number @@ -57,9 +57,9 @@ export interface ActivityResponse { other_negative_count: Array } export interface GetBehaviourOptions { - from: string | undefined - to: string | undefined - last_id: string | undefined + from?: string + to?: string + last_id?: string } export interface BehaviourPoint { id: number