Created
August 10, 2018 21:07
-
-
Save bibscy/64ba73b88868d91ab9c3987d51da3c78 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
extension NotificationsMyStreet { | |
func prepareVars(request:Request) throws -> DataFromClientSendNotifications { | |
struct ObjectReceived: NodeInitializable { | |
let title: String | |
let body: String | |
let unreadMessagesCount: Int | |
init(node: Node, in context: Context = EmptyNode) throws { | |
title = try node.extract() | |
body = try node.extract() | |
unreadMessagesCount = try node.extract() | |
} | |
} | |
guard let json = request.json else { | |
throw Abort.custom(status: .badRequest, message: "something went ") | |
} | |
let objects = try json.object?.values.map { try ObjectReceived(node: $0 as! Node) } ?? [] | |
print(objects) | |
}//end of func prepareVars | |
}//end of extension |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment