@param $list_id
@param int $days

@return array|\SimpleXMLElement|string
@throws Exception

API documentation: https://whatcounts.zendesk.com/hc/en-us/articles/204670135
508890
public function showOptouts($list_id, $days = 30)
		{
			$form_data = array(
				'list_id' => $list_id,
				'days' => $days
			);
			$xml = $this->call('show_optout', $form_data);

			return $xml;
		}
483054
public function findById($listId)
    {
        $listData = $this->mailchimp->get("lists/$listId");

        if (!$this->mailchimp->success()) {
            $this->throwMailchimpError($this->mailchimp->getLastResponse());
        }
        return $listData;
    }
34261
private function prepareListBuilder(array $fieldDescriptors, Request $request, ListBuilderInterface $listBuilder)
    {
        $restHelper = $this->get('sulu_core.doctrine_rest_helper');
        $restHelper->initializeListBuilder($listBuilder, $fieldDescriptors);
        $listBuilder->addSelectField($fieldDescriptors['handlerClass']);
        $listBuilder->addSelectField($fieldDescriptors['taskId']);

        if ($entityClass = $request->get('entity-class')) {
            $listBuilder->where($fieldDescriptors['entityClass'], $entityClass);
        }

        if ($entityId = $request->get('entity-id')) {
            $listBuilder->where($fieldDescriptors['entityId'], $entityId);
        }

        if ($locale = $request->get('locale')) {
            $listBuilder->where($fieldDescriptors['locale'], $locale);
        }

        if ($handlerClasses = $request->get('handler-class')) {
            $handlerClassList = explode(',', $handlerClasses);
            if (0 < count($handlerClassList)) {
                $listBuilder->in($fieldDescriptors['handlerClass'], $handlerClassList);
            }
        }

        if (null !== ($schedule = $request->get('schedule'))
            && in_array($schedule, array_keys(self::$scheduleComparators))
        ) {
            $listBuilder->where($fieldDescriptors['schedule'], new \DateTime(), self::$scheduleComparators[$schedule]);
        }

        return $listBuilder;
    }
704244
public static function calFromJd($julian_day, $calendar_id)
    {
        switch ($calendar_id) {
            case CAL_FRENCH:
                return self::calFromJdCalendar($julian_day, self::jdToFrench($julian_day), self::$MONTH_NAMES_FRENCH, self::$MONTH_NAMES_FRENCH);

            case CAL_GREGORIAN:
                return self::calFromJdCalendar($julian_day, self::jdToGregorian($julian_day), self::$MONTH_NAMES, self::$MONTH_NAMES_SHORT);

            case CAL_JEWISH:
                $months = self::jdMonthNameJewishMonths($julian_day);

                $cal = self::calFromJdCalendar($julian_day, self::jdToCalendar(self::$jewish_calendar, $julian_day, 347998, 324542846), $months, $months);

                if (($julian_day < 347998 || $julian_day > 324542846) && !self::shouldEmulateBug67976()) {
                    $cal['dow'] = null;
                    $cal['dayname'] = '';
                    $cal['abbrevdayname'] = '';
                }

                return $cal;

            case CAL_JULIAN:
                return self::calFromJdCalendar($julian_day, self::jdToJulian($julian_day), self::$MONTH_NAMES, self::$MONTH_NAMES_SHORT);

            default:
                return trigger_error('invalid calendar ID ' . $calendar_id, E_USER_WARNING);
        }
    }
75762
public function getIndex($listUuid = null)
    {
        $lt = self::LIST_ELEMENT_TABLE_NAME;
        $lc = self::LIST_COLLECTION_TABLE_NAME;

        $sql = 'SELECT
                `'.$lc.'`.`uuid`,
                `'.$lc.'`.`headers`,
                `'.$lc.'`.`created_at`
                FROM `'.$lt.'` 
                INNER JOIN `'.$lc.'` 
                ON `'.$lt.'`.`list` = `'.$lc.'`.`uuid`';

        if ($listUuid) {
            $sql .= 'WHERE `'.$lc.'`.`uuid` = :list';
        }

        $stmt = $this->pdo->prepare($sql);
        if ($listUuid) {
            $stmt->bindParam(':list', $listUuid);
        }
        $stmt->execute();

        $list = $stmt->fetchAll(\PDO::FETCH_ASSOC);

        $index = [];

        foreach ($list as $item) {
            $index[$item['uuid']] = [
                'uuid' => $item['uuid'],
                'created_on' => \DateTime::createFromFormat('Y-m-d H:i:s.u', $item['created_at']),
                'size' => $this->getCounter($item['uuid']),
                'chunks' => 0,
                'chunk-size' => 0,
                'headers' => $this->getHeaders($item['uuid']),
                'ttl' => 0,
            ];
        }

        return $index;
    }
640426
public static function dayList($length = 0)
    {
        $dayNameArray = explode(',', $this->dayNames);
        for ($i = 1; $i <= 7; $i++) {
            if ($length == 0) {
                $dayList[$i] = trim($dayNameArray[$i - 1]);
            } else {
                $dayList[$i] = substr(trim($dayNameArray[$i - 1]), 0, $length);
            }
        }

        return $dayList;
    }
1080743
public function getDays() {
    $query = \Drupal::entityQuery('day');
    $query->condition('league', $this->id());
    $query->sort('id', 'ASC');
    $ids = $query->execute();

    return Day::loadMultiple($ids);
  }
349357
private function _toFormatTree($list, $level = 0)
    {
        $formatTree = [];
        foreach ($list as $val) {
            $tmp_str = str_repeat($this->tabSize, $level);
            $tmp_str .= "└&nbsp;";
            
            $val['level'] = intval($level);
            $val[$this->showTitleField] = $level == 0 ? $val[$this->showTitleField] : $tmp_str . $val[$this->showTitleField];
            if (!array_key_exists('_child', $val)) {
                array_push($formatTree, $val);
            } else {
                $tmp_ary = $val['_child'];
                unset($val['_child']);
                array_push($formatTree, $val);
                $formatTree = array_merge($formatTree, $this->_toFormatTree($tmp_ary, $level + 1));
            }
        }
        
        return $formatTree;
    }
1358382
protected function mapEntityList(array $list, $rowElementName = null)
    {
        if (is_null($rowElementName)) {
            $rowElementName = 'row';
        }
        $xml = '';
        $no = 1;
        foreach ($list as $element) {
            $xml .= '<' . $rowElementName . ' no="' . $no++ . '">';
            $xml .= $this->mapSingleEntity($element);
            $xml .= "</$rowElementName>";
        }

        return $xml;
    }
371671
public static List<String> getDayListBetween2Day(String startDate, String endDate, Format format) {
        List<String> dayList = new ArrayList<String>();
        int dataNum = Integer.parseInt(getTwoDay2String(startDate, endDate, format));
        for (int i = 0; i < (dataNum + 1); i++) {
            String resultDate = getNextDay2String(startDate, String.valueOf(i), format);
            dayList.add(resultDate);
        }
        return dayList;
    }
239738
public static function getChoices($format = 'ShortName', $day_of_week_numbers = array(1,2,3,4,5,6,7))
    {
        switch ($format)
        {
            case 'ShortName':
            case 'FirstLetter':
            case 'LongName':

                $method = 'get'.$format;
        }

        $choices = array();

        foreach ($day_of_week_numbers as $day_of_week_number)
        {
            $dayOfWeek = new self($day_of_week_number);

            $choices[$day_of_week_number] = $dayOfWeek->$method();
        }

        return $choices;
    }
806926
def list_id(self):
        
        list_id = getattr(self, '_list_id', None)

        if list_id is None:
            for l in self.api.lists.all()['lists']:
                if l['name'] == self.list_name:
                    self._list_id = l['id']

            if not getattr(self, '_list_id', None):
                self._list_id = self.api.lists.create(
                    label=self.list_label, name=self.list_name,
                    method='POST')['list_id']

        return self._list_id
528295
public static function daysList($days)
    {
        foreach($days as $day)
        {
            // if it isn't negative, it's positive
            $day = ltrim($day, "+");
            $day = trim($day);

            $ordwk = 1;
            $weekday = false;

            if (strlen($day) === 2)
            {
                $weekday = $day;
            }
            else
            {
                list($ordwk, $weekday) = sscanf($day, "%d%s");
            }

            if (!self::weekDay($weekday) || !self::ordWk(abs($ordwk)))
            {
                return false;
            }
        }

        return true;
    }
1316402
public static function getRequestedTodayByIp(string $ip, int $type_id)
    {
        $query = self::find()
            ->where([
                'ip' => $ip,
                'is_validated' => 0,
                'is_deleted' => 0,
            ])
            ->andWhere(['between', 'created_at', time() - DateHelper::TIME_DAY_ONE, time()])
            ->andWhere(['type_id' => $type_id]);

        return $query->count();
    }
1291762
protected function getListRepresentation($id, $request)
    {
        $locale = $request->get('locale');

        /** @var RestHelperInterface $restHelper */
        $restHelper = $this->get('sulu_core.doctrine_rest_helper');

        /** @var DoctrineListBuilderFactory $factory */
        $factory = $this->get('sulu_core.doctrine_list_builder_factory');

        $listBuilder = $factory->create($this->container->getParameter('sulu_product.product_entity'));
        $fieldDescriptors = $this->getManager()->getFieldDescriptors($locale);
        $listBuilder->where($fieldDescriptors['product'], $id);

        $restHelper->initializeListBuilder(
            $listBuilder,
            $fieldDescriptors
        );

        $listResponse = $listBuilder->execute();
        $listResponse = $this->addThumbnails($listResponse, $locale);

        $list = new ListRepresentation(
            $listResponse,
            'media',
            'cget_product_media',
            array_merge(['id' => $id], $request->query->all()),
            $listBuilder->getCurrentPage(),
            $listBuilder->getLimit(),
            $listBuilder->count()
        );

        return $list;
    }
1274833
protected function formatDay(): string
    {
        $locale = app(LocaleInterface::class)->language()->code();

        if ($locale === 'he' || $locale === 'yi') {
            return (new JewishCalendar())->numberToHebrewNumerals($this->day, true);
        }

        return parent::formatDay();
    }
1102532
def _set_list_ids_from_xml_iter(self, xml, xmlpath, var):
        '''
        
        '''
        es = xml.iterfind(xmlpath)
        if es is not None:
            l = []
            for e in es:
                l.append( e.attrib['frameid'] )
            
            setattr(self, var, l)