Esempio n. 1
0
 /**
  * @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;
 }
 /**
  * @param DateTime dateFilter
  */
 public function getContributions(string $type = null, $dateFilter = null)
 {
     if (!$type) {
         $type = 'all';
     }
     $filter = [];
     if (!$dateFilter) {
         $dateFilter = 'past24hours';
     } elseif (is_array($dateFilter)) {
         $filter['start'] = $dateFilter['start']->format('Y-m-d H:i:s');
         $filter['stop'] = $dateFilter['stop']->format('Y-m-d H:i:s');
         $dateFilter = 'custom';
     }
     $filter['type'] = $type;
     $filter['date'] = $dateFilter;
     try {
         $this->api->setDeferredResultMaxAttempts(60);
         $this->api->setDeferredResultInterval(10);
         $response = $this->api->get('contribution/get_contributions', ['filter' => $filter]);
     } finally {
         $this->api->setDeferredResultMaxAttempts(20);
         $this->api->setDeferredResultInterval(5);
     }
     return $response;
 }
 public function fastCount(int $id)
 {
     return $this->api->signupCount($id);
 }
 /**
  * @param array|string $params
  * @param ?string $reason
  */
 public function list()
 {
     return $this->api->get('cons_group/list_constituent_groups');
 }