/**
  * listUnsubscribe
  * Unsubscribe the user from the mailing list. Does not remove the user, just sets status to unsubscribed.
  * 
  * @param listid is the id for the list
  * @param email_address is the email address subscribed in mailchimp
  * @return false in case of an error
  */
 public static function listUnsubscribe($listid, $email_address, $externaluserargs = null, $email_type = 'html', $memberlist = null)
 {
     global $CFG;
     require_once $CFG->dirroot . '/blocks/mailchimp/classes/MailChimp.php';
     if (!isset($CFG->block_mailchimp_apicode)) {
         return false;
     }
     $memberid = helper::getMemberID($listid, $email_address, $memberlist);
     if (!$memberid) {
         //If member is not already present in the list, add them to the list with an unsubscribed status.
         $method = "lists/" . $listid . "/members";
         if (!($api = new \DrewM\MailChimp\MailChimp($CFG->block_mailchimp_apicode))) {
             debugging("ERROR: Unable to create mailchimp wrapper object \\DrewM\\MailChimp\\MailChimp.");
             return false;
         }
         $args = array('email_address' => strtolower($email_address), 'email_type' => $email_type, 'status' => 'unsubscribed', 'VIP' => false, 'merge_fields' => array('FNAME' => $externaluserargs['FNAME'], 'LNAME' => $externaluserargs['LNAME']));
         if (!$api->post($method, $args)) {
             debugging("ERROR: Unable to add unsubscribed user " . $email_address . " to mailchimp, method: " . $method);
             return false;
         }
         return true;
     }
     // Member is present in the list, update the status to unsubscribed.
     $method = "lists/" . $listid . "/members/" . $memberid;
     if (!($api = new \DrewM\MailChimp\MailChimp($CFG->block_mailchimp_apicode))) {
         debugging("ERROR: Unable to create mailchimp wrapper object \\DrewM\\MailChimp\\MailChimp.");
         return false;
     }
     $args = array('email_address' => strtolower($email_address), 'status' => 'unsubscribed');
     if (!$api->patch($method, $args)) {
         debugging("ERROR: Unable to unsubscribe mailchimp user " . $email_address . ", method: " . $method);
         return false;
     }
     return true;
 }