mailjet / mailjet-apiv3-php

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

Is there a filter for get contact to ignore deleted contacts? #212

Closed jutho-agentur closed 3 years ago

jutho-agentur commented 3 years ago

Hi there,

I'm new to mailjet and trying to use the API. By getting a list of my contacts I always get the deleted contacts too. Is there a way to set a filter for only active contacts?

$response = $mj->get(Resources::$Contact); $success=$response->success();

I'm looking for something like that:

$response = $mj->get(Resources::$Contact, ['filter' => ['deleted' => false]]); $success=$response->success();

Anyone ideas?

My problem is that we have around 6k deleted contacts and when I'm getting a list of them I always get the deleted ones too... That is really bad!

uavn commented 3 years ago

@jutho-agentur So there is no such filter at MailJet, all you can do is filter them after you get them all:

$response = $mj->get(Resources::$Contact);
$nonDeletedContacts = array_filter($response->getData(), function(array $contact) {
    return false === strpos($contact['Email'], '@domain.invalid');
//    or
//    return 'Anonymized' !== $contact['Name'];
});

print_r($nonDeletedContacts);die;