Skip to content

Commit 371ee36

Browse files
authored
Adds ResolveLinks (#27)
1 parent f04167c commit 371ee36

File tree

4 files changed

+84
-0
lines changed

4 files changed

+84
-0
lines changed
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
/**
6+
* This file is part of Storyblok-Api.
7+
*
8+
* (c) SensioLabs Deutschland <[email protected]>
9+
*
10+
* For the full copyright and license information, please view the LICENSE
11+
* file that was distributed with this source code.
12+
*/
13+
14+
namespace Storyblok\Api\Domain\Value\Resolver;
15+
16+
/**
17+
* @author Silas Joisten <[email protected]>
18+
*
19+
* @see https://www.storyblok.com/docs/api/content-delivery/v2/stories/retrieve-multiple-stories
20+
*/
21+
enum LinkLevel: int
22+
{
23+
case Default = 1;
24+
case Deep = 2;
25+
}
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
/**
6+
* This file is part of Storyblok-Api.
7+
*
8+
* (c) SensioLabs Deutschland <[email protected]>
9+
*
10+
* For the full copyright and license information, please view the LICENSE
11+
* file that was distributed with this source code.
12+
*/
13+
14+
namespace Storyblok\Api\Domain\Value\Resolver;
15+
16+
/**
17+
* @author Silas Joisten <[email protected]>
18+
*
19+
* @see https://www.storyblok.com/docs/api/content-delivery/v2/stories/retrieve-multiple-stories
20+
*/
21+
enum LinkType: string
22+
{
23+
case Link = 'link';
24+
case Url = 'url';
25+
case Story = 'story';
26+
}
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
/**
6+
* This file is part of Storyblok-Api.
7+
*
8+
* (c) SensioLabs Deutschland <[email protected]>
9+
*
10+
* For the full copyright and license information, please view the LICENSE
11+
* file that was distributed with this source code.
12+
*/
13+
14+
namespace Storyblok\Api\Domain\Value\Resolver;
15+
16+
final readonly class ResolveLinks
17+
{
18+
public function __construct(
19+
public ?LinkType $type = null,
20+
public LinkLevel $level = LinkLevel::Default,
21+
) {
22+
}
23+
}

src/Request/StoriesRequest.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
use Storyblok\Api\Domain\Value\Filter\FilterCollection;
2121
use Storyblok\Api\Domain\Value\IdCollection;
2222
use Storyblok\Api\Domain\Value\Resolver\RelationCollection;
23+
use Storyblok\Api\Domain\Value\Resolver\ResolveLinks;
2324
use Storyblok\Api\Domain\Value\Tag\TagCollection;
2425
use Webmozart\Assert\Assert;
2526

@@ -42,6 +43,7 @@ public function __construct(
4243
public RelationCollection $withRelations = new RelationCollection(),
4344
public ?Version $version = null,
4445
public ?string $searchTerm = null,
46+
public ResolveLinks $resolveLinks = new ResolveLinks(),
4547
) {
4648
Assert::stringNotEmpty($language);
4749
Assert::lessThanEq($this->pagination->perPage, self::MAX_PER_PAGE);
@@ -57,6 +59,9 @@ public function __construct(
5759
* with_tag?: string,
5860
* excluding_fields?: string,
5961
* excluding_ids?: string,
62+
* resolve_relations?: string,
63+
* resolve_links?: string,
64+
* resolve_links_level?: string,
6065
* search_term?: string,
6166
* version?: string,
6267
* }
@@ -93,6 +98,11 @@ public function toArray(): array
9398
$array['resolve_relations'] = $this->withRelations->toString();
9499
}
95100

101+
if (null !== $this->resolveLinks->type) {
102+
$array['resolve_links'] = $this->resolveLinks->type->value;
103+
$array['resolve_links_level'] = $this->resolveLinks->level->value;
104+
}
105+
96106
if (null !== $this->searchTerm) {
97107
$array['search_term'] = $this->searchTerm;
98108
}

0 commit comments

Comments
 (0)