Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot assign offset 'attributes' to Brevo\Client\Model\UpdateContact. #28

Open
johnkhansrc opened this issue Jul 1, 2024 · 1 comment

Comments

@johnkhansrc
Copy link

When I update the attributes of a Brevo contact as described in the documentation (https://developers.brevo.com/reference/updatecontact) PHPStan reports the following violation :

Cannot assign offset 'attributes' to Brevo\Client\Model\UpdateContact.

try {
            $identifier = '[email protected]';
            $updateContact = new UpdateContact();
            $updateContact['attributes'] = ['EMAIL'=>'[email protected]', 'FIRSTNAME'=>'John Doe'];

            $this->contactEndpoint->updateContact($identifier, $updateContact);
        } catch (\Exception $e) {
            $this->brevoLogger->error('Error while updating contact on SendinBlue', ['exception' => $e]);
        }

What is the correct way to modify a contact's attributes?

@Farrusc0
Copy link

Farrusc0 commented Jul 8, 2024

Hello! I'm not sure if this will help, but I use the following approach, and it works like a charm.

try {

            $identifier = '[email protected]'; // string | Email (urlencoded) OR ID of the contact

            $updateContact = new \Brevo\Client\Model\UpdateContact();

            $updateContact->setAttributes( ['EMAIL'=>'[email protected]', 'FIRSTNAME'=>'John Doe']);

            $this->instance->updateContact($identifier, $updateContact);

        } catch (Exception $e) {

            $this->Log->content(["Exception in ", __METHOD__, $e->getMessage(), PHP_EOL])->saveToFile()->andExit();

        }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants