val notificationPlanService = {
authenticate(httpBasic(realm="ns-notifications-api")) { user =>
pathPrefix("api/%s".format(VERSION)) {
pathPrefix("device" / "[^/]+".r / "notifications") { deviceId => //matches till the next /, potentially very unsafe!
// Before notification save & update
path(IntNumber / "before") { timeInAdvance =>
post {
content(as[NotificationPlan]) { notificationPlan =>
processDepartureNotificationPost(notificationPlan, deviceId, timeInAdvance)
_.complete("done")
}
} ~
put {
content(as[NotificationPlan]) { notificationPlan =>
//update the scheduled plan (delete/insert)
_.complete("done updating")
}
}
} ~
// Before notification delete
path("before") {
delete {
content(as[NotificationPlan]) { notificationPlan =>
//delete a before schedule
deleteNotificationPlan(notificationPlan, deviceId)
_.complete("done deleting")
}
} ~
get{
//return a list of scheduled tasks
_.complete("Use POST")
}
} ~
// Guard notification
path("guard") {
get{_.complete("pusher is set to guard")}
} ~
// After notification save & update
path(IntNumber / "after") { timeInAdvance =>
post {
content(as[NotificationPlan]) { notificationPlan =>
processArrivalNotificationPost(notificationPlan, deviceId, timeInAdvance);
_.complete("done")
}
} ~
put {
content(as[NotificationPlan]) { notificationPlan =>
//update the scheduled plan (delete/insert)
_.complete("done updating")
}
}
} ~
// After notification delete
path("after") {
delete {
content(as[NotificationPlan]) { notificationPlan =>
//delete a after schedule
deleteNotificationPlan(notificationPlan, deviceId)
_.complete("done deleting")
}
}
}
}
}
}
}