Update subscriptions
This commit is contained in:
@ -302,6 +302,49 @@ class Toku extends Ideal\Service
|
||||
return $queues;
|
||||
}
|
||||
|
||||
public function update(array $ids, ?string $type = null): array
|
||||
{
|
||||
if ($type === null) {
|
||||
$types = [
|
||||
'customers',
|
||||
'subscriptions',
|
||||
'invoices'
|
||||
];
|
||||
$results = [];
|
||||
foreach ($types as $type) {
|
||||
$results[$type] = $this->update($ids[$type], $type);
|
||||
}
|
||||
return $results;
|
||||
}
|
||||
$results = [];
|
||||
switch ($type) {
|
||||
case 'customers':
|
||||
try {
|
||||
$results['subscription'] = $this->subscription->updateByCustomer($ids);
|
||||
$results['invoice'] = $this->invoice->updateByCustomer($ids);
|
||||
} catch (EmptyResult $exception) {
|
||||
$this->logger->error($exception);
|
||||
}
|
||||
break;
|
||||
case 'subscriptions':
|
||||
try {
|
||||
$results['subscription'] = $this->subscription->update($ids);
|
||||
$results['invoice'] = $this->invoice->updateBySubscription($ids);
|
||||
} catch (EmptyResult | EmptyResponse $exception) {
|
||||
$this->logger->error($exception);
|
||||
}
|
||||
break;
|
||||
case 'invoices':
|
||||
try {
|
||||
$results['invoice'] = $this->invoice->updateAll($ids);
|
||||
} catch (EmptyResult $exception) {
|
||||
$this->logger->error($exception);
|
||||
}
|
||||
break;
|
||||
}
|
||||
return $results;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param ServerRequestInterface $request
|
||||
* @param array $tokenConfig
|
||||
|
Reference in New Issue
Block a user