Updates the given contact.

@param Contact $contact The contact to update

@return Contact

@deprecated since version 0.8, to be removed in 0.9. Use update() instead
343284
public function updateContact(Contact $contact): Contact
    {
        @trigger_error(sprintf('The %s() method is deprecated since version 0.8. Use update() instead.', __METHOD__), E_USER_DEPRECATED);

        return $this->update($contact);
    }
940038
public function addContact(array $attributes)
    {
        $attributes = $this->loadContactAttributes($attributes);

        return $this->contacts()->updateOrCreate($attributes);
    }
515968
public function updateContact($contactId, $data)
    {
        $url = $this->getApiEndpoint() . self::REST_CONTACTS . $contactId;
        $this->setUrl($url)
            ->setVerb('PUT')
            ->buildPostBody($data);

        $response = $this->execute();
        if (isset($response->message)) {
            $message = 'ERROR : UPDATE SINGLE CONTACT : ' . $url . ' message : '
                . $response->message;
            $this->helper->debug('updateContact', [$message]);
            $this->helper->debug('updateContact', $data);
        }

        return $response;
    }
314305
public function UpdateContacts(Request\UpdateContacts $UpdateContacts = null)
    {
        $uri = $this->getUri('/contact', array());

        return $this->put($uri, $UpdateContacts);
    }
1255529
public function deserialize(array $data, Contact $contact = null)
    {
        if (empty($contact)) {
            $contact = $this->contactRepo->findOneBy(['id' => $data['id']]);
        }
        if (empty($contact)) {
            $contact = new Contact();
        }
        if (isset($data['user'])) {
            $user = isset($data['user']['id']) ? $this->userRepo->findOneBy(['uuid' => $data['user']['id']]) : null;
            $contact->setUser($user);
        }
        if (isset($data['data'])) {
            $contactUser = isset($data['data']['id']) ? $this->userRepo->findOneBy(['uuid' => $data['data']['id']]) : null;
            $contact->setContact($contactUser);
        }
        $this->deserializeCategories($contact, $data['categories']);

        return $contact;
    }
800962
private function updateContact()
    {
        // Assume no attribution till calculated.
        $this->attribution = 0;

        // Do not update contacts for test runs.
        if ($this->test || !$this->payloadModel) {
            return;
        }

        // Only update contacts if success definitions are met.
        if (!$this->valid) {
            return;
        }

        try {
            $this->dispatchContextCreate();

            // Only API model currently has a map to update contacts based on the response.
            $updatedFields = false;
            if (method_exists($this->payloadModel, 'applyResponseMap')) {
                /** @var bool $updatedFields */
                $updatedFields = $this->payloadModel->applyResponseMap();
                if ($updatedFields) {
                    $this->contact = $this->payloadModel->getContact();
                }
            }

            /** @var Attribution $attribution */
            $attribution = new Attribution($this->contactClient, $this->contact, $this->payloadModel);
            /** @var bool $updatedAttribution */
            $updatedAttribution = $attribution->applyAttribution();
            if ($updatedAttribution) {
                $this->attribution = $attribution->getAttributionChange();
                $this->setLogs(strval(round($this->attribution, 4)), 'attribution');
                if ($this->attribution && method_exists($this->payloadModel, 'setAttribution')) {
                    $this->payloadModel->setAttribution($this->attribution);
                }
            } else {
                $this->setLogs('0', 'attribution');
            }
            $this->setLogs(strval(round($this->contact->getAttribution(), 4)), 'attributionTotal');

            // If any fields were updated, save the Contact entity.
            if ($updatedFields || $updatedAttribution) {
                $this->getContactModel()->saveEntity($this->contact);
                $this->setLogs('Operation successful. The contact was updated.', 'updated');
            } else {
                $this->setLogs('Operation successful, but no fields on the contact needed updating.', 'info');
            }
            if (!$updatedAttribution) {
                // Fields may have updated, but not attribution, so the ledger needs an event to capture conversions.
                $this->dispatchContextCapture();
            }
        } catch (\Exception $e) {
            $this->valid = false;
            $this->setLogs('Operation completed, but we failed to update our Contact. '.$e->getMessage(), 'error');
            $this->logIntegrationError($e, $this->contact);
            $this->retry = false;
        }
    }
882331
public function getSortedUtmTags(Contact $contact)
    {
        $tags = [];
        if ($contact instanceof Contact) {
            $utmTags = $contact->getUtmTags();
            if ($utmTags) {
                $utmTags = $utmTags instanceof ArrayCollection ? $utmTags->toArray() : $utmTags;
                /** @var \Mautic\LeadBundle\Entity\UtmTag $utmTag */
                foreach ($utmTags as $utmTag) {
                    $tags[$utmTag->getDateAdded()->getTimestamp()] = $utmTag;
                }
                ksort($tags);
            }
        }

        return $tags;
    }
555310
public function setContactId($contactId)
    {
        if ($contactId instanceof Lead) {
            $this->setContact($contactId);
        } elseif (\is_int($contactId)) {
            $this->contactId = $contactId;
        } else {
            throw new \InvalidArgumentException(
                '$contact must be an integer or instance of "\\Mautic\\LeadBundle\\Entity\\Lead"'
            );
        }

        return $this;
    }
1259676
public function update( models\Call\ContactEntry $ContactEntry){
        $rest = $this->getService( self::API_CONTACT . $ContactEntry->getId());
        $rest->PUT( $ContactEntry);

        return $rest->getResult( models\Call\ContactEntry::class);
    }
447154
public function getFirstUtmSource(Contact $contact)
    {
        $source = '';
        if (!empty($tags = $this->getSortedUtmTags($contact))) {
            $tag    = reset($tags);
            $source = trim($tag->getUtmSource());
        }

        return $source;
    }
588193
public function updateContact($contactId, array $data = [])
	{
		return $this->sendRequest(
			$this->createRequest('PATCH', sprintf('contacts/%d', $contactId), [], $data)
		);
	}
978115
public function pushLead($contact, $event = [])
    {
        $this->reset();
        $this->getEvent($event);

        if (empty($this->event['config']['contactclient'])) {
            return false;
        }

        /** @var Contact $contactModel */
        $clientModel = $this->getContactClientModel();
        $client      = $clientModel->getEntity($this->event['config']['contactclient']);

        $this->sendContact($client, $contact, false);

        // Returning false will typically cause a retry.
        // If an error occurred and we do not wish to retry we should return true.
        return $this->valid ? $this->valid : !$this->retry;
    }
830268
public function saveContact(contact $contact)
    {
        $contact->save();
        foreach ($this->contacts as $k => $contactdb) {
            if ($contactdb->id == $contact->id) {
                $this->contacts[$k] = $contact;

                return;
            }
        }
        $this->contacts[] = $contact;
    }
1052634
protected function extractContacts(Contact $contact)
    {
        $result = [];

        foreach ($this->languages as $language) {
            $result[$language] = $this->contactLocalization($contact, $language);
        }

        return $result;
    }
250966
protected function form(Contact $contact)
    {
        $countries = collect(countries())->map(function ($country, $code) {
            return [
                'id' => $code,
                'text' => $country['name'],
                'emoji' => $country['emoji'],
            ];
        })->values();
        $languages = collect(languages())->pluck('name', 'iso_639_1');
        $sources = app('rinvex.contacts.contact')->distinct()->get(['source'])->pluck('source', 'source')->toArray();
        $methods = app('rinvex.contacts.contact')->distinct()->get(['method'])->pluck('method', 'method')->toArray();
        $genders = ['male' => trans('cortex/contacts::common.male'), 'female' => trans('cortex/contacts::common.female')];

        return view('cortex/contacts::managerarea.pages.contact', compact('contact', 'genders', 'countries', 'languages', 'sources', 'methods'));
    }
274816
public function processEmails($contact, $emails)
    {
        $get = function($email) {
            /* @var Email $email */

            return $email->getId();
        };

        $delete = function($email) use ($contact) {
            return $contact->removeEmail($email);
        };

        $update = function($email, $matchedEntry) {
            return $this->updateEmail($email, $matchedEntry);
        };

        $add = function($email) use ($contact) {
            return $this->addEmail($contact, $email);
        };

        $entities = $contact->getEmails();

        $result = $this->processSubEntities(
            $entities,
            $emails,
            $get,
            $add,
            $update,
            $delete
        );

        $this->resetIndexOfSubentites($entities);

        // check main
        $this->setMainEmail($contact);

        return $result;
    }
1067138
public function setContactIdVersion($v)
    {
        if ($v !== null) {
            $v = (int) $v;
        }

        if ($this->contact_id_version !== $v) {
            $this->contact_id_version = $v;
            $this->modifiedColumns[DealerContactInfoVersionTableMap::CONTACT_ID_VERSION] = true;
        }


        return $this;
    }