/** * Update an individual contact * @param string $accessToken - Valid access token * @param Contact $contact - Contact to update * @param boolean $actionByVisitor - is the action being taken by the visitor, default is false * @return Contact */ public function updateContact($accessToken, Contact $contact, $actionByVisitor = false) { $params = array(); if ($actionByVisitor == true) { $params['action_by'] = "ACTION_BY_VISITOR"; } return $this->contactService->updateContact($accessToken, $contact, $params); }
if ($contact->getId() == null || $contact->getId() == -1) { return error($response, 'UPDATE A CONTACT WITH NO ID IS NOT POSSIBLE'); } if ($contact->getExchangeId() == null || $contact->getExchangeId() == -1 || $contact->getExchangeId() == "") { return error($response, 'UPDATE A CONTACT WITH NO EXCHANGE ID IS NOT POSSIBLE'); } $contactService = new ContactService(); $exchangeService = new ExchangeService(); $deletedFromExchange = $exchangeService->deleteContact($contact); if (!$deletedFromExchange) { return error($response, 'ERROR DURING UPDATING IN EXCHANGE'); } if (!$exchangeService->addContact($contact)) { return error($response, 'ERROR DURING UPDATING IN EXCHANGE'); } if (!$contactService->updateContact($contact)) { return error($response, 'ERROR DURING UPDATING IN DATABASE'); } return $response->write(json_encode("ok", true)); } catch (Exception $e) { error_log($e->getMessage()); } return error($response, ' UPDATE CONTACT UNKNOWN ERROR'); }); $app->post('/deleteContact', function (\Slim\Http\Request $request, \Slim\Http\Response $response, $args) use($app) { try { if (!has_access($request)) { return access_denied($response); } $requestData = $request->getBody()->getContents(); $data = json_decode($requestData, true);