From e0b4550cd330f27c84a04f9d0134cf0fe0baec07 Mon Sep 17 00:00:00 2001 From: dankito Date: Tue, 26 Nov 2024 03:19:11 +0100 Subject: [PATCH] Added ListenForNewMailsOptions so that there onEmailReceived has to be set --- .../net/codinux/invoicing/email/EmailsFetcher.kt | 2 +- .../net/codinux/invoicing/email/FetchEmailsOptions.kt | 2 +- .../invoicing/email/ListenForNewMailsOptions.kt | 10 ++++++++++ 3 files changed, 12 insertions(+), 2 deletions(-) create mode 100644 e-invoice-domain/src/main/kotlin/net/codinux/invoicing/email/ListenForNewMailsOptions.kt diff --git a/e-invoice-domain/src/main/kotlin/net/codinux/invoicing/email/EmailsFetcher.kt b/e-invoice-domain/src/main/kotlin/net/codinux/invoicing/email/EmailsFetcher.kt index 24c986e..dc9ac3d 100644 --- a/e-invoice-domain/src/main/kotlin/net/codinux/invoicing/email/EmailsFetcher.kt +++ b/e-invoice-domain/src/main/kotlin/net/codinux/invoicing/email/EmailsFetcher.kt @@ -34,7 +34,7 @@ open class EmailsFetcher( protected val log by logger() - open fun listenForNewEmails(account: EmailAccount, options: FetchEmailsOptions) = runBlocking { + open fun listenForNewEmails(account: EmailAccount, options: ListenForNewMailsOptions) = runBlocking { try { connect(account) { store -> val folder = store.getFolder(options.emailFolderName) diff --git a/e-invoice-domain/src/main/kotlin/net/codinux/invoicing/email/FetchEmailsOptions.kt b/e-invoice-domain/src/main/kotlin/net/codinux/invoicing/email/FetchEmailsOptions.kt index 1c007a7..2159aa9 100644 --- a/e-invoice-domain/src/main/kotlin/net/codinux/invoicing/email/FetchEmailsOptions.kt +++ b/e-invoice-domain/src/main/kotlin/net/codinux/invoicing/email/FetchEmailsOptions.kt @@ -1,6 +1,6 @@ package net.codinux.invoicing.email -data class FetchEmailsOptions( +open class FetchEmailsOptions( val downloadMessageBody: Boolean = false, val emailFolderName: String = "INBOX", diff --git a/e-invoice-domain/src/main/kotlin/net/codinux/invoicing/email/ListenForNewMailsOptions.kt b/e-invoice-domain/src/main/kotlin/net/codinux/invoicing/email/ListenForNewMailsOptions.kt new file mode 100644 index 0000000..b56be09 --- /dev/null +++ b/e-invoice-domain/src/main/kotlin/net/codinux/invoicing/email/ListenForNewMailsOptions.kt @@ -0,0 +1,10 @@ +package net.codinux.invoicing.email + +open class ListenForNewMailsOptions( + downloadMessageBody: Boolean = false, + emailFolderName: String = "INBOX", + + onError: ((FetchEmailsError) -> Unit)? = null, + onEmailReceived: (EmailWithInvoice) -> Unit +) : FetchEmailsOptions(downloadMessageBody, emailFolderName, onError, onEmailReceived) { +} \ No newline at end of file