Skip to content

Commit

Permalink
Merge pull request #10 from answear/ANS-9289-increase-number-of-retur…
Browse files Browse the repository at this point in the history
…n-products-br

ANS-9289 added param to SearchByFeatureRequest - max number of return products
  • Loading branch information
ropczan committed Jan 5, 2022
2 parents f35552f + 63a5d7f commit 13dc8ba
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 3 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/phpunit.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,4 +45,4 @@ jobs:
if: "${{ matrix.deps == 'low' }}"

- name: "Run PHPUnit"
run: "vendor/bin/phpunit"
run: "SYMFONY_DEPRECATIONS_HELPER=weak vendor/bin/phpunit"
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -63,14 +63,15 @@ To search products with previously found feature use `searchByFeature`
```php
use Answear\WideEyesBundle\Service\SearchByImageClient;
$detectAndFeturesResponse = $searchByImageClient->searchByFeature('featureId', 'label', 'gender', 'filters');
$detectAndFeturesResponse = $searchByImageClient->searchByFeature('featureId', 'label', 'gender', 'filters', 'maxNumResults');
```

Your agruments are:
* `featureId` - featureId you got form DetectAndFeatures
* `label` - label you got form DetectAndFeatures
* `gender` - gender you got from DetectAndFeatures (optional)
* `filters` - result filters (optional)
* `maxNumResults` - maximal number of return products (optional)

In result you're getting `SearchByFeatureResponse` that contains all found products uids meeting your criteria.

Expand Down
5 changes: 4 additions & 1 deletion src/Request/SearchByFeatureRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,15 @@ class SearchByFeatureRequest implements Request
private string $label;
private ?string $gender;
private ?string $filters;
private ?int $maxNumResults;

public function __construct(string $featureId, string $label, ?string $gender = null, ?string $filters = null)
public function __construct(string $featureId, string $label, ?string $gender = null, ?string $filters = null, ?int $maxNumResults = null)
{
$this->featureId = $featureId;
$this->label = $label;
$this->gender = $gender;
$this->filters = $filters;
$this->maxNumResults = $maxNumResults;
}

public function toJson(): string
Expand All @@ -28,6 +30,7 @@ public function toJson(): string
'label' => $this->label,
'gender' => $this->gender,
'filters' => $this->filters,
'maxNumResults' => $this->maxNumResults,
]
)
);
Expand Down
13 changes: 13 additions & 0 deletions tests/Unit/Request/SearchByFeatureRequestTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,4 +34,17 @@ public function requestWithGenderAndCountryIsCorrect(): void
$request->toJson()
);
}

/**
* @test
*/
public function requestWithMaxNumResultsIsCorrect(): void
{
$request = new SearchByFeatureRequest('featureId', 'label', null, null, 30);

self::assertSame(
'{"featureId":"featureId","label":"label","maxNumResults":30}',
$request->toJson()
);
}
}

0 comments on commit 13dc8ba

Please sign in to comment.