mailchimp-api-php icon indicating copy to clipboard operation
mailchimp-api-php copied to clipboard

Fix #58

Open collinhaines opened this issue 8 years ago • 6 comments

This will allow users to use Views Bulk Operations to add subscribed members to an already-created static segment.

A subsequent mailchimp.module patch for adding users will appear on drupal.org.

collinhaines avatar Jun 09 '17 20:06 collinhaines

The function already has 5 parameters which is already too many. Is there a way to solve this without adding a 6th?

Greg-Boggs avatar Jun 09 '17 20:06 Greg-Boggs

I attempted to remove (object) entirely but I'm not familiar with MailChimp API enough to know what other submodules require it.

collinhaines avatar Jun 09 '17 20:06 collinhaines

There's already an options array. Could this feature be one of the keys on the options array?

Greg-Boggs avatar Jun 09 '17 20:06 Greg-Boggs

The problem lies with the object casting. It converts

$array = array(
  'members_to_add' => array(
    '[email protected]'
  )
);

into {"members_to_add":{"0":"[email protected]"}} instead of {"members_to_add":["[email protected]"]} like the example gives in the docs.

collinhaines avatar Jun 09 '17 20:06 collinhaines

Actually, we'd want the opposite so it doesn't change the existing behavior

if ($options['convert_to_object']) {
          $options['json'] = (object) $parameters;
} else {
          $options['json'] = $parameters;
}

Greg-Boggs avatar Jun 09 '17 21:06 Greg-Boggs

Ok, I believe this is ready to be reviewed. I have another PR ready for the addSegment() function that follows this code.

collinhaines avatar Jun 14 '17 12:06 collinhaines