Skip to content

Commit 7637df1

Browse files
Merge pull request sendgrid#224 from sccalabr/api
Adding SendGridApi interface.
2 parents 82b2867 + 3e54539 commit 7637df1

File tree

2 files changed

+96
-4
lines changed

2 files changed

+96
-4
lines changed

src/main/java/com/sendgrid/SendGrid.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,10 @@
55
import java.util.Map;
66

77
/**
8-
* Class SendGrid allows for quick and easy access to the SendGrid API.
9-
*/
10-
public class SendGrid {
11-
/** The current library version. */
8+
* Class SendGrid allows for quick and easy access to the SendGrid API.
9+
*/
10+
public class SendGrid implements SendGridAPI {
11+
1212
private static final String VERSION = "3.0.0";
1313

1414
/** The user agent string to return to SendGrid. */
Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
1+
package com.sendgrid;
2+
3+
import java.io.IOException;
4+
import java.util.Map;
5+
6+
public interface SendGridAPI {
7+
8+
/**
9+
* Initializes SendGrid
10+
*
11+
* @param apiKey is your SendGrid API Key: https://app.sendgrid.com/settings/api_keys
12+
*/
13+
public void initializeSendGrid(String apiKey);
14+
15+
/**
16+
* Returns the library version
17+
*
18+
* @param apiKey is your SendGrid API Key: https://app.sendgrid.com/settings/api_keys
19+
* @return the library version.
20+
*/
21+
public String getLibraryVersion();
22+
23+
/**
24+
* Gets the version.
25+
*
26+
* @return returns the version.
27+
*/
28+
public String getVersion();
29+
30+
/**
31+
* Sets the version.
32+
*
33+
* @param version the SendGrid version.
34+
*/
35+
public void setVersion(String version);
36+
37+
/**
38+
* Gets the request headers.
39+
* @return returns a map of request headers.
40+
*/
41+
public Map<String, String> getRequestHeaders();
42+
43+
/**
44+
* Adds a request headers.
45+
*
46+
* @param key the key
47+
* @param value the value
48+
* @return returns a map of request headers.
49+
*/
50+
public Map<String, String> addRequestHeader(String key, String value);
51+
52+
/**
53+
* Removes a request headers.
54+
*
55+
* @param key the key
56+
* @return returns a map of request headers.
57+
*/
58+
public Map<String, String> removeRequestHeader(String key);
59+
60+
/**
61+
* Gets the host.
62+
*
63+
* @return returns the host.
64+
*/
65+
public String getHost();
66+
67+
/**
68+
* Sets the host.
69+
*
70+
* @param host the host to set
71+
*/
72+
public void setHost(String host);
73+
74+
/**
75+
* Class makeCall makes the call to the SendGrid API, override this method for
76+
* testing.
77+
*
78+
* @param request the request
79+
* @return returns a response.
80+
* @throws IOException in case of network or marshal error.
81+
*/
82+
public Response makeCall(Request request) throws IOException;
83+
84+
/**
85+
* Class api sets up the request to the SendGrid API, this is main interface.
86+
*
87+
* @param request the request
88+
* @return returns a response.
89+
* @throws IOException in case of network or marshal error.
90+
*/
91+
public Response api(Request request) throws IOException;
92+
}

0 commit comments

Comments
 (0)