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

recipients method in JourneyEmails Java class replaces date param with null value #58

Open
jwcanto opened this issue Sep 21, 2021 · 0 comments

Comments

@jwcanto
Copy link

jwcanto commented Sep 21, 2021

This causes the date to be set to the default value of the last 30 days (see Campaign Monitor's API Documentation here), instead of the date that is passed in. Where it says (MultivaluedMap)null, it should really say queryString instead, like the methods for getting the number of unsubscribes, bounces, opens, and clicks do for the Journey API.

private PagedResult<JourneyEmailRecipient> recipients(String fromDate, Integer page, Integer pageSize, String orderDirection) throws CreateSendException {
    MultivaluedMap<String, String> queryString = new MultivaluedMapImpl();
    queryString.add("date", fromDate);
    return this.jerseyClient.getPagedResult(page, pageSize, (String)null, orderDirection, (MultivaluedMap)null, new String[]{"journeys", "email", this.journeyEmailID, "recipients.json"});
}

For our project, I created a JourneyEmail Java class that extends the CreateSendBase Java class so that I could override the recipients method and replace the null value with the date that I passed in.

import com.createsend.CreateSendBase;
import com.createsend.models.PagedResult;
import com.createsend.models.journeys.JourneyEmailRecipient;
import com.createsend.util.AuthenticationDetails;
import com.createsend.util.JerseyClientImpl;
import com.createsend.util.exceptions.CreateSendException;
import com.createsend.util.jersey.JsonProvider;
import com.sun.jersey.core.util.MultivaluedMapImpl;
import javax.ws.rs.core.MultivaluedMap;
import java.util.Date;

public class JourneyEmail extends CreateSendBase {
    private final String journeyEmailID;

    public JourneyEmail(AuthenticationDetails auth, String journeyEmailID) {
        this.journeyEmailID = journeyEmailID;
        this.jerseyClient = new JerseyClientImpl(auth);
    }

    public PagedResult<JourneyEmailRecipient> recipients(Date fromDate, Integer page, Integer pageSize, String orderDirection) throws CreateSendException {
        String fromDateStr = JsonProvider.ApiDateFormat.format(fromDate);
        MultivaluedMap<String, String> queryString = new MultivaluedMapImpl();
        queryString.add("date", fromDateStr);
        return this.jerseyClient.getPagedResult(page, pageSize, null, orderDirection, queryString, new String[]{"journeys", "email", this.journeyEmailID, "recipients.json"});
    }
}
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

No branches or pull requests

1 participant