avtocod / b2b-api-php Goto Github PK
View Code? Open in Web Editor NEWPHP client for a working with B2B API
License: MIT License
PHP client for a working with B2B API
License: MIT License
Right now all API client methods (except ::userReportMake
) requires a lot of different parameners to invoke. The better strategy is using single parameters object (like in #17).
We need to update all methods before v4.x
releasing.
Hello, it would be great to add PHP 8.1 to your SDK.
Сейчас в некоторых unit-тест-классах (остальные тесты, в целом, не проверял) встречаются namespace-строки типа:
namespace Avtocod\B2BApi\Tests;
Штормина справедливо светится на них, должно быть:
namespace Avtocod\B2BApi\Tests\Unit;
С ходу несколько таких файлов:
tests/Unit/ClientTest.php
tests/Unit/DateTimeFactoryTest
tests/Unit/SettingsTest
If you have any questions feel free to ask
Can you explain how I get an account for your API?, is there a contact email address? Or is there a registration form?
Floating bug in ClientTest
on CI (PHP 7.4, maybe not only):
> @php ./vendor/bin/phpunit --coverage-html='./coverage/html' --testsuite=Unit
PHPUnit 8.5.8 by Sebastian Bergmann and contributors.
.........F..................................................... 63 / 105 ( 60%)
.......................................... 105 / 105 (100%)
Time: 1.46 seconds, Memory: 16.00 MB
There was 1 failure:
1) Avtocod\B2BApi\Tests\Unit\ClientTest::testDoRequestFireEventsOnSuccess
Failed asserting that 6 matches expected 0.
/home/runner/work/b2b-api-php/b2b-api-php/tests/Unit/ClientTest.php:325
/home/runner/work/b2b-api-php/b2b-api-php/src/Client.php:384
/home/runner/work/b2b-api-php/b2b-api-php/src/Client.php:384
/home/runner/work/b2b-api-php/b2b-api-php/src/Client.php:356
/home/runner/work/b2b-api-php/b2b-api-php/src/Client.php:92
/home/runner/work/b2b-api-php/b2b-api-php/tests/Unit/ClientTest.php:332
FAILURES!
Tests: 105, Assertions: 919, Failures: 1.
You can see here:
https://github.com/avtocod/b2b-api-php/pull/18/checks?check_run_id=1230816870
PHPStan errors:
------ -------------------------------------------------------
103 Unsafe usage of new static().
💡 Consider making the class or the constructor final.
------ -------------------------------------------------------
------ -------------------------------------------------------
Line Responses/UserResponse.php
------ -------------------------------------------------------
91 Unsafe usage of new static().
💡 Consider making the class or the constructor final.
------ -------------------------------------------------------
Now disabled:
parameters:
# ...
ignoreErrors:
- # Replacing with `return new self` or classes finalization requires major version upping. Make it on next major release
message: '#Unsafe usage of new static\(\)#'
paths:
- src/Responses/*Response.php
- src/Responses/Entities/*.php
- src/Exceptions/*Exception.php
We must replace new static
with new self
or finalize classes in new major version (v4.x)
One more suggestion - replace DateTime
with DateTimeImmutable
in all code places. Reason - date/time seems like immutable during API calls
fzaninotto/faker
This package is abandoned and no longer maintained. No replacement package was suggested.
When we run phpstan analyze
, we looked a message:
⚠️ You're running a really old version of PHPStan.️
The last release in the 0.12.x series with new features
and bugfixes was released on September 12th 2021,
that's 582 days ago.
Since then more than 67 new PHPStan versions were released
with hundreds of new features, bugfixes, and other
quality of life improvements.
To learn about what you're missing out on, check out
this blog with articles about the latest major releases:
https://phpstan.org/blog
Upgrade today to PHPStan 1.8 or newer by using
"phpstan/phpstan": "^1.8" in your composer.json.
The new guzzle http client supports the PSR http client interface. It would be great to remove the dependency from the require block to the suggest block in composer and just use the PSR interface.
Как понял удалили либу https://github.com/tarampampam/wrappers-php
Которая используется в https://github.com/avtocod/b2b-api-php
Из-за этого сейчас не собирается пакет
Сейчас в сигнатуре метода userReportMake
(ClientInterface
) 8 параметров. С учётом PR #14 будет девять, что овер-многовато.
Все необязательные параметры условно можно поделить на две группы -- те, которые попадут в $request_body['options']
и те, которые попадут непосредственно в $request_body
:
$request_body = [
'queryType' => $type,
'query' => $value,
'options' => <дополнительные параметры в options>
'foo_параметр' => <доп. параметр непосредственно в request_body>
];
К options-параметрам относятся:
?array $options = [],
?bool $is_force = false,
?string $on_update = null,
?string $on_complete = null,
К параметрам попадающим в $request_body
-- $data
и, если PR #14 будет принят, $idempotence_key
.
Не уверен на счёт последней парочки ($data
& $idempotence_key
), но 4 options-параметра явно напрашиваются на объединение в некий param-объект.
Предлагаю в будущих мажерных (сломается обратная совместимость) версиях b2b-api-php
сигнатуру метода userReportMake
заменить на что-нибудь типа:
public function userReportMake(
string $report_type_uid,
string $type,
string $value,
?BodyParams $body_params,
?OptionalParams $optional_params,
): UserReportMakeResponse
Composer 2 and php 8 availeble now
Add support for PHP 8 and update composer to v2
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.