code examples
This commit is contained in:
parent
d29a2b7d73
commit
ee7c336356
|
@ -49,4 +49,4 @@ spec:
|
||||||
paths:
|
paths:
|
||||||
- backend:
|
- backend:
|
||||||
serviceName: skolplattformen-api
|
serviceName: skolplattformen-api
|
||||||
servicePort: 8000
|
servicePort: 9000
|
|
@ -36,28 +36,53 @@ api.register({
|
||||||
const token = await backend.login(c.request.query.socialSecurityNumber)
|
const token = await backend.login(c.request.query.socialSecurityNumber)
|
||||||
return res.status(200).json(token)
|
return res.status(200).json(token)
|
||||||
},
|
},
|
||||||
|
|
||||||
waitForToken: async (c, req, res) => {
|
waitForToken: async (c, req, res) => {
|
||||||
const order = c.request.params.order
|
const order = c.request.params.order
|
||||||
const cookie = await backend.waitForToken({order})
|
const cookie = await backend.waitForToken({order})
|
||||||
const jwtToken = jwt.sign(cookie, process.env.JWT_SECRET || 'secret')
|
const jwtToken = jwt.sign(cookie, process.env.JWT_SECRET || 'secret')
|
||||||
return res.status(200).json(jwtToken)
|
return res.status(200).json(jwtToken)
|
||||||
},
|
},
|
||||||
|
|
||||||
getChildren: async (c, req, res) => {
|
getChildren: async (c, req, res) => {
|
||||||
const cookie = c.security.bearerAuth
|
const cookie = c.security.bearerAuth
|
||||||
const children = await backend.getChildren(cookie)
|
const children = await backend.getChildren(cookie)
|
||||||
return res.status(200).json(children)
|
return res.status(200).json(children)
|
||||||
},
|
},
|
||||||
|
|
||||||
getChildById: async (c, req, res) => {
|
getChildById: async (c, req, res) => {
|
||||||
const cookie = c.security.bearerAuth
|
const cookie = c.security.bearerAuth
|
||||||
const childId = c.request.params.order
|
const childId = c.request.params.order
|
||||||
const child = await backend.getChildById(childId, cookie)
|
const child = await backend.getChildById(childId, cookie)
|
||||||
return res.status(200).json(child)
|
return res.status(200).json(child)
|
||||||
},
|
},
|
||||||
|
getNews: async (c, req, res) => {
|
||||||
|
const cookie = c.security.bearerAuth
|
||||||
|
const childId = c.request.params.order
|
||||||
|
const news = await backend.getNews(childId, cookie)
|
||||||
|
return res.status(200).json(news)
|
||||||
|
},
|
||||||
|
getCalendar: async (c, req, res) => {
|
||||||
|
const cookie = c.security.bearerAuth
|
||||||
|
const childId = c.request.params.order
|
||||||
|
const calendar = await backend.getCalendar(childId, cookie)
|
||||||
|
return res.status(200).json(calendar)
|
||||||
|
},
|
||||||
|
getNotifications: async (c, req, res) => {
|
||||||
|
const cookie = c.security.bearerAuth
|
||||||
|
const childId = c.request.params.order
|
||||||
|
const notifications = await backend.getNotifications(childId, cookie)
|
||||||
|
return res.status(200).json(notifications)
|
||||||
|
},
|
||||||
|
getMenu: async (c, req, res) => {
|
||||||
|
const cookie = c.security.bearerAuth
|
||||||
|
const childId = c.request.params.order
|
||||||
|
const menu = await backend.getMenu(childId, cookie)
|
||||||
|
return res.status(200).json(menu)
|
||||||
|
},
|
||||||
|
getSchedule: async (c, req, res) => {
|
||||||
|
const cookie = c.security.bearerAuth
|
||||||
|
const childId = c.request.params.order
|
||||||
|
const schedule = await backend.getSchedule(childId, cookie)
|
||||||
|
return res.status(200).json(schedule)
|
||||||
|
}
|
||||||
|
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
|
@ -62,10 +62,10 @@ module.exports = {
|
||||||
login,
|
login,
|
||||||
waitForToken,
|
waitForToken,
|
||||||
getChildren,
|
getChildren,
|
||||||
|
getChildById,
|
||||||
getNews,
|
getNews,
|
||||||
getCalendar,
|
getCalendar,
|
||||||
getNotifications,
|
getNotifications,
|
||||||
getMenu,
|
getMenu,
|
||||||
getSchedule,
|
getSchedule
|
||||||
getChildById
|
|
||||||
}
|
}
|
|
@ -11,15 +11,38 @@ info:
|
||||||
# Introduction
|
# Introduction
|
||||||
This API is a wrapper on top of the SOA layer behind **Skolplattformen** which is the mandatory platform for schools in Stockholm Stad.
|
This API is a wrapper on top of the SOA layer behind **Skolplattformen** which is the mandatory platform for schools in Stockholm Stad.
|
||||||
|
|
||||||
|
# Get Started
|
||||||
|
Generate code examples from the OpenAPI yaml (press Download above) or use this as a start:
|
||||||
|
```
|
||||||
|
const socialSecurityNumber = '121212121212'
|
||||||
|
const baseUrl = 'https://skolplattformen-api.snowflake.cash'
|
||||||
|
const token = await fetch(`${baseUrl}/login?socialSecurityNumber=${socialSecurityNumber}`, {method: 'POST'}).then(res => res.json())
|
||||||
|
|
||||||
|
// Now start BankID and authorize, when you do - your jwt token will be ready
|
||||||
|
const jwt = await fetch(`${baseUrl}/login/${token.order}/jwt`).then(res => res.json())
|
||||||
|
const headers = {authorization: 'Bearer ' + jwt}
|
||||||
|
|
||||||
|
// Use the jwt token as bearer token in your requests
|
||||||
|
const children = await fetch(`${baseUrl}/children`, {headers}).then(res => res.json())
|
||||||
|
|
||||||
|
// Get some details
|
||||||
|
const childId = children[0].id
|
||||||
|
const child = await fetch(`${baseUrl}/children/${childId}`, {headers}).then(res => res.json())
|
||||||
|
const news = await fetch(`${baseUrl}/children/${childId}/news`, {headers}).then(res => res.json())
|
||||||
|
const calendar = await fetch(`${baseUrl}/children/${childId}/calendar`, {headers}).then(res => res.json())
|
||||||
|
|
||||||
|
```
|
||||||
|
|
||||||
# Disclaimers
|
# Disclaimers
|
||||||
I have no affiliate with the Stockholm Stad organisation or any part of any development team for the city. Therefore things may change and suddenly stop working and I have no way of knowing or even a way of contacting you. My motivation for creating this API is purely for personal reasons. I want to develop apps for my own use and have no interest to go deep in the underlying SDK every day so I'm using this API as a way of creating a little bit of sanity and conform the sometimes swinglish structure into something a little bit more consistant.
|
I have no affiliate with the Stockholm Stad organisation or any part of any development team for the city. Therefore things may change and suddenly stop working and I have no way of knowing or even a way of contacting you. My motivation for creating this API is purely for personal reasons. I want to develop apps for my own use and have no interest to go deep in the underlying SDK every day so I'm using this API as a way of creating a little bit of sanity and conform the sometimes swinglish structure into something a little bit more consistant.
|
||||||
|
|
||||||
**Please let me know if you find anything useful and I'll add it**. /Hopefully I can find a reasonable way to release this sourcecode as open source soon./
|
**Please let me know if you find anything useful and I'll add it**. /Hopefully I can find a reasonable way to release this sourcecode as open source soon./
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
contact:
|
contact:
|
||||||
name: Christian Landgren
|
name: Christian Landgren
|
||||||
email: christian@landgren.nu
|
email: christian.landgren@iteam.se
|
||||||
url: https://github.com/irony
|
url: https://github.com/irony
|
||||||
x-logo:
|
x-logo:
|
||||||
url: '/logo.png'
|
url: '/logo.png'
|
||||||
|
@ -118,6 +141,8 @@ paths:
|
||||||
/children/{childId}/news:
|
/children/{childId}/news:
|
||||||
get:
|
get:
|
||||||
summary: News
|
summary: News
|
||||||
|
operationId: getNews
|
||||||
|
|
||||||
description: Get list of news items for this child
|
description: Get list of news items for this child
|
||||||
tags:
|
tags:
|
||||||
- Children
|
- Children
|
||||||
|
@ -139,6 +164,8 @@ paths:
|
||||||
/children/{childId}/calendar:
|
/children/{childId}/calendar:
|
||||||
get:
|
get:
|
||||||
summary: Calendar
|
summary: Calendar
|
||||||
|
operationId: getCalendar
|
||||||
|
|
||||||
description: Get list of calendar events
|
description: Get list of calendar events
|
||||||
security:
|
security:
|
||||||
- bearerAuth: []
|
- bearerAuth: []
|
||||||
|
@ -161,6 +188,8 @@ paths:
|
||||||
/children/{childId}/notifications:
|
/children/{childId}/notifications:
|
||||||
get:
|
get:
|
||||||
summary: Notifications
|
summary: Notifications
|
||||||
|
operationId: getNotifications
|
||||||
|
|
||||||
description: Get list of notifications for this child
|
description: Get list of notifications for this child
|
||||||
security:
|
security:
|
||||||
- bearerAuth: []
|
- bearerAuth: []
|
||||||
|
@ -179,6 +208,8 @@ paths:
|
||||||
/children/{childId}/menu:
|
/children/{childId}/menu:
|
||||||
get:
|
get:
|
||||||
summary: Lunch Menu
|
summary: Lunch Menu
|
||||||
|
operationId: getMenu
|
||||||
|
|
||||||
description: Get list of news items for this child
|
description: Get list of news items for this child
|
||||||
security:
|
security:
|
||||||
- bearerAuth: []
|
- bearerAuth: []
|
||||||
|
@ -197,6 +228,8 @@ paths:
|
||||||
/children/{childId}/schedule:
|
/children/{childId}/schedule:
|
||||||
get:
|
get:
|
||||||
summary: Schedule
|
summary: Schedule
|
||||||
|
operationId: getSchedule
|
||||||
|
|
||||||
description: Get list of news items for this child
|
description: Get list of news items for this child
|
||||||
security:
|
security:
|
||||||
- bearerAuth: []
|
- bearerAuth: []
|
||||||
|
@ -212,8 +245,6 @@ paths:
|
||||||
responses:
|
responses:
|
||||||
'200':
|
'200':
|
||||||
description: OK
|
description: OK
|
||||||
|
|
||||||
|
|
||||||
components:
|
components:
|
||||||
schemas:
|
schemas:
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue