Skip to content

Commit

Permalink
Add support for print logs (#19)
Browse files Browse the repository at this point in the history
  • Loading branch information
raphaelm authored Oct 30, 2024
1 parent 6cc93c8 commit 037b9c5
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 5 deletions.
2 changes: 1 addition & 1 deletion libpretixsync-repo
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ object Server {
get("questions/", EmptyResourceEndpoint)
get("badgelayouts/", BadgeLayoutEndpoint)
get("checkinlists/", CheckInListEndpoint)
post("orderpositions/{positionid}/printlog/", PrintLogEndpoint)
get("orders/", EmptyResourceEndpoint)
get("badgeitems/", BadgeItemEndpoint)
get("settings/", SettingsEndpoint)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,12 @@
package eu.pretix.pretixscan.scanproxy.endpoints

import eu.pretix.libpretixsync.db.*
import eu.pretix.pretixscan.scanproxy.ProxyFileStorage
import eu.pretix.pretixscan.scanproxy.Server
import eu.pretix.pretixscan.scanproxy.proxyDeps
import io.javalin.http.Context
import io.javalin.http.Handler
import io.javalin.http.NotFoundResponse
import java.text.SimpleDateFormat
import java.time.LocalDate
import java.util.*


object EventEndpoint : Handler {
Expand Down Expand Up @@ -216,4 +213,19 @@ object EmptyResourceEndpoint : Handler {
)
)
}
}
}

object PrintLogEndpoint : Handler {
override fun handle(ctx: Context) {
val event = proxyDeps.syncData.select(Event::class.java)
.where(Event.SLUG.eq(ctx.pathParam("event")))
.get().firstOrNull() ?: throw NotFoundResponse("Event not found")
ctx.json(event.json)

val log = QueuedCall()
log.setBody(ctx.body())
log.setIdempotency_key(NonceGenerator.nextNonce())
log.setUrl(proxyDeps.pretixApi.eventResourceUrl(ctx.pathParam("event"), "orderpositions") + ctx.pathParam("positionid") + "/printlog/")
proxyDeps.syncData.insert(log)
}
}

0 comments on commit 037b9c5

Please sign in to comment.