json = $json; $this->requestService = $requestService; $this->customerRepository = $customerRepository; $this->changeQuoteControl = $changeQuoteControl; } /** * POST for disableAccounts api * @param string $email * @param string $secret * @param string $ids */ public function postDisableAccounts($email, $secret, $ids) { return $this->requestService->post( $email, $secret, [$this, 'disableAccounts'], ['ids' => $this->json->unserialize($ids)] ); } /** * {@inheritdoc} */ public function disableAccounts($ids) { $result = []; foreach ($ids as $id) { try { $customer = $this->customerRepository->getById($id); $customer->setGroupId(5); $customer->setConfirmation('non-empty string'); $this->changeQuoteControl->forceIsAllowed(true); $this->customerRepository->save($customer); $result[] = array('account' => $customer->getEmail(), 'error' => NULL); } catch (\Exception $e) { $result[] = array('account' => isset($customer) ? $customer->getEmail() : $id, 'error' => $e->getMessage()); } } return $result; } }