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

Refactory ClientInterface & Client class #22

Merged
merged 65 commits into from
Oct 22, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
65 commits
Select commit Hold shift + click to select a range
0b56d0b
Add ReportRefreshParams
Oct 13, 2020
4effde6
Merge branch 'master' of https://github.com/avtocod/b2b-api-php into …
gomzyakov Oct 13, 2020
8fde271
Update tests for method `userReportRefresh` & change README.md
gomzyakov Oct 13, 2020
2565ed2
Add `AbstractListParams`
gomzyakov Oct 13, 2020
a1ac2f6
Add `ReportTypesParams` & `ReportsParams`
gomzyakov Oct 13, 2020
2201587
Realize methods `userReportTypes` & `userReports`
gomzyakov Oct 13, 2020
a827942
Update method `user()`
gomzyakov Oct 13, 2020
d5d1441
Update method `devPing()`
gomzyakov Oct 13, 2020
da45545
Update method `userReport()`
gomzyakov Oct 13, 2020
7a03cde
Change `userBalance()` method signature
gomzyakov Oct 13, 2020
54f1987
Change `devToken()` method signature
gomzyakov Oct 13, 2020
5c8cdc2
Rename param-objects
gomzyakov Oct 14, 2020
45631c5
Add `UserReportParamsTest`
gomzyakov Oct 14, 2020
1ec0d6b
Add `UserReportRefreshParamsTest`
gomzyakov Oct 14, 2020
94b3802
Add `UserParamsTest`
gomzyakov Oct 14, 2020
0b93799
Add `UserBalanceParamsTest`
gomzyakov Oct 14, 2020
562c01d
Add `DevPingParamsTest`
gomzyakov Oct 14, 2020
ce126ab
Add `DevTokenParamsTest`
gomzyakov Oct 14, 2020
3c50a38
Add `UserReportsParamsTest`
gomzyakov Oct 14, 2020
39661ba
Add `UserReportTypesParamsTest`
gomzyakov Oct 14, 2020
c4313a7
Update CHANGELOG.md
gomzyakov Oct 14, 2020
a120191
Apply patch from StyleCI
gomzyakov Oct 14, 2020
cec588c
Update README.md
gomzyakov Oct 14, 2020
6262d17
Fix `Client` method `devToken()`
gomzyakov Oct 14, 2020
a1733b9
Add `AbstractListParams`
gomzyakov Oct 14, 2020
2e04d92
Fix PHPStan warning in method `devToken`
gomzyakov Oct 14, 2020
adbb3ff
Remove () if constructor is empty
gomzyakov Oct 16, 2020
0a090fa
Rename parameter `include_content` to `with_content`
gomzyakov Oct 16, 2020
f4dbd2e
Make param-object optional in some `Client` methods
gomzyakov Oct 16, 2020
c2850ea
Apply patch from StyleCI
gomzyakov Oct 16, 2020
932cac9
Rollback changes with DateTimeImmutable
gomzyakov Oct 16, 2020
1725e8e
Apply patch from StyleCI
gomzyakov Oct 16, 2020
fda3dfb
Fix `null`-able param in `setDateFrom()`
gomzyakov Oct 16, 2020
b129d6e
Fix options param PhpDoc in UserReportRefreshParams
gomzyakov Oct 16, 2020
3651963
Fix CHANGELOG.md
gomzyakov Oct 19, 2020
c5e64d2
Update README.md
gomzyakov Oct 19, 2020
83b30f3
Remove AbstractListParams.php
gomzyakov Oct 20, 2020
10d6e50
Rewrite all Client methods, excepts `userReportTypes`
gomzyakov Oct 20, 2020
3456cfe
Apply patch from StyleCI & fix coverage
gomzyakov Oct 20, 2020
0362d7e
Remove default property values from UserReportTypesParams
gomzyakov Oct 21, 2020
233c4b7
Remove temporary group from ClientTest
gomzyakov Oct 21, 2020
e63ac3e
`Unit/ClientTest` was cleaned
gomzyakov Oct 21, 2020
7bb0597
Client was cleaned
gomzyakov Oct 21, 2020
4b82177
Rollback method `devPing`
gomzyakov Oct 21, 2020
1e800d1
Rollback method `devToken`
gomzyakov Oct 21, 2020
44a6827
Rollback method `user()`
gomzyakov Oct 21, 2020
c08bff1
Apply patch from StyleCI
gomzyakov Oct 21, 2020
4cddc4c
Rollback method `userBalance()`
gomzyakov Oct 21, 2020
4261cab
Rollback method `userReport()`
gomzyakov Oct 21, 2020
97a1126
Simplify `userReport()`
gomzyakov Oct 21, 2020
721dac9
Methods `userReports` & `userReportTypes` without refactoring
gomzyakov Oct 21, 2020
18f0fa4
Root slash before functions like a is_string, is_bool, etc
gomzyakov Oct 21, 2020
1af6853
Update method `userBalance` in `Client`
gomzyakov Oct 21, 2020
a664a53
Chose '_offset' over `max()` in `Client::userReportTypes`
gomzyakov Oct 21, 2020
d1a3c87
Chose '_offset' over `max()` in `Client::userReports`
gomzyakov Oct 21, 2020
29caa24
Update CHANGELOG.md
gomzyakov Oct 21, 2020
ec83a0a
Update '_detailed' property logic in `Client::userReport`
gomzyakov Oct 22, 2020
185ae21
Update '_content' property logic in `Client::userReport`
gomzyakov Oct 22, 2020
53a5878
Fix params _content & _detailed logic
gomzyakov Oct 22, 2020
cec58f7
Some fixes in CHANGELOG.md
gomzyakov Oct 22, 2020
0ce812e
Delete line from Fixed block in CHANGELOG.md
gomzyakov Oct 22, 2020
60737f0
Update '_detailed' property logic in `Client::userReport`
gomzyakov Oct 22, 2020
8f6cd6c
Change `userReport()` logic & rollback tests
gomzyakov Oct 22, 2020
93ebe68
Remove `private` from params & mark properties as protected
gomzyakov Oct 22, 2020
166276b
More strict 'is_hash' logic in `Client::devToken`
gomzyakov Oct 22, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 17 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,28 @@ The format is based on [Keep a Changelog][keepachangelog] and this project adher

### Added

- Class `ReportMakeParams` to build make-report parameters
- Class `DevPingParams` as parameter to test connection
- Class `DevTokenParams` as parameter to debug token generation
- Class `UserReportMakeParams` to build make-report parameters
- Class `UserParams` as parameter to retrieve information about current user
- Class `UserBalanceParams` as parameter to retrieve balance information
- Class `UserReportTypesParams` as parameter to retrieve report types data
- Class `UserReportsParams` as parameter to get reports list
- Class `UserReportParams` as parameter to get report by unique report ID
- Class `UserReportRefreshParams` as parameter to refresh existing report
- Optional parameter `idempotenceKey` for report-make requests

### Changed

- Method `ClientInterface::userReportMake` now takes object `ReportMakeParams` as parameter
- Method `ClientInterface::devPing` now takes optional object `DevPingParams` as parameter
- Method `ClientInterface::devToken` now takes object `DevTokenParams` as parameter
- Method `ClientInterface::user` now takes optional object `UserParams` as parameter
- Method `ClientInterface::userBalance` now takes object `UserBalanceParams` as parameter
- Method `ClientInterface::userReportTypes` now takes optional object `UserReportTypesParams` as parameter
- Method `ClientInterface::userReports` now takes optional object `UserReportsParams` as parameter
- Method `ClientInterface::userReport` now takes object `UserReportParams` as parameter
- Method `ClientInterface::userReportRefresh` now takes object `UserReportRefreshParams` as parameter

### Fixed

Expand Down
27 changes: 13 additions & 14 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,33 +52,31 @@ And then we can make next operations _(each call will returns an object with ser
<?php /** @var \Avtocod\B2BApi\Client $client */

// Test connection
$client->devPing();
$client->devPing(new \Avtocod\B2BApi\Params\DevPingParams);

// Debug token generation
$client->devToken('username', 'password');
$client->devToken(new \Avtocod\B2BApi\Params\DevTokenParams('username', 'password'));

// Retrieve information about current user
$client->user(true);
$client->user(new \Avtocod\B2BApi\Params\UserParams);

// Retrieve balance information for report type
$client->userBalance('report_type_uid@domain');
$client->userBalance(new \Avtocod\B2BApi\Params\UserBalanceParams('report_type_uid@domain'));

// Retrieve report types data
$client->userReportTypes();
$client->userReportTypes(new \Avtocod\B2BApi\Params\UserReportTypesParams);

// Get reports list
$client->userReports();
$client->userReports(new \Avtocod\B2BApi\Params\UserReportsParams);

// Get report by unique report ID
$client->userReport('report_uid_SOMEIDENTIFIERGOESHERE@domain');
$client->userReport(new \Avtocod\B2BApi\Params\UserReportParams('report_uid_SOMEIDENTIFIERGOESHERE@domain'));

// Make (generate) report
$client->userReportMake(
new ReportMakeParams('report_type_uid@domain', 'VIN', 'Z94CB41AAGR323020')
);
$client->userReportMake(new \Avtocod\B2BApi\Params\UserReportMakeParams('report_type_uid@domain', 'VIN', 'Z94CB41AAGR323020'));

// Refresh existing report
$client->userReportRefresh('report_uid_SOMEIDENTIFIERGOESHERE@domain');
$client->userReportRefresh(new \Avtocod\B2BApi\Params\UserReportRefreshParams('report_uid_SOMEIDENTIFIERGOESHERE@domain'));
```

For example, if you want to generate report for `A111AA177` (`GRZ` type), you can:
Expand All @@ -89,7 +87,7 @@ For example, if you want to generate report for `A111AA177` (`GRZ` type), you ca
// Make report (this operation is asynchronous)
$report_uid = $client
->userReportMake(
(new ReportMakeParams(`some_report_uid`, 'GRZ', 'A111AA177'))
(new \Avtocod\B2BApi\Params\UserReportMakeParams(`some_report_uid`, 'GRZ', 'A111AA177'))
->setForce(true)
->setOnUpdateUrl('https://example.com/webhook/updated')
->setOnCompleteUrl('https://example.com/webhook/completed')
Expand All @@ -99,14 +97,15 @@ $report_uid = $client

// Wait for report is ready
while (true) {
if ($client->userReport($report_uid, false)->first()->isCompleted()) {
$user_report_params = (new \Avtocod\B2BApi\Params\UserReportParams($report_uid))->setIncludeContent(false);
if ($client->userReport($user_report_params)->first()->isCompleted()) {
break;
}

\sleep(1);
}

$content = $client->userReport($report_uid)->first()->getContent();
$content = $client->userReport(new \Avtocod\B2BApi\Params\UserReportParams($report_uid))->first()->getContent();

$vin_code = $content->getByPath('identifiers.vehicle.vin'); // (string) 'JTMHX05J704083922'
$engine_kw = $content->getByPath('tech_data.engine.power.kw'); // (int) 227
Expand Down
Loading