diff --git a/self-api/src/main/java/com/selfxdsd/api/EmailNotification.java b/self-api/src/main/java/com/selfxdsd/api/EmailNotification.java new file mode 100644 index 00000000..d32329df --- /dev/null +++ b/self-api/src/main/java/com/selfxdsd/api/EmailNotification.java @@ -0,0 +1,50 @@ +/** + * Copyright (c) 2020-2022, Self XDSD Contributors + * All rights reserved. + *
+ * 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. + *
+ * 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 (amihaiemil@gmail.com) + * @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(); +} diff --git a/self-api/src/main/java/com/selfxdsd/api/EmailNotifications.java b/self-api/src/main/java/com/selfxdsd/api/EmailNotifications.java new file mode 100644 index 00000000..d8432e2a --- /dev/null +++ b/self-api/src/main/java/com/selfxdsd/api/EmailNotifications.java @@ -0,0 +1,38 @@ +/** + * Copyright (c) 2020-2022, Self XDSD Contributors + * All rights reserved. + *
+ * 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. + *
+ * 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 (amihaiemil@gmail.com) + * @version $Id$ + * @since 0.0.99 + */ +public interface EmailNotifications { + + /** + * Send a notification. + * @param emailNotification - Notification to send. + */ + void send(final EmailNotification emailNotification); +} diff --git a/self-core-impl/src/main/java/com/selfxdsd/core/MailjetEmailNotifications.java b/self-core-impl/src/main/java/com/selfxdsd/core/MailjetEmailNotifications.java new file mode 100644 index 00000000..529e4b18 --- /dev/null +++ b/self-core-impl/src/main/java/com/selfxdsd/core/MailjetEmailNotifications.java @@ -0,0 +1,63 @@ +/** + * Copyright (c) 2020-2022, Self XDSD Contributors + * All rights reserved. + *
+ * 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. + *
+ * 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 (amihaiemil@gmail.com) + * @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) { + + } +} diff --git a/self-core-impl/src/main/java/com/selfxdsd/core/PlatformInvoiceEmailNotification.java b/self-core-impl/src/main/java/com/selfxdsd/core/PlatformInvoiceEmailNotification.java new file mode 100644 index 00000000..1cadef96 --- /dev/null +++ b/self-core-impl/src/main/java/com/selfxdsd/core/PlatformInvoiceEmailNotification.java @@ -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 (amihaiemil@gmail.com) + * @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 "office@extremelydistributed.com"; + } + + @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(); + } +}