-
Notifications
You must be signed in to change notification settings - Fork 14
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
Issue with page size, but it's set at 1? #11
Comments
You've set page size to 1 so if there are lots of results then it will have to fetch many pages but apparently it is possible to fetch too many pages. I'm not able to reproduce the issue with |
Thanks, Was thinking about the page size of 1 just before my head hit the pillow.. Have now set the page size to 100, but think there is a lot of results, and perhaps it's not knowing when the last page stops at? I'm searching for a company by name 'Test' shows the same error as the company which I'm searching for Putting the code in a try and catch statement it seems to take a long time and then throws this exception The full stack trace is shown below. "message": "Bad request: Invalid value '[14]' for query parameter page. Invalid number 14 expected number between 1 and 13",
"exception": "SynergiTech\\Creditsafe\\Exception\\APIException",
"file": "C:\\vhosts\\website.local\\vendor\\synergitech\\creditsafe-connect\\src\\Client.php",
"line": 175,
"trace": [
{
"file": "C:\\vhosts\\website.local\\vendor\\synergitech\\creditsafe-connect\\src\\Client.php",
"line": 195,
"function": "request",
"class": "SynergiTech\\Creditsafe\\Client",
"type": "->"
},
{
"file": "C:\\vhosts\\website.local\\vendor\\synergitech\\creditsafe-connect\\src\\ListResult.php",
"line": 91,
"function": "get",
"class": "SynergiTech\\Creditsafe\\Client",
"type": "->"
},
{
"file": "C:\\vhosts\\website.local\\vendor\\synergitech\\creditsafe-connect\\src\\ListResult.php",
"line": 77,
"function": "fetchPage",
"class": "SynergiTech\\Creditsafe\\ListResult",
"type": "->"
},
{
"file": "C:\\vhosts\\website.local\\vendor\\synergitech\\creditsafe-connect\\src\\ListResult.php",
"line": 126,
"function": "page",
"class": "SynergiTech\\Creditsafe\\ListResult",
"type": "->"
},
{
"file": "C:\\vhosts\\website.local\\app\\Http\\Controllers\\Admin\\JsonController.php",
"line": 116,
"function": "next",
"class": "SynergiTech\\Creditsafe\\ListResult",
"type": "->"
}
] Full code snippet querying Credit Safe $returnArray = array(
'status' => 'error',
'accounts' => [],
'message' => '',
'html' => '',
'code' => 500
);
$accounts = [];
$company_name = $request->input('name');
if ($company_name) {
try {
$creditSafeClient = new \SynergiTech\Creditsafe\Client(['username' => env('CREDIT_SAFE_USERNAME'),
'password' => env('CREDIT_SAFE_PASSWORD')]);
$searchParams = ['countries' => 'GB', 'name' => $company_name];
if ($request->input('city')) {
$searchParams['city'] = $request->input('city');
}
$creditSafeResults = $creditSafeClient->companies()->search($searchParams);
$creditSafeResults->setPageSize(100);
if ($creditSafeResults->valid()) {
foreach ($creditSafeResults as $result) {
$accounts[] = array(
'companyID' => $result->getID(),
'businessName' => $result->getName(),
'registeredCompanyName' => $result->getRefNo(),
'mainAddress' => $result->getAddress(),
'type' => $result->getType(),
'dateOfLatestChange' => $result->getDateOfLatestChange()->format('Y-m-d H:i:s'),
);
}
$returnArray['code'] = 200;
$returnArray['accounts'] = $accounts;
} else {
$returnArray['code'] = 200;
$returnArray['message'] = 'No results found';
}
} catch (APIException $e) {
$returnArray['status'] = 'error';
$returnArray['message'] = $e->getMessage();
$returnArray['code'] = 500;
return response()->json($returnArray, $returnArray['code']);
}
}
return $returnArray; Wonder if a for loop rather than the foreach could be done if the List results can know the page and last page number? |
Thanks for the extra information, I can now reproduce. It looks like there are some problems with how we have implemented iteration so we'll have a look at fixing it. |
Thanks, Think it might also be if it's over the page size of 14, of the results ,e.g. 14000+ records, being returned by credit save, I've limited the result set only 300 by putting in the city field to Would be good to get the full record set, |
Superb! and super faster.. Awesome work people! |
Getting this strange bug when I search by name. any idea's?
(See below for details)
Bad request: Invalid value '[14]' for query parameter page. Invalid number 14 expected number between 1 and 13 vendor/synergitech/creditsafe-connect/src/Client.php Line:175
The code i have is
The text was updated successfully, but these errors were encountered: