Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,14 @@ All notable changes to this project will be documented in this file.

The format is based on [Keep a Changelog][keepachangelog] and this project adheres to [Semantic Versioning][semver].

## v3.3.0

### Added

- Additional (optional) parameter `data` for `::userReportMake` in `ClientInterface` and `Client` [#8]

[#8]:https://github.com/avtocod/b2b-api-php/pull/8

## v3.2.1

### Added
Expand Down
19 changes: 13 additions & 6 deletions src/Client.php
Original file line number Diff line number Diff line change
Expand Up @@ -266,7 +266,8 @@ public function userReportMake(string $report_type_uid,
?array $options = [],
?bool $is_force = false,
?string $on_update = null,
?string $on_complete = null): UserReportMakeResponse
?string $on_complete = null,
?array $data = []): UserReportMakeResponse
{
$request_options = [];

Expand All @@ -282,13 +283,19 @@ public function userReportMake(string $report_type_uid,
$request_options['webhook']['on_complete'] = $on_complete;
}

$request_body = [
'queryType' => $type,
'query' => $value,
'options' => (object) \array_replace($request_options, $options ?? []),
];

if (\is_array($data)) {
$request_body['data'] = (object) $data;
}

return UserReportMakeResponse::fromHttpResponse(
$this->doRequest(new Request('post', \sprintf('user/reports/%s/_make', \urlencode($report_type_uid))), [
GuzzleOptions::JSON => (object) [
'queryType' => $type,
'query' => $value,
'options' => (object) \array_replace($request_options, $options ?? []),
],
GuzzleOptions::JSON => (object) $request_body,
])
);
}
Expand Down
4 changes: 3 additions & 1 deletion src/ClientInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,7 @@ public function userReport(string $report_uid,
* @param bool|null $is_force Force update report, if it already was generated previously
* @param string|null $on_update Call (using `post` method) when report content updated
* @param string|null $on_complete Call (using `post` method) when report generation completed
* @param array|null $data Additional request data
*
* @throws BadRequestException
* @throws BadResponseException
Expand All @@ -165,7 +166,8 @@ public function userReportMake(string $report_type_uid,
?array $options = [],
?bool $is_force = false,
?string $on_update = null,
?string $on_complete = null): UserReportMakeResponse;
?string $on_complete = null,
?array $data = []): UserReportMakeResponse;

/**
* Refresh existing report.
Expand Down
4 changes: 3 additions & 1 deletion tests/Unit/ClientTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -1351,7 +1351,8 @@ public function testUserReportMake(): void
null,
true,
$on_update = $this->faker->url,
$on_complete = $this->faker->url
$on_complete = $this->faker->url,
$data = ['foo' => 'bar']
);

$this->assertSame(1, $response->getSize());
Expand Down Expand Up @@ -1381,6 +1382,7 @@ public function testUserReportMake(): void
$this->assertSame($body, $request_body['query']);
$this->assertSame($on_update, $request_body['options']['webhook']['on_update']);
$this->assertSame($on_complete, $request_body['options']['webhook']['on_complete']);
$this->assertSame($data, $request_body['data']);

foreach ($response as $item) {
$this->assertInstanceOf(ReportMade::class, $item);
Expand Down