Skip to content
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

Create a basic mailchimp client #1

Merged
merged 12 commits into from
Nov 29, 2017
Merged

Conversation

TickleThePanda
Copy link
Contributor

@TickleThePanda TickleThePanda commented Aug 11, 2017

mailing-list-client - This project provides an API for integrating with a mailing list service. It provides an implementation of the API for Mailchimp.

mailchimp-webhooks - This project provides an small example Spring Boot client that can listen to webhooks from Mailchimp that register user details changing in Mailchimp.

Things it doesn't address yet:

import org.springframework.boot.autoconfigure.SpringBootApplication;

@SpringBootApplication
@EnableAutoConfiguration

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't be necessary


private static final Logger LOGGER = LogManager.getLogger();

@GetMapping()

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are the brackets necessary?

import java.util.Set;

/**
* An client for mailing lists service with the following functionality:

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A client

return DigestUtils.md5Hex(email.toLowerCase());
}

private final MailchimpInternalHttpClient httpClient;

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could we move this private field right to the top of the class and then move the private constructor to just below getInstance?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What about moving the convertEmailToId to the top instead, I think that improves the readability more?

* Configuration for the Mailchimp client.
*/
public class MailchimpClientConfiguration {
private static final String SCHEME = "https";

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would any of these benefit from being pulled out into a properties file of some kind, but with the ability to use these values as the defaults if a value isn't provided in the properties file?

Or if not possible due to this being a reusable component, have a builder that can be used to create the configuration, again using these values as the defaults if none are setup using the builder's methods?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think there's any benefit from these being pulled out into a properties file; if any of this changes then it would have been a major/breaking change on the mailchimp side of the API and I guess a lot of our code would change with that. Mailchimp still have their old versions of their API running in the same location as well - I just wanted it to be more explicit here what each of these values meant.

}

private <T> T doRequest(HttpUriRequest request, Class<T> responseClass) throws MailingListClientException {
LOG.debug("making {} request for {}", request::getMethod, request::getURI);

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it worth adding something to the logging page to say that method references should be used for debug logging for performance...or should it be assumed knowledge?

*/
@GetMapping
@ResponseBody
public void handshake() {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you need the @ResponseBody?

*
* @param listId the ID of the list from which the member will be
* removed from
* @param email the email of the member who will be removed
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

throws exception if deletion failed

test what happens when a non-existent user is removed from list

public static MailchimpInternalHttpClient getInstance(MailchimpClientConfiguration configuration) {

CredentialsProvider provider = new BasicCredentialsProvider();
Credentials credentials = new UsernamePasswordCredentials("user", configuration.getApiKey());
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

comment saying that mailchimp doesn't care about what the user is


private final MailchimpClientConfiguration configuration;

MailchimpInternalHttpClient(
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Comment warning that this should not be used.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Deprecated annotation

}

// dash is required in the api key
private static final MailchimpClientConfiguration config = new MailchimpClientConfiguration("abcd-ab1");
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Check variable name

}

@Nested
@DisplayName("a non-existant member")

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

non-existent

Copy link

@srconway srconway left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Spotted a typo but as it's in the tests it's not vital to fix.

@TickleThePanda TickleThePanda merged commit 3eea05d into develop Nov 29, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants