Skip to content
This repository has been archived by the owner on Feb 1, 2024. It is now read-only.

Example of setting or updating the grouping information on a subscriber #24

Open
ghost opened this issue Jul 6, 2014 · 2 comments
Open

Comments

@ghost
Copy link

ghost commented Jul 6, 2014

Hi,

First, thanks for the library — I’d be dead in the water without it.

Second, I’d like to reopen the very first issue/question raised [#1 Updating grouping for existing or new subscriber]:
It would be great if you could include an example (e.g. in the unit tests) of
setting or updating the grouping information on a subscriber, for instance when
adding a new subscriber via listSubscribe using GROUPINGS in merge_vars.

The problem is that the link in the response to that question is broken:

https://github.com/Ecwid/ecwid-mailchimp/blob/master/src/test/java/com/ecwid/mailchimp/method/list/InterestGroupingMethodsTest.java

And in the current download, there are no tests, only a folder containing logging.properties.

I’ve gotten the basic ‘subscribe a person to a list’ working following your wiki code. But I can’t work out how to utilize/combine the various [List]InterestGroup[ings]Method objects with SubscribeMethod or UpdateMemberMethod.

Regards,
Ken

@jo-elimu
Copy link

jo-elimu commented Apr 4, 2016

Hi, I'm struggling with the same thing. I'm iterating to the relevant MemberInfoGroups, update them, and execute the request, but the changes are not reflected on the MailChimp server...

    UpdateMemberMethod updateMemberMethod = new UpdateMemberMethod();
    updateMemberMethod.apikey = API_KEY;
    updateMemberMethod.id = LIST_ID;
    updateMemberMethod.email = new Email();
    updateMemberMethod.email.email = email;

    MemberInfoData memberInfoData = new MailChimpSubscriptionHelper().getMemberInfoData(email);
    List<MemberInfoGrouping> memberInfoGroupings = (List<MemberInfoGrouping>) memberInfoData.merges.get("GROUPINGS");
    for (MemberInfoGrouping memberInfoGrouping : memberInfoGroupings) {
        // Update relevant MemberInfoGroups (set attribute "interested" = true)
    }
    logger.info("memberInfoGroupings: " + memberInfoGroupings);
    MailChimpObject mergeVars = new MailChimpObject();
    mergeVars.put("GROUPINGS", memberInfoGroupings.toString());
    updateMemberMethod.merge_vars = mergeVars;

    updateMemberMethod.replace_interests = true;

    MailChimpClient mailChimpClient = new MailChimpClient();
    try {
        mailChimpClient.execute(updateMemberMethod);
    } catch (IOException | MailChimpException ex) {
        logger.error(null, ex);
    }

@kejdiB
Copy link

kejdiB commented Sep 16, 2020

you have to include the API_KEY into mialchimp client
MailChimpClient mailChimpClient = new MailChimpClient(lYOUR_API_KEY);

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants