-
Notifications
You must be signed in to change notification settings - Fork 119
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Configurable Root url #82
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -22,6 +22,8 @@ | |
* @since Mar 17, 2013 | ||
*/ | ||
public class MandrillApi { | ||
public static final String rootUrl = "https://mandrillapp.com/api/1.0/"; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is public because we need to default it here as well as in the other classes for backwards compatibility reasons. See below comment. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ok |
||
|
||
private String key; | ||
private final MandrillUsersApi users; | ||
private final MandrillMessagesApi messages; | ||
|
@@ -38,25 +40,32 @@ public class MandrillApi { | |
private final MandrillIpsApi ips; | ||
|
||
public MandrillApi(final String key) { | ||
this(key, rootUrl); | ||
} | ||
|
||
public MandrillApi(final String key, final String rootUrl) { | ||
if(key == null) { | ||
throw new NullPointerException( | ||
"'key' is null; please provide Mandrill API key"); | ||
|
||
} | ||
if(rootUrl == null) { | ||
throw new NullPointerException( | ||
String.format("'rootUrl' is null; please provide Mandrill URL (default: %s)", rootUrl)); | ||
} | ||
this.key = key; | ||
users = new MandrillUsersApi(key); | ||
messages = new MandrillMessagesApi(key); | ||
tags = new MandrillTagsApi(key); | ||
rejects = new MandrillRejectsApi(key); | ||
whitelists = new MandrillWhitelistsApi(key); | ||
senders = new MandrillSendersApi(key); | ||
urls = new MandrillUrlsApi(key); | ||
templates = new MandrillTemplatesApi(key); | ||
webhooks = new MandrillWebhooksApi(key); | ||
subaccounts = new MandrillSubaccountsApi(key); | ||
inbound = new MandrillInboundApi(key); | ||
exports = new MandrillExportsApi(key); | ||
ips = new MandrillIpsApi(key); | ||
users = new MandrillUsersApi(key, rootUrl); | ||
messages = new MandrillMessagesApi(key, rootUrl); | ||
tags = new MandrillTagsApi(key, rootUrl); | ||
rejects = new MandrillRejectsApi(key, rootUrl); | ||
whitelists = new MandrillWhitelistsApi(key, rootUrl); | ||
senders = new MandrillSendersApi(key, rootUrl); | ||
urls = new MandrillUrlsApi(key, rootUrl); | ||
templates = new MandrillTemplatesApi(key, rootUrl); | ||
webhooks = new MandrillWebhooksApi(key, rootUrl); | ||
subaccounts = new MandrillSubaccountsApi(key, rootUrl); | ||
inbound = new MandrillInboundApi(key, rootUrl); | ||
exports = new MandrillExportsApi(key, rootUrl); | ||
ips = new MandrillIpsApi(key, rootUrl); | ||
} | ||
|
||
/** | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,6 +8,7 @@ | |
import java.util.Date; | ||
import java.util.HashMap; | ||
|
||
import com.microtripit.mandrillapp.lutung.MandrillApi; | ||
import com.microtripit.mandrillapp.lutung.model.MandrillApiError; | ||
import com.microtripit.mandrillapp.lutung.view.MandrillExportJobInfo; | ||
|
||
|
@@ -17,11 +18,16 @@ | |
* | ||
*/ | ||
public class MandrillExportsApi { | ||
private static final String rootUrl = MandrillUtil.rootUrl; | ||
private final String key; | ||
private final String rootUrl; | ||
|
||
public MandrillExportsApi(final String key, final String url) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I wanted to modify the original constructor but since this is a public class with a public constructor that would break backwards compatibility which is why I chose overloading. |
||
this.key = key; | ||
this.rootUrl = url; | ||
} | ||
|
||
public MandrillExportsApi(final String key) { | ||
this.key = key; | ||
this(key, MandrillApi.rootUrl); | ||
} | ||
|
||
/** | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this might be able to be switched to a test only dependency. It could also be a runtime dependency of the HttpClient though so I didn't change it.