wip: fix timetable and minor things
This commit is contained in:
parent
8385d30aaf
commit
f1c622ef60
|
@ -72,6 +72,9 @@ async function run() {
|
|||
console.log('calendar')
|
||||
const calendar = await api.getCalendar(children[0])
|
||||
console.log(calendar)
|
||||
|
||||
console.log('news')
|
||||
const news = await api.getNews(children[0])
|
||||
/*
|
||||
/*console.log('classmates')
|
||||
const classmates = await api.getClassmates(children[0])
|
||||
|
@ -97,11 +100,6 @@ async function run() {
|
|||
console.error(error)
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
console.log('news')
|
||||
const news = await api.getNews(children[0])
|
||||
*/
|
||||
/* console.log('news details')
|
||||
const newsItems = await Promise.all(
|
||||
news.map((newsItem) =>
|
||||
|
|
|
@ -211,8 +211,6 @@ export class ApiAdmentum extends EventEmitter implements Api {
|
|||
isoWeek.toString()
|
||||
)
|
||||
console.log('fetching calendar', fetchUrl)
|
||||
//const calendarResponse = await this.fetch('get-calendar', fetchUrl)
|
||||
//const calendarResponseJson = await calendarResponse.json()
|
||||
const overviewResponse = await this.fetch('get-week-data', fetchUrl, {
|
||||
headers: {
|
||||
'x-requested-with': 'XMLHttpRequest',
|
||||
|
@ -260,14 +258,9 @@ export class ApiAdmentum extends EventEmitter implements Api {
|
|||
"weekly_interval": ""
|
||||
}
|
||||
*/
|
||||
return Promise.resolve(
|
||||
schedule_events.map(({ menu, date }: any) => ({
|
||||
title: date,
|
||||
description: menu,
|
||||
}))
|
||||
)
|
||||
return Promise.resolve([])
|
||||
} catch (e) {
|
||||
console.error('Error fetching menu', e)
|
||||
console.error('Error fetching overview', e)
|
||||
return Promise.resolve([])
|
||||
}
|
||||
}
|
||||
|
@ -373,6 +366,17 @@ export class ApiAdmentum extends EventEmitter implements Api {
|
|||
if (!this.isLoggedIn) {
|
||||
throw new Error('Not logged in...')
|
||||
}
|
||||
|
||||
const fetchUrl = apiUrls.messages(this.userId, '1')
|
||||
console.log('fetching messages', fetchUrl)
|
||||
const messagesResponse = await this.fetch('get-messages', fetchUrl, {
|
||||
headers: {
|
||||
'x-requested-with': 'XMLHttpRequest',
|
||||
},
|
||||
})
|
||||
const messagesResponseJson = await messagesResponse.json()
|
||||
console.log('messages response', messagesResponseJson)
|
||||
|
||||
return Promise.resolve([])
|
||||
}
|
||||
|
||||
|
|
|
@ -2,6 +2,7 @@ import * as html from 'node-html-parser'
|
|||
import { decode } from 'he'
|
||||
import { CalendarItem, TimetableEntry } from 'libs/api/lib/types'
|
||||
import { DateTime, FixedOffsetZone } from 'luxon'
|
||||
import { teacher } from 'libs/api-skolplattformen/lib/parse'
|
||||
|
||||
// TODO: Move this into the parse folder and convert it to follow the pattern of other parsers (include tests).
|
||||
|
||||
|
@ -89,12 +90,12 @@ export const parseCalendarItem = (jsonData: any): any => {
|
|||
const dayOfWeek = DayOfWeek[day.name as keyof typeof DayOfWeek]
|
||||
timetableEntries.push({
|
||||
id: lesson.id,
|
||||
teacher: lesson.bookedTeacherNames && lesson.bookedTeacherNames[0],
|
||||
location: lesson.location,
|
||||
teacher: lesson.teachers,
|
||||
location: lesson.room || lesson.title || lesson.subject_name,
|
||||
timeStart: lesson.time.substring(0, 5),
|
||||
timeEnd: lesson.time.substring(9),
|
||||
dayOfWeek,
|
||||
blockName: lesson.title || lesson.subject_name
|
||||
blockName: lesson.title || lesson.subject_name,
|
||||
} as TimetableEntry)
|
||||
});
|
||||
})
|
||||
|
|
|
@ -15,6 +15,9 @@ export const apiUrls = {
|
|||
leisure_groups: api + 'leisure_groups',
|
||||
lesson_infos: api + 'lesson_infos',
|
||||
lessons: api + 'lessons',
|
||||
// start at page 1
|
||||
messages: (userId: string, page: string) =>
|
||||
`https://messages.admentum.se/api/users/${userId}/conversations?page=${page}`, // unread_only=1
|
||||
organisations: api + 'organisations',
|
||||
orientations: api + 'orientations',
|
||||
overview: (action: string, year: string, week: string) =>
|
||||
|
|
Loading…
Reference in New Issue