Skip to content

Commit

Permalink
Add endpoint for getting item properties (RAD-720)
Browse files Browse the repository at this point in the history
  • Loading branch information
foglcz committed Dec 5, 2017
1 parent ce11e62 commit 96c7edd
Show file tree
Hide file tree
Showing 7 changed files with 47 additions and 4 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
<!-- There is always Unreleased section on the top. Subsections (Added, Changed, Fixed, Removed) should be added as needed. -->

## Unreleased
- Endpoint `$matej->getItemProperties()` that returns all defined item properties

## 1.0.0 - 2017-12-05
### Added
Expand Down
2 changes: 1 addition & 1 deletion src/Model/Request.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ class Request
/** @var string */
private $requestId;

public function __construct(string $path, string $method, array $data, string $requestId = null)
public function __construct(string $path, string $method, array $data = [], string $requestId = null)
{
$this->path = $path;
$this->method = $method;
Expand Down
16 changes: 16 additions & 0 deletions src/RequestBuilder/ItemPropertiesGetRequestBuilder.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<?php declare(strict_types=1);

namespace Lmc\Matej\RequestBuilder;

use Fig\Http\Message\RequestMethodInterface;
use Lmc\Matej\Model\Request;

class ItemPropertiesGetRequestBuilder extends AbstractRequestBuilder
{
protected const ENDPOINT_PATH = '/item-properties';

public function build(): Request
{
return new Request(self::ENDPOINT_PATH, RequestMethodInterface::METHOD_GET);
}
}
4 changes: 1 addition & 3 deletions src/RequestBuilder/ItemPropertiesSetupRequestBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,8 @@
use Lmc\Matej\Model\Command\ItemPropertySetup;
use Lmc\Matej\Model\Request;

class ItemPropertiesSetupRequestBuilder extends AbstractRequestBuilder
class ItemPropertiesSetupRequestBuilder extends ItemPropertiesGetRequestBuilder
{
protected const ENDPOINT_PATH = '/item-properties';

/** @var ItemPropertySetup[] */
protected $commands = [];
/** @var bool */
Expand Down
5 changes: 5 additions & 0 deletions src/RequestBuilder/RequestBuilderFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,11 @@ public function __construct(RequestManager $requestManager)
$this->requestManager = $requestManager;
}

public function getItemProperties(): ItemPropertiesGetRequestBuilder
{
return $this->createConfiguredBuilder(ItemPropertiesGetRequestBuilder::class);
}

/**
* Define new properties into the database. Those properties will be created and subsequently accepted by Matej.
*
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<?php declare(strict_types=1);

namespace Lmc\Matej\IntegrationTests\RequestBuilder;

use Lmc\Matej\IntegrationTests\IntegrationTestCase;

/**
* @covers \Lmc\Matej\RequestBuilder\ItemPropertiesGetRequestBuilder
*/
class ItemPropertiesGetRequestBuilderTest extends IntegrationTestCase
{
/** @test */
public function shouldGetListOfPropertiesFromMatej(): void
{
$response = $this->createMatejInstance()
->request()
->getItemProperties()
->send();

$this->assertResponseCommandStatuses($response, 'OK');
}
}
1 change: 1 addition & 0 deletions tests/unit/RequestBuilder/RequestBuilderFactoryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ public function provideBuilderMethods(): array
$userRecommendation = UserRecommendation::create('user-id', 1, 'test-scenario', 0.5, 3600);

return [
['getItemProperties', ItemPropertiesGetRequestBuilder::class, $voidInit],
['setupItemProperties', ItemPropertiesSetupRequestBuilder::class, $itemPropertiesSetupInit],
['deleteItemProperties', ItemPropertiesSetupRequestBuilder::class, $itemPropertiesSetupInit],
['events', EventsRequestBuilder::class, $eventInit],
Expand Down

0 comments on commit 96c7edd

Please sign in to comment.