Skip to content

Commit

Permalink
final refactoring before release
Browse files Browse the repository at this point in the history
  • Loading branch information
ibalosh committed Nov 21, 2017
1 parent 006ede5 commit 5c06b01
Show file tree
Hide file tree
Showing 6 changed files with 98 additions and 93 deletions.
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@ Add the dependency to your project:
</dependency>
```

Note: to retrieve version, visit [maven central repository](http://repo1.maven.org/maven2/com/wildbit/java/postmark/) , or check the badge at top of the page,showing latest version in Maven repository archives.
Note: to retrieve version, visit [maven central repository](http://repo1.maven.org/maven2/com/wildbit/java/postmark/) , or check the badge at top of the page, showing latest version synced in Maven repository archives.
Maven central repository might be slightly acurrate, in case new version was published recently.

## Issues & Comments

Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
</developers>

<properties>
<postmark.version>0.9.3</postmark.version>
<postmark.version>1.0.0</postmark.version>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<java.version>1.8</java.version>
<junit.jupiter.version>5.0.0-M4</junit.jupiter.version>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,10 @@
*/
public class AccountApiClient extends BaseApiClient {

private final String serversEndpoint = "/servers/";
private final String domainsEndpoint = "/domains/";
private final String sendersEndpoint = "/senders/";

public AccountApiClient(String baseUrl, MultivaluedHashMap<String,Object> headers) {
super(baseUrl,headers);
}
Expand All @@ -33,27 +37,27 @@ public AccountApiClient(String baseUrl, MultivaluedHashMap<String,Object> header


public Server getServers(Integer id) throws PostmarkException, IOException {
String response = execute(HttpClient.REQUEST_TYPES.GET, getEndpointUrl("/servers/" + id));
String response = execute(HttpClient.REQUEST_TYPES.GET, getEndpointUrl(serversEndpoint + id));
return dataHandler.fromJson(response, Server.class);
}

public Server createServer(Server data) throws PostmarkException, IOException {
String response = execute(HttpClient.REQUEST_TYPES.POST, getEndpointUrl("/servers"), data);
String response = execute(HttpClient.REQUEST_TYPES.POST, getEndpointUrl(serversEndpoint), data);
return dataHandler.fromJson(response, Server.class);
}

public Server setServer(Integer id, Server data) throws PostmarkException, IOException {
String response = execute(HttpClient.REQUEST_TYPES.PUT, getEndpointUrl("/servers/" + id), data);
String response = execute(HttpClient.REQUEST_TYPES.PUT, getEndpointUrl(serversEndpoint + id), data);
return dataHandler.fromJson(response, Server.class);
}

public Servers getServers(Parameters parameters) throws PostmarkException, IOException {
String response = execute(HttpClient.REQUEST_TYPES.GET, getEndpointUrl("/servers" + parameters));
String response = execute(HttpClient.REQUEST_TYPES.GET, getEndpointUrl(serversEndpoint + parameters));
return dataHandler.fromJson(response, Servers.class);
}

public String deleteServer(Integer id) throws PostmarkException, IOException {
return execute(HttpClient.REQUEST_TYPES.DELETE, getEndpointUrl("/servers/" + id));
return execute(HttpClient.REQUEST_TYPES.DELETE, getEndpointUrl(serversEndpoint + id));
}


Expand All @@ -62,35 +66,35 @@ public String deleteServer(Integer id) throws PostmarkException, IOException {
*/

public Domains getDomains(Parameters parameters) throws PostmarkException, IOException {
String response = execute(HttpClient.REQUEST_TYPES.GET, getEndpointUrl("/domains" + parameters));
String response = execute(HttpClient.REQUEST_TYPES.GET, getEndpointUrl(domainsEndpoint + parameters));
return dataHandler.fromJson(response, Domains.class);
}

public DomainDetails getDomainDetails(Integer id) throws PostmarkException, IOException {
String response = execute(HttpClient.REQUEST_TYPES.GET, getEndpointUrl("/domains/" + id));
String response = execute(HttpClient.REQUEST_TYPES.GET, getEndpointUrl(domainsEndpoint + id));
return dataHandler.fromJson(response, DomainDetails.class);
}

public DomainDetails createDomain(Domain domain) throws PostmarkException, IOException {
String response = execute(HttpClient.REQUEST_TYPES.POST, getEndpointUrl("/domains"), domain);
String response = execute(HttpClient.REQUEST_TYPES.POST, getEndpointUrl(domainsEndpoint), domain);
return dataHandler.fromJson(response, DomainDetails.class);
}

public DomainDetails setDomain(Integer id, DomainDetails domain) throws PostmarkException, IOException {
String response = execute(HttpClient.REQUEST_TYPES.PUT, getEndpointUrl("/domains/" + id), domain);
String response = execute(HttpClient.REQUEST_TYPES.PUT, getEndpointUrl(domainsEndpoint + id), domain);
return dataHandler.fromJson(response, DomainDetails.class);
}

public String deleteDomain(Integer id) throws PostmarkException, IOException {
return execute(HttpClient.REQUEST_TYPES.DELETE, getEndpointUrl("/domains/" + id));
return execute(HttpClient.REQUEST_TYPES.DELETE, getEndpointUrl(domainsEndpoint + id));
}

public String verifyDomainSPF(Integer id) throws PostmarkException, IOException {
return execute(HttpClient.REQUEST_TYPES.POST, getEndpointUrl("/domains/" + id + "/verifySPF"));
return execute(HttpClient.REQUEST_TYPES.POST, getEndpointUrl(domainsEndpoint + id + "/verifySPF"));
}

public String rotateDomainDKIM(Integer id) throws PostmarkException, IOException {
return execute(HttpClient.REQUEST_TYPES.POST, getEndpointUrl("/domains/" + id + "/rotateDKIM"));
return execute(HttpClient.REQUEST_TYPES.POST, getEndpointUrl(domainsEndpoint + id + "/rotateDKIM"));
}


Expand All @@ -99,40 +103,40 @@ public String rotateDomainDKIM(Integer id) throws PostmarkException, IOException
*/

public Signatures getSenderSignatures(Parameters parameters) throws PostmarkException, IOException {
String response = execute(HttpClient.REQUEST_TYPES.GET, getEndpointUrl("/senders" + parameters));
String response = execute(HttpClient.REQUEST_TYPES.GET, getEndpointUrl(sendersEndpoint + parameters));
return dataHandler.fromJson(response, Signatures.class);
}

public SignatureDetails getSenderSignatureDetails(Integer id) throws PostmarkException, IOException {
String response = execute(HttpClient.REQUEST_TYPES.GET, getEndpointUrl("/senders/" + id));
String response = execute(HttpClient.REQUEST_TYPES.GET, getEndpointUrl(sendersEndpoint + id));
return dataHandler.fromJson(response, SignatureDetails.class);
}

public SignatureDetails createSenderSignature(SignatureToCreate signature) throws PostmarkException, IOException {
String response = execute(HttpClient.REQUEST_TYPES.POST, getEndpointUrl("/senders"), signature);
String response = execute(HttpClient.REQUEST_TYPES.POST, getEndpointUrl(sendersEndpoint), signature);
return dataHandler.fromJson(response, SignatureDetails.class);
}

public SignatureDetails setSenderSignature(Integer id, SignatureToCreate signature) throws PostmarkException, IOException {
String response = execute(HttpClient.REQUEST_TYPES.PUT, getEndpointUrl("/senders/" + id), signature);
String response = execute(HttpClient.REQUEST_TYPES.PUT, getEndpointUrl(sendersEndpoint + id), signature);
return dataHandler.fromJson(response, SignatureDetails.class);
}

public String deleteSenderSignature(Integer id) throws PostmarkException, IOException {
return execute(HttpClient.REQUEST_TYPES.DELETE, getEndpointUrl("/senders/" + id));
return execute(HttpClient.REQUEST_TYPES.DELETE, getEndpointUrl(sendersEndpoint + id));
}

public String resendSenderSignatureConfirmation(Integer id) throws PostmarkException, IOException {
return execute(HttpClient.REQUEST_TYPES.POST, getEndpointUrl("/senders/" + id + "/resend"));
return execute(HttpClient.REQUEST_TYPES.POST, getEndpointUrl(sendersEndpoint + id + "/resend"));
}

public SignatureDetails verifySenderSignatureSPF(Integer id) throws PostmarkException, IOException {
String response = execute(HttpClient.REQUEST_TYPES.POST, getEndpointUrl("/senders/" + id + "/verifySPF"));
String response = execute(HttpClient.REQUEST_TYPES.POST, getEndpointUrl(sendersEndpoint + id + "/verifySPF"));
return dataHandler.fromJson(response, SignatureDetails.class);
}

public String requestSenderSignatureDKIM(Integer id) throws PostmarkException, IOException {
return execute(HttpClient.REQUEST_TYPES.POST, getEndpointUrl("/senders/" + id + "/requestNewDKIM"));
return execute(HttpClient.REQUEST_TYPES.POST, getEndpointUrl(sendersEndpoint + id + "/requestNewDKIM"));
}

}
Loading

0 comments on commit 5c06b01

Please sign in to comment.