mailjet / mailjet-apiv3-php

[API v3] Mailjet PHP Wrapper
http://dev.mailjet.com
MIT License
267 stars 86 forks source link

Call to undefined method Mailjet\LaravelMailjet\Model\Contact::setProperties() #251

Closed ValCanBuild closed 2 years ago

ValCanBuild commented 2 years ago

I'm trying to use the ContactListService.updateEmail() method to update the emails of users on my list. But since updating to Laravel 9 and the the latest client version (3.0.2) this is failing each time with the error:

Call to undefined method Mailjet\LaravelMailjet\Model\Contact::setProperties() It's failing on in this part

    public function updateEmail(string $id, Contact $contact, string $oldEmail): array
    {
        $response = $this->mailjet->get(Resources::$Contactdata, ['id' => $oldEmail]);

        if (! $response->success()) {
            throw new MailjetException(0, 'ContactsListService:changeEmail() failed', $response);
        }

        $oldContactData = $response->getData();

        if (isset($oldContactData[0])) {
            $contact->setProperties($oldContactData[0]['Data']);
        }
        ....
}

When I look at the Contact model and it looks like it doesn't have a setProperties method so this error makes sense. Perhaps it needs to be setOptionalProperties instead?

Seems like a bug in the code that needs fixed?

ValCanBuild commented 2 years ago

Apologies, meant to raise this on the laravel-mailjet repo: https://github.com/mailjet/laravel-mailjet/issues/60