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

getAllAsModel ignores filters #111

Open
Drachenkaetzchen opened this issue Oct 27, 2015 · 3 comments
Open

getAllAsModel ignores filters #111

Drachenkaetzchen opened this issue Oct 27, 2015 · 3 comments

Comments

@Drachenkaetzchen
Copy link

I try to retrieve all clients matching a given email address, so I don't create duplicate clients by accident:

$client = new Client();
$client->setFilter(array("email" => "example@example.com"));

$response = $request->getAllAsModel($client);

However, the getAllAsModel() call returns all clients and ignores the filter.

If I change getAllAsModel to getAll, I receive the expected result.

@mgleis
Copy link

mgleis commented Jan 5, 2016

Same for Transaction objects :-(

Solution: add the following code to the request classes in \Paymill\Models\Request*

        case 'getAll':
        case 'getAllAsModel':    // <-- this line is new
            $parameterArray = $this->getFilter();
            break;

Please add this ;-)

@mgleis
Copy link

mgleis commented Jan 5, 2016

Workaround until bug is fixed: call getAll and convert yourself:

$client = new Client(); 
$client->setFilter(array("email" => "example@example.com"));
$response = $request->getAll($client);
$clients = [];
foreach ($response as $entry) {
    $clients[] = $r->convertResponse($entry, $client->getServiceResource());
}

@danielsippel
Copy link

+1

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

3 participants