diff options
Diffstat (limited to 'nexus/src/main/kotlin/tech/libeufin/nexus/Helpers.kt')
-rw-r--r-- | nexus/src/main/kotlin/tech/libeufin/nexus/Helpers.kt | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/nexus/src/main/kotlin/tech/libeufin/nexus/Helpers.kt b/nexus/src/main/kotlin/tech/libeufin/nexus/Helpers.kt index 468e8f03..e39f521f 100644 --- a/nexus/src/main/kotlin/tech/libeufin/nexus/Helpers.kt +++ b/nexus/src/main/kotlin/tech/libeufin/nexus/Helpers.kt @@ -28,4 +28,20 @@ fun chunkString(input: String): String { fun expectId(param: String?): String { return param ?: throw NexusError(HttpStatusCode.BadRequest, "Bad ID given") +} + +/* Needs a transaction{} block to be called */ +fun expectIdTransaction(param: String?): EbicsSubscriberEntity { + if (param == null) { + throw NexusError(HttpStatusCode.BadRequest, "Null Id given") + } + return EbicsSubscriberEntity.findById(param) ?: throw NexusError(HttpStatusCode.NotFound, "Subscriber: $param not found") +} + +/* Needs a transaction{} block to be called */ +fun expectAcctidTransaction(param: String?): EbicsAccountInfoEntity { + if (param == null) { + throw NexusError(HttpStatusCode.BadRequest, "Null Acctid given") + } + return EbicsAccountInfoEntity.findById(param) ?: throw NexusError(HttpStatusCode.NotFound, "Account: $param not found") }
\ No newline at end of file |