inspirum / balikobot-php Goto Github PK
View Code? Open in Web Editor NEWPHP library for Balikobot API.
License: MIT License
PHP library for Balikobot API.
License: MIT License
Hi,
I got an undefined index error on line https://github.com/inspirum/balikobot-php/blob/master/src/Services/Client.php#L191.
I have dumped $responseItem
variable from this method, its var_dumped content is:
array(1) { [0]=> string(37) "DPD API error: Authentication failed." }
Is it possible to check if index status_text
exists and then throw an exception?
Thanks
From time to time, GLS sends valid HTTP 200 code response with just content of '503' - service not available. Which is correctly decoded by json_decode, but the result is not an array, thus fails to be passed onto next functions:
[25-Jun-2020 18:21:38 Europe/Prague] PHP Fatal error: Uncaught TypeError: Argument 1 passed to Inspirum\Balikobot\Model\Values\PackageStatus::newInstanceFromData() must be of the type array, string given, called in /www/sites/7/site70717/public_html/vendor/inspirum/balikobot/src/Services/Balikobot.php on line 170 and defined in /www/sites/7/site70717/public_html/vendor/inspirum/balikobot/src/Model/Values/PackageStatus.php:68
Stack trace:
#0 /www/sites/7/site70717/public_html/vendor/inspirum/balikobot/src/Services/Balikobot.php(170): Inspirum\Balikobot\Model\Values\PackageStatus::newInstanceFromData('503')
#1 /www/sites/7/site70717/public_html/vendor/inspirum/balikobot/src/Services/Balikobot.php(146): Inspirum\Balikobot\Services\Balikobot->trackPackages(Object(Inspirum\Balikobot\Model\Aggregates\OrderedPackageCollection))
#2 /www/sites/7/site70717/public_html/cron/balikobotCheckStatus.php(40): Inspirum\Balikobot\Services\Balikobot->trackPackage(Object(Inspirum\Balikobot\Model\Values\OrderedPackage))
#3 {main}
thrown in /www/sites/7/site70717/public_html/vendor/inspirum/balikobot/src/Model/Values/PackageStatus.php on line 68
Definitely should be fixed on the side of GLS. Will report this issue to them as well. Also reporting here just for information. Could be possibly fixed in library as well
While trying to get a response in "trackPackage" method in "Client" class, an error is returned, even though there is a valid data returned. It is caused by statusCode set to 500.
Fixes the bug. Allows users to retrieve relevant data.
There is supposed to be $shouldHaveStatus variable in validateResponseStatus method set to false as there is not this index set in the response.
Just set shouldHaveStatus parameter in the trackPackage method to false - this solves the problem.
Not necessary
\Inspirum\Balikobot\Services\Client::trackPackagesLastStatus
call trackstatus with version V2V2, but in documentation it's not available - it's same as V2
see https://balikobot.docs.apiary.io/#reference/tracking/trackstatus-v2
I wrote with balikobot and they wrote:
method trackPackages throws TypeError
Provide a detailed description of the change or addition you are proposing.
Probably a bug
To make it work
How can it benefit other users?
It will work for them
Not obligatory, but suggest an idea for implementing addition or change.
cheheck if $status variable in trackPackages' method's loop is array
PHP7.4
inspirum/balikobot composer version 3.3.0
Sometimes when trackPackages() method is called, we got this error:
Argument 1 passed to Inspirum\Balikobot\Model\Values\PackageStatus::newInstanceFromData() must be of the type array, string given
I am unable to replicate this error in testing environment, but live, the error sometimes appear for us.
Ahoj,
prosím jen informativně, je v plánu implmentovat i https://balikobot.docs.apiary.io/#reference/tracking/track-v3 ?
When tracking GLS packages, statuses returned by trackPackages() are always empty.
the issue is due to this part of code:
if (empty($response[0])) {
throw new BadRequestException($response);
}
$response[0] can be empty and thus will throw an exception, crude (don't now if good) solution is to check $response[1] being set:
if (empty($response[0])) {
if(empty($response[1])) {
throw new BadRequestException($response);
}
$response[0] = $response[1];
}
In some cases PPL branch ids contain the string 'KM' multiple times, wich than generates a faulty branchId property.
e.g. KMSKMK000000000
-> SK000000000
I'm not sure why the leading 'KM' has to be removed but with the current str_replace method it's not sufficient for this purpose.
A more specific way would be to do it with preg_match().
\Inspirum\Balikobot\Services\Client::getAddServiceOptions
called without service returns empty array.
Without serviceType the api returns options nested for all services under service_types key:
{
"status": 200,
"service_types": [
{
"service_type": "F",
"service_type_name": "Fofr",
"services": [
{
"code": 1,
"name": "křehké"
},
{
"code": 2,
"name": "neklopit"
},
{
"code": 3,
"name": "deštník"
},
{
"code": 4,
"name": "SMS před svozem"
},
{
"code": 5,
"name": "SMS před doručením"
}
]
}
]
}
...
inspirum/balikobot: v5.4.0
Tracking api Balíkobotu vrací v určitých případech české pošty zvláštní odpověď, kde je namísto pole eventů, pouze pole se stringem 404
.
{
"packages": [
{
"carrier_id": "NBxxxxxxxxxxxxxx",
"status": 200,
"states": ["404"]
}
]
}
Z Balíkobotu máme vyjádření, že pouze přeposílají data z České Pošty a tudíž se tomu nebudou věnovat.
Na základě této chyby, knihovna špatně detekuje stav 4 - Nedoručený balík.
Toto se dá jednoduše hacknout na straně použití knihovny přibližně takto:
$statuses = $this->balikobot->trackPackage($orderedPackage);
// Hack / fix 404 Czech Post in Inspirum library
if (
$package->getShipper()->isCeskaPosta()
&& count($statuses) === 1
&& $statuses[0]->getId() === 4.0
&& $statuses[0]->getName() === '4'
&& $statuses[0]->getDescription() === '4'
&& $statuses[0]->getDate() === null
) {
$statuses = [];
}
Nicméně bylo by moc fajn, kdyby toto uměla řešit přímo knihovna.
Díky za váš čas, pokud se tomu budete věnovat.
Could you please provide an example of full instantiation of $packageService ? I am trying to migrate from 5.7. to 7.6. and am unable to figure out how to use it.
Many thanks
Balikobot branches allows filtering results by either country or service for shippers not in \Inspirum\Balikobot\Definitions\Shipper::hasBranchCountryFilterSupport
. (https://balikobotv2.docs.apiary.io/#reference/branches) but \Inspirum\Balikobot\Services\Balikobot::getAllBranchesForShipperServiceForCountries
filters only by service:
https://github.com/inspirum/balikobot-php/blob/v5.3.0/src/Services/Balikobot.php#L467
This is a problem especially for Zasilkovna with $service set as null, because the countries are filtered later and it requires excessive amount of memory.
Calling $shipper/branches/country/$country
would greatly reduce the response size and allowed to remove filtering by countries later.
\Inspirum\Balikobot\Definitions\Shipper::hasBranchCountryFilterSupport
should only be checked in case both $service and $country is set. Or the check can be dropped completely in favor of api exception in response.
inspirum/balikobot: v5.3.0
Zdravím,
vyvíjím integraci Balíkobotu pomocí vaší knihovny a při kombinaci dopravce Zásilkovna a služby dobírka se vrací:
Operace neproběhla v pořádku, zkontrolujte konkrétní data.
[0][cod_currency]: Nepovolený ISO kód měny dobírky. (500 Internal Server Error)
Exception
Inspirum\Balikobot\Exceptions
BadRequestException
in vendor/inspirum/balikobot/src/Services/Validator.php (line 27)
throw new BadRequestException($response, (int) ($response['status'] ?? $statusCode));
Přitom data, co se týká ISO kódu měny dobírky by měla být podle mě v pořádku.
object(Inspirum\Balikobot\Model\Values\Package)#3537 (1) {
["data":"Inspirum\Balikobot\Model\Values\AbstractPackage":private]=>
array(10) {
["eid"]=>
string(18) "123456789111222333"
["service_type"]=>
string(4) "VMCZ"
["rec_name"]=>
string(11) "Lorem Ipsum"
["rec_phone"]=>
string(13) "+420731123555"
["branch_id"]=>
string(4) "1442"
["price"]=>
float(2010)
["cod_price"]=>
float(2010)
["vs"]=>
string(18) "123456789111222333"
["cod_currency"]=>
string(3) "CZK"
["return_full_errors"]=>
int(1)
}
}
Pokud dám Zásilkovnu bez dobírky nebo DPD s dobírkou, tak to prochází v pořádku, protože používám kontanty
Inspirum\Balikobot\Definitions\Currency\Currency::CZK a Inspirum\Balikobot\Definitions\Currency\Currency::EUR
Můžete se na to, prosím, podívat?
Díky.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.