/**
  * @param array|string $params May either take all params as an array or
  * the email as a string
  * @param ?string $reason Won't be used if $params is an array
  */
 public function register($params, bool $subscribed = true)
 {
     if (is_string($params)) {
         $params = ['email' => $params];
     } elseif (!is_array($params)) {
         throw new InvalidArgumentException();
     }
     if ($subscribed) {
         $params['is_subscribed'] = 1;
     }
     $result = $this->api->post('cons/email_register', $params);
     return $result;
 }
 /**
  * array|string|int $consIds
  */
 public function delete($consIds)
 {
     if (is_string($consIds)) {
         $consIds = (int) $consIds;
     }
     if (is_int($consIds)) {
         $consIds = [$consIds];
     }
     if (!is_array($consIds)) {
         throw new InvalidArgumentException();
     }
     try {
         $response = $this->api->post('cons/delete_constituents_by_id', ['cons_ids' => implode(',', $consIds)], '', false);
     } catch (DeferredException $e) {
         $response = $e->getDeferredId();
     }
     return $response;
 }
 public function process($id, $fieldData)
 {
     if (is_string($id)) {
         $id = (int) $id;
     } elseif (!is_int($id)) {
         throw new InvalidArgumentException();
     }
     $dom = new DOMDocument('1.0', 'utf-8');
     $api = $dom->createElement('api');
     $signupForm = $dom->createElement('signup_form');
     $signupForm->setAttribute('id', $id);
     foreach ($fieldData as $key => $value) {
         $field = $dom->createElement('signup_form_field', $value);
         $field->setAttribute('id', $key);
         $signupForm->appendChild($field);
     }
     $api->appendChild($signupForm);
     $dom->appendChild($api);
     return $this->api->post('signup/process_signup', [], $dom->saveXML());
 }
 private function bySlug(string $slug)
 {
     return $this->api->post('cons_group/get_constituent_group_by_slug', ['slug' => $slug]);
 }