Skip to content

Commit

Permalink
Merge pull request #59 from acelaya-forks/feature/tags-mode
Browse files Browse the repository at this point in the history
Add support for tags mode in short URLs list
  • Loading branch information
acelaya authored Mar 11, 2024
2 parents ac5edf0 + 8764b2f commit 6601a4d
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 7 deletions.
5 changes: 4 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,19 @@ All notable changes to this project will be documented in this file.

The format is based on [Keep a Changelog](https://keepachangelog.com), and this project adheres to [Semantic Versioning](https://semver.org).

## [Unreleased]
## [2.0.0] - 2024-03-11
### Added
* [#53](https://github.com/shlinkio/shlink-php-sdk/issues/53) Add support for Shlink 4.0.0.

* Short URL redirect rules.
* Filter orphan visits by type.
* Deprecate anything related with device long URLs.

* [#57](https://github.com/shlinkio/shlink-php-sdk/issues/57) Add support for `tagsMode` when listing short URLs.

### Changed
* [#25](https://github.com/shlinkio/shlink-php-sdk/issues/25) Add code coverage collection to integration tests.
* `ShortUrlsFilter::containingTags` renamed to `ShortUrlsFilter::containingSomeTags`.

### Deprecated
* *Nothing*
Expand Down
2 changes: 1 addition & 1 deletion docs/basic/getting-started.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ $httpClient = new HttpClient(
$client = new ShortUrlsClient($httpClient)

$filter = ShortUrlsFilter::create()
->containingTags('foo', 'bar')
->containingSomeTags('foo', 'bar')
->since(Chronos::now()->subDays(10)) // Any object implementing DateTimeInterface
->orderingAscBy(ShortUrlListOrderField::VISITS)
$shortUrls = $client->listShortUrlsWithFilter($filter)
Expand Down
2 changes: 1 addition & 1 deletion docs/contexts/short-urls.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ use Shlinkio\Shlink\SDK\ShortUrls\Model\ShortUrlListOrderField;
use Shlinkio\Shlink\SDK\ShortUrls\Model\ShortUrlsFilter;

$filter = ShortUrlsFilter::create()->searchingBy('foobar')
->containingTags('videogames', 'development')
->containingSomeTags('videogames', 'development')
->orderingDescBy(ShortUrlListOrderField::TITLE);
$filteredShortUrls = $shortUrlsClient->listShortUrlsWithFilter($filter);

Expand Down
9 changes: 7 additions & 2 deletions src/ShortUrls/Model/ShortUrlsFilter.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,14 @@ public function searchingBy(string $searchTerm): self
return $this->cloneWithProp('searchTerm', $searchTerm);
}

public function containingTags(string ...$tags): self
public function containingSomeTags(string ...$tags): self
{
return $this->cloneWithProp('tags', $tags);
return $this->cloneWithProp('tags', $tags)->cloneWithProp('tagsMode', 'any');
}

public function containingAllTags(string ...$tags): self
{
return $this->cloneWithProp('tags', $tags)->cloneWithProp('tagsMode', 'all');
}

public function excludingMaxVisitsReached(): self
Expand Down
8 changes: 6 additions & 2 deletions test/ShortUrls/Model/ShortUrlsFilterTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,13 @@ public static function providePayloads(): iterable
];
yield [
fn () => ShortUrlsFilter::create()
->containingTags('foo', 'bar')
->containingSomeTags('foo', 'bar')
->searchingBy('searching'),
['tags' => ['foo', 'bar'], 'searchTerm' => 'searching'],
['tags' => ['foo', 'bar'], 'tagsMode' => 'any', 'searchTerm' => 'searching'],
];
yield [
fn () => ShortUrlsFilter::create()->containingAllTags('foo', 'bar'),
['tags' => ['foo', 'bar'], 'tagsMode' => 'all'],
];
yield [
fn () => ShortUrlsFilter::create()->orderingAscBy(ShortUrlListOrderField::VISITS),
Expand Down

0 comments on commit 6601a4d

Please sign in to comment.