-
-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
EmailNotifications scaffolding with MailJet
- Loading branch information
1 parent
fe71c44
commit 817c479
Showing
4 changed files
with
187 additions
and
0 deletions.
There are no files selected for viewing
50 changes: 50 additions & 0 deletions
50
self-api/src/main/java/com/selfxdsd/api/EmailNotification.java
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
/** | ||
* Copyright (c) 2020-2022, Self XDSD Contributors | ||
* All rights reserved. | ||
* <p> | ||
* Permission is hereby granted, free of charge, to any person obtaining a copy | ||
* of this software and associated documentation files (the "Software"), | ||
* to read the Software only. Permission is hereby NOT GRANTED to use, copy, | ||
* modify, merge, publish, distribute, sublicense, and/or sell copies of | ||
* the Software. | ||
* <p> | ||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" | ||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | ||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | ||
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE | ||
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, | ||
* OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT | ||
* OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS | ||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN | ||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | ||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | ||
* POSSIBILITY OF SUCH DAMAGE. | ||
*/ | ||
package com.selfxdsd.api; | ||
|
||
/** | ||
* E-mail notification in Self XDSD. | ||
* @author Mihai Andronache ([email protected]) | ||
* @version $Id$ | ||
* @since 0.0.99 | ||
*/ | ||
public interface EmailNotification { | ||
|
||
/** | ||
* Destination e-mail address. | ||
* @return String. | ||
*/ | ||
String to(); | ||
|
||
/** | ||
* Subect text. | ||
* @return String. | ||
*/ | ||
String subject(); | ||
|
||
/** | ||
* Text body. | ||
* @return String. | ||
*/ | ||
String body(); | ||
} |
38 changes: 38 additions & 0 deletions
38
self-api/src/main/java/com/selfxdsd/api/EmailNotifications.java
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
/** | ||
* Copyright (c) 2020-2022, Self XDSD Contributors | ||
* All rights reserved. | ||
* <p> | ||
* Permission is hereby granted, free of charge, to any person obtaining a copy | ||
* of this software and associated documentation files (the "Software"), | ||
* to read the Software only. Permission is hereby NOT GRANTED to use, copy, | ||
* modify, merge, publish, distribute, sublicense, and/or sell copies of | ||
* the Software. | ||
* <p> | ||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" | ||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | ||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | ||
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE | ||
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, | ||
* OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT | ||
* OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS | ||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN | ||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | ||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | ||
* POSSIBILITY OF SUCH DAMAGE. | ||
*/ | ||
package com.selfxdsd.api; | ||
|
||
/** | ||
* E-mail notifications in Self XDSD. | ||
* @author Mihai Andronache ([email protected]) | ||
* @version $Id$ | ||
* @since 0.0.99 | ||
*/ | ||
public interface EmailNotifications { | ||
|
||
/** | ||
* Send a notification. | ||
* @param emailNotification - Notification to send. | ||
*/ | ||
void send(final EmailNotification emailNotification); | ||
} |
63 changes: 63 additions & 0 deletions
63
self-core-impl/src/main/java/com/selfxdsd/core/MailjetEmailNotifications.java
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
/** | ||
* Copyright (c) 2020-2022, Self XDSD Contributors | ||
* All rights reserved. | ||
* <p> | ||
* Permission is hereby granted, free of charge, to any person obtaining a copy | ||
* of this software and associated documentation files (the "Software"), | ||
* to read the Software only. Permission is hereby NOT GRANTED to use, copy, | ||
* modify, merge, publish, distribute, sublicense, and/or sell copies of | ||
* the Software. | ||
* <p> | ||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" | ||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | ||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | ||
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE | ||
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, | ||
* OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT | ||
* OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS | ||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN | ||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | ||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | ||
* POSSIBILITY OF SUCH DAMAGE. | ||
*/ | ||
package com.selfxdsd.core; | ||
|
||
import com.selfxdsd.api.EmailNotification; | ||
import com.selfxdsd.api.EmailNotifications; | ||
|
||
/** | ||
* Using MailJet to send e-mail notifications. | ||
* @author Mihai Andronache ([email protected]) | ||
* @version $Id$ | ||
* @since 0.0.99 | ||
*/ | ||
public final class MailjetEmailNotifications implements EmailNotifications { | ||
|
||
/** | ||
* API Public Key (username). | ||
*/ | ||
private final String apiKey; | ||
|
||
/** | ||
* API Private Key (password). | ||
*/ | ||
private final String apiSecretKey; | ||
|
||
/** | ||
* Ctor. | ||
* @param apiKey MailJet's API Key. | ||
* @param apiSecretKey MailJet's API Secret Key. | ||
*/ | ||
public MailjetEmailNotifications( | ||
final String apiKey, | ||
final String apiSecretKey | ||
) { | ||
this.apiKey = apiKey; | ||
this.apiSecretKey = apiSecretKey; | ||
} | ||
|
||
@Override | ||
public void send(final EmailNotification emailNotification) { | ||
|
||
} | ||
} |
36 changes: 36 additions & 0 deletions
36
self-core-impl/src/main/java/com/selfxdsd/core/PlatformInvoiceEmailNotification.java
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
package com.selfxdsd.core; | ||
|
||
import com.selfxdsd.api.EmailNotification; | ||
import com.selfxdsd.api.PlatformInvoice; | ||
|
||
/** | ||
* E-mail sent to the admin of Self XDSD when a PlatformInvoice is generated. | ||
* @author Mihai Andronache ([email protected]) | ||
* @version $Id$ | ||
* @since 0.0.99 | ||
*/ | ||
final class PlatformInvoiceEmailNotification implements EmailNotification { | ||
|
||
private final PlatformInvoice platformInvoice; | ||
|
||
PlatformInvoiceEmailNotification(final PlatformInvoice platformInvoice) { | ||
this.platformInvoice = platformInvoice; | ||
} | ||
|
||
@Override | ||
public String to() { | ||
return "[email protected]"; | ||
} | ||
|
||
@Override | ||
public String subject() { | ||
return "[Self XDSD] New Platform Invoice " + | ||
"(ID: " + this.platformInvoice.id() + ")"; | ||
} | ||
|
||
@Override | ||
public String body() { | ||
return "New platform invoice (id is " + this.platformInvoice.id() + | ||
") registered at " + this.platformInvoice.createdAt(); | ||
} | ||
} |
817c479
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@amihaiemil I've opened the Issues [#1298, #1299] for the newly added to-dos.
The to-dos may have been added in an earlier commit, but I've found them just now.