public function getCards2024(): array
{
$cards = [];
$limit = 100;
$cursor = [
'limit' => $limit
];
do {
$res = $this->curlQuery(
self::API_SUPPLIERS,
self::METHOD_POST,
'content/v2/get/cards/list',
[
'settings' => [
'sort' => [
'ascending' => false
],
'cursor' => $cursor,
'filter' => ['withPhoto' => -1]
]
]
);
if(!is_array($res) || !isset($res['cards'])) {
throw new \ErrorException('WB returns wrong answer');
}
$cards = array_merge($cards, $res['cards']);
$cursor['updatedAt'] = $res['cursor']['updatedAt'];
$cursor['nmID'] = $res['cursor']['nmID'];
} while($res['cursor']['total'] >= $limit);
return $cards;
}
private function makeLowIdList($array)
{
return array_flip(array_map(fn($value) => mb_convert_case($value, MB_CASE_LOWER), $array));
}
private function getId($idList, $title, $label)
{
$lowTitle = mb_convert_case($title, MB_CASE_LOWER);
if(!array_key_exists($lowTitle, $idList)) {
throw new Exception('wrong ' . $label . ': ' . $title);
}
return $idList[$lowTitle];
}
public function import($data)
{
$payerIds = $this->makeLowIdList(Payer::getTitles());
foreach(...) {
try {
...
$payerId = $this->getId($payerIds, $row['payer'], $row['orderNumber'] . ' payer');
...
} catch(Exception $e) {
$error = $e->getMessage();
if(!in_array($error, $errors)) {
$errors[] = $error;
}
}
}
return $errors;
}
появилась проблема что не читает кирилицу
convert -list format
покажет, что у IM с поддержкой этого формата.MSVG SVG rw+ ImageMagick's own SVG internal renderer
SVG SVG rw+ Scalable Vector Graphics (XML 2.9.4)
SVGZ SVG rw+ Compressed Scalable Vector Graphics (XML 2.9.4)
/etc/ImageMagick-6/policy.xml
запрещено конвертировать из этого формата ввиду теоретических эксплойтов. switch($functionName) {
case 'index': return index();
case 'store': return store();
}
$registry = array(
'index' => new ActionIndex(),
'store' => new ActionStore()
)
$registry[$functionName]->run();