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

Getting a batch with objects #9

Open
Niels-P opened this issue Apr 7, 2019 · 1 comment
Open

Getting a batch with objects #9

Niels-P opened this issue Apr 7, 2019 · 1 comment

Comments

@Niels-P
Copy link

Niels-P commented Apr 7, 2019

Hi RMUit,

I'm currently using your library to get the resources from a connector. The resource should have 1692 entries in it. I use your helper function getDataBatch to do it in batches. I'm using the REST API of AFAS. I get the following error;

Afas GetConnector returned a non-array value. (Has an unsupported Outputmode option been set?)

Which makes sense, because when debugging AFAS returns null. So for some reason it doesn't find any entities in the batch. I'm using the following code;

$client = new RestCurlClient( [ 'customerId' => ****, 'appToken' => '*****' ] );
$connection = new Connection($client);
$helper = new Helper();

$results = ['subtotal' => 0, 'finished' => false];
$test = 0;
do {
     $data = $helper->getDataBatch(['connection' => $connection, 'connector' => '****', 'id_field' => 'Verkooprelatie', 'options' => [ 'Outputmode' => Connection::GET_OUTPUTMODE_ARRAY ]], $results);
    $test++;
} while($results['finished'] == false);
dd($results);

Can you help me how to implement this method?

@rmuit
Copy link
Owner

rmuit commented Apr 7, 2019

Hi Niels,

Thanks for the report. I've never used this together with the REST API and will depend on your feedback / testing to make this work better.

Questions that come to mind: (If you don't know, skip to the next question.)

  • I believe that $client->callAfas() should never return NULL; I expect it to return an empty array to represent "no data found". Do you have information that contradicts this?

  • Are you sure "Verkooprelatie" is a sortable field, that will work correctly if you apply a 'smaller / larger' filter to it?

  • Is there a timeout from AFAS maybe? If so, try adding a 'take' parameter to the arguments of getDataBatch(). (I believe my code does not add any explicit 'take' and assumes that REST will return maximum 100 records, but that behavior might be changed.)

  • Otherwise... can you dd($filters); dd($getdata_args); dd($context), in the Helper class just before this exception gets thrown?

PS I don't think filling $results or the 'options' argument should be necessary, but it shouldn't hurt either.

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