Skip to content

Commit

Permalink
Add getStoryByUuid method
Browse files Browse the repository at this point in the history
  • Loading branch information
jorenvh committed Jan 21, 2021
1 parent a40479a commit cced39c
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 1 deletion.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,7 @@ All notable changes to `laravel-storyblok` will be documented in this file.
## 1.0.0 - 2021-01-19

- initial release

## 1.0.1 - 2021-01-21

- Add `getStoryByUuid` method
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,8 @@ class SomeClass

public function someMethod()
{
$this->storyblok->getStoryBySlug("your-slug");
$this->storyblok->getStoryBySlug("story-slug");
$this->storyblok->getStoryByUuid("story-uuid");
}
}
```
Expand Down
11 changes: 11 additions & 0 deletions src/Storyblok.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,15 @@ public function getStoryBySlug(string $slug): array

return $response->getBody()['story'];
}

public function getStoryByUuid(string $uuid): array
{
$response = $this->client->getStoryByUuid($uuid);

if (! $response->getBody() && ! isset($response->getBody()['story'])) {
throw new Exception('Invalid Storyblok api call');
}

return $response->getBody()['story'];
}
}

0 comments on commit cced39c

Please sign in to comment.