public function changeEmail($listId, Contact $contact, $oldEmail)
    {
        // get old contact properties
        $response = $this->mailjet->get(Resources::$Contactdata, ['id' => $oldEmail]);
        if (!$response->success()) {
            $this->throwError("ContactsListManager:changeEmail() failed", $response);
        }

        // copy contact properties
        $oldContactData = $response->getData();
        if (isset($oldContactData[0])) {
            $contact->setProperties($oldContactData[0]['Data']);
        }

        // add new contact
        $contact->setAction(Contact::ACTION_ADDFORCE);
        $response = $this->_exec($listId, $contact);
        if (!$response->success()) {
            $this->throwError("ContactsListManager:changeEmail() failed", $response);
        }

        // remove old
        $oldContact = new Contact($oldEmail);
        $oldContact->setAction(Contact::ACTION_REMOVE);
        $response = $this->_exec($listId, $oldContact);
        if (!$response->success()) {
            $this->throwError("ContactsListManager:changeEmail() failed", $response);
        }

        return $response->getData();
    }
public function changeEmail($listId, Contact $contact, $oldEmail)
    {
        // get old contact properties
        $response = $this->mailjet->get(Resources::$Contactdata, ['id' => $oldEmail]);
        if (!$response->success()) {
            $this->throwError("ContactsListManager:changeEmail() failed", $response);
        }

        // copy contact properties
        $oldContactData = $response->getData();
        if (isset($oldContactData[0])) {
            $contact->setProperties($oldContactData[0]['Data']);
        }

        // add new contact
        $contact->setAction(Contact::ACTION_ADDFORCE);
        $response = $this->_exec($listId, $contact);
        if (!$response->success()) {
            $this->throwError("ContactsListManager:changeEmail() failed", $response);
        }

        // remove old
        $oldContact = new Contact($oldEmail);
        $oldContact->setAction(Contact::ACTION_REMOVE);
        $response = $this->_exec($listId, $oldContact);
        if (!$response->success()) {
            $this->throwError("ContactsListManager:changeEmail() failed", $response);
        }

        return $response->getData();
    }
public function changeEmail ( $ listId , Contact $ contact , $ oldEmail ) { // get old contact properties $ response = $ this -> mailjet -> get ( Resources :: $ Contactdata , [ 'id' => $ oldEmail ] ) ; if ( ! $ response -> success ( ) ) { $ this -> throwError ( "ContactsListManager:changeEmail() failed" , $ response ) ; } // copy contact properties $ oldContactData = $ response -> getData ( ) ; if ( isset ( $ oldContactData [ 0 ] ) ) { $ contact -> setProperties ( $ oldContactData [ 0 ] [ 'Data' ] ) ; } // add new contact $ contact -> setAction ( Contact :: ACTION_ADDFORCE ) ; $ response = $ this -> _exec ( $ listId , $ contact ) ; if ( ! $ response -> success ( ) ) { $ this -> throwError ( "ContactsListManager:changeEmail() failed" , $ response ) ; } // remove old $ oldContact = new Contact ( $ oldEmail ) ; $ oldContact -> setAction ( Contact :: ACTION_REMOVE ) ; $ response = $ this -> _exec ( $ listId , $ oldContact ) ; if ( ! $ response -> success ( ) ) { $ this -> throwError ( "ContactsListManager:changeEmail() failed" , $ response ) ; } return $ response -> getData ( ) ; }
Change email a Contact
@param string $listId
@param Contact $contact
@param string $oldEmail
Change email a Contact