package com.mailgun.api;

import com.sun.jersey.api.client.Client;
import com.sun.jersey.api.client.WebResource;
import com.sun.jersey.api.client.filter.HTTPBasicAuthFilter;

import java.net.URI;

public class MailGunClient {

    private String domain;

	private String apiEndpoint = "api.mailgun.net";
	public static final String API_VERSION = "v2";
	
	protected Client client;
	protected WebResource service;
	
	public MailGunClient(String apiKey, String domain) {
        this.domain = domain;
		this.client = Client.create();
		this.client.addFilter(new HTTPBasicAuthFilter("api", apiKey));
		this.service = this.client.resource(getBaseUri());
	}
	
	public URI getBaseUri() {
		return URI.create(String.format("https://%s/%s/%s", this.apiEndpoint, API_VERSION, this.domain));
	}

	public String getApiEndpoint() {
		return this.apiEndpoint;
	}

	public void setApiEndpoint(String apiEndpoint) {
		this.apiEndpoint = apiEndpoint;
	}

	public String getDomain() {
		return this.domain;
	}

	public void setDomain(String domain) {
		this.domain = domain;
	}
}

@@ -60,16 +60,65 @@
 Client;%0A
+import com.sun.jersey.api.client.ClientResponse;%0A
 import c
@@ -217,16 +217,56 @@
 ilter;%0A%0A
+import javax.ws.rs.core.MultivaluedMap;%0A
 import j
@@ -1141,11 +1141,288 @@
 main;%0A%09%7D
+%0A%0A    public ClientResponse get(String path)%7B%0A        return this.service.path(path).get(ClientResponse.class);%0A    %7D%0A%0A    public ClientResponse get(String path, MultivaluedMap params)%7B%0A        return this.service.path(path).queryParams(params).get(ClientResponse.class);%0A    %7D
 %0A%7D%0A

add jersey client response methods