Skip to content

Commit 817c479

Browse files
committed
EmailNotifications scaffolding with MailJet
1 parent fe71c44 commit 817c479

File tree

4 files changed

+187
-0
lines changed

4 files changed

+187
-0
lines changed
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
/**
2+
* Copyright (c) 2020-2022, Self XDSD Contributors
3+
* All rights reserved.
4+
* <p>
5+
* Permission is hereby granted, free of charge, to any person obtaining a copy
6+
* of this software and associated documentation files (the "Software"),
7+
* to read the Software only. Permission is hereby NOT GRANTED to use, copy,
8+
* modify, merge, publish, distribute, sublicense, and/or sell copies of
9+
* the Software.
10+
* <p>
11+
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
12+
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
13+
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
14+
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
15+
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
16+
* OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
17+
* OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
18+
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
19+
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
20+
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
21+
* POSSIBILITY OF SUCH DAMAGE.
22+
*/
23+
package com.selfxdsd.api;
24+
25+
/**
26+
* E-mail notification in Self XDSD.
27+
* @author Mihai Andronache (amihaiemil@gmail.com)
28+
* @version $Id$
29+
* @since 0.0.99
30+
*/
31+
public interface EmailNotification {
32+
33+
/**
34+
* Destination e-mail address.
35+
* @return String.
36+
*/
37+
String to();
38+
39+
/**
40+
* Subect text.
41+
* @return String.
42+
*/
43+
String subject();
44+
45+
/**
46+
* Text body.
47+
* @return String.
48+
*/
49+
String body();
50+
}
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
/**
2+
* Copyright (c) 2020-2022, Self XDSD Contributors
3+
* All rights reserved.
4+
* <p>
5+
* Permission is hereby granted, free of charge, to any person obtaining a copy
6+
* of this software and associated documentation files (the "Software"),
7+
* to read the Software only. Permission is hereby NOT GRANTED to use, copy,
8+
* modify, merge, publish, distribute, sublicense, and/or sell copies of
9+
* the Software.
10+
* <p>
11+
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
12+
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
13+
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
14+
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
15+
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
16+
* OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
17+
* OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
18+
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
19+
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
20+
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
21+
* POSSIBILITY OF SUCH DAMAGE.
22+
*/
23+
package com.selfxdsd.api;
24+
25+
/**
26+
* E-mail notifications in Self XDSD.
27+
* @author Mihai Andronache (amihaiemil@gmail.com)
28+
* @version $Id$
29+
* @since 0.0.99
30+
*/
31+
public interface EmailNotifications {
32+
33+
/**
34+
* Send a notification.
35+
* @param emailNotification - Notification to send.
36+
*/
37+
void send(final EmailNotification emailNotification);
38+
}
Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
/**
2+
* Copyright (c) 2020-2022, Self XDSD Contributors
3+
* All rights reserved.
4+
* <p>
5+
* Permission is hereby granted, free of charge, to any person obtaining a copy
6+
* of this software and associated documentation files (the "Software"),
7+
* to read the Software only. Permission is hereby NOT GRANTED to use, copy,
8+
* modify, merge, publish, distribute, sublicense, and/or sell copies of
9+
* the Software.
10+
* <p>
11+
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
12+
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
13+
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
14+
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
15+
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
16+
* OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
17+
* OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
18+
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
19+
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
20+
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
21+
* POSSIBILITY OF SUCH DAMAGE.
22+
*/
23+
package com.selfxdsd.core;
24+
25+
import com.selfxdsd.api.EmailNotification;
26+
import com.selfxdsd.api.EmailNotifications;
27+
28+
/**
29+
* Using MailJet to send e-mail notifications.
30+
* @author Mihai Andronache (amihaiemil@gmail.com)
31+
* @version $Id$
32+
* @since 0.0.99
33+
*/
34+
public final class MailjetEmailNotifications implements EmailNotifications {
35+
36+
/**
37+
* API Public Key (username).
38+
*/
39+
private final String apiKey;
40+
41+
/**
42+
* API Private Key (password).
43+
*/
44+
private final String apiSecretKey;
45+
46+
/**
47+
* Ctor.
48+
* @param apiKey MailJet's API Key.
49+
* @param apiSecretKey MailJet's API Secret Key.
50+
*/
51+
public MailjetEmailNotifications(
52+
final String apiKey,
53+
final String apiSecretKey
54+
) {
55+
this.apiKey = apiKey;
56+
this.apiSecretKey = apiSecretKey;
57+
}
58+
59+
@Override
60+
public void send(final EmailNotification emailNotification) {
61+
62+
}
63+
}
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
package com.selfxdsd.core;
2+
3+
import com.selfxdsd.api.EmailNotification;
4+
import com.selfxdsd.api.PlatformInvoice;
5+
6+
/**
7+
* E-mail sent to the admin of Self XDSD when a PlatformInvoice is generated.
8+
* @author Mihai Andronache (amihaiemil@gmail.com)
9+
* @version $Id$
10+
* @since 0.0.99
11+
*/
12+
final class PlatformInvoiceEmailNotification implements EmailNotification {
13+
14+
private final PlatformInvoice platformInvoice;
15+
16+
PlatformInvoiceEmailNotification(final PlatformInvoice platformInvoice) {
17+
this.platformInvoice = platformInvoice;
18+
}
19+
20+
@Override
21+
public String to() {
22+
return "office@extremelydistributed.com";
23+
}
24+
25+
@Override
26+
public String subject() {
27+
return "[Self XDSD] New Platform Invoice " +
28+
"(ID: " + this.platformInvoice.id() + ")";
29+
}
30+
31+
@Override
32+
public String body() {
33+
return "New platform invoice (id is " + this.platformInvoice.id() +
34+
") registered at " + this.platformInvoice.createdAt();
35+
}
36+
}

0 commit comments

Comments
 (0)