requestService = $requestService; $this->customerRepository = $customerRepository; $this->changeQuoteControl = $changeQuoteControl; } /** * {@inheritdoc} */ public function postDeny($email, $secret, $id, $customer_group) { return $this->requestService->post( $email, $secret, [$this, 'deny'], ['id' => $id, 'customer_group' => $customer_group] ); } /** * {@inheritdoc} */ public function deny($id, $customer_group) { $result = []; $groups = [ 'Enduser' => 5, 'Competitor' => 6, 'Other' => 7, ]; try { $customer = $this->customerRepository->getById($id); $customer->setCustomAttribute('sales_rep', ''); $customer->setGroupId(array_key_exists($customer_group, $groups) ? $groups[$customer_group] : 7); $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; } }