1 package com.srv4pos.server.api.email;
2
3 import com.srv4pos.server.api.infrastructure.HttpMethod;
4 import com.srv4pos.server.api.infrastructure.StringConnectionWriter;
5 import com.srv4pos.server.api.infrastructure.credentials.Credentials;
6 import com.srv4pos.server.api.infrastructure.http.HttpHelper;
7 import com.srv4pos.server.api.infrastructure.http.Transport;
8
9 import java.net.URL;
10
11 import static com.srv4pos.server.api.infrastructure.request.RequestHelper.requestVoid;
12
13
14
15
16 public class EmailService {
17 private URL url;
18 private Credentials credentials;
19 private Transport transport;
20
21
22
23
24
25
26
27
28 public EmailService(URL url, Credentials credentials, Transport transport) {
29 this.url = url;
30 this.credentials = credentials;
31 this.transport = transport;
32 }
33
34
35
36
37
38
39 public void send(EmailInfo emailInfo) {
40 requestVoid("email",
41 HttpMethod.POST,
42 url,
43 credentials == null ? null : credentials.toAuthentication(),
44 null,
45 null,
46 new StringConnectionWriter(emailInfo.toJson()),
47 HttpHelper.CONTENT_TYPE_APPLICATION_JSON,
48 transport);
49 }
50
51 }