Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Apply fixes from StyleCI #165

Merged
merged 1 commit into from
Jul 21, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 4 additions & 5 deletions src/Endpoints/Page.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
*/
class Page extends Endpoint
{

/**
* @var ?string
*/
Expand All @@ -25,12 +24,12 @@ public function __construct(Notion $notion, string $pageId)
}

/**
* Retrieve a page property item
*
* Retrieve a page property item.
*
* @url https://api.notion.com/{version}/pages/{page_id}/properties/{property_id} [get]
*
* @reference https://developers.notion.com/reference/retrieve-a-page-property.
*
*
* @param string $propertyId
* @return Page
*
Expand All @@ -40,7 +39,7 @@ public function __construct(Notion $notion, string $pageId)
public function property(string $propertyId): Property
{
$response = $this->get(
$this->url(Endpoint::PAGES . '/' . $this->pageId . '/' . 'properties' . '/' . urlencode($propertyId))
$this->url(Endpoint::PAGES.'/'.$this->pageId.'/'.'properties'.'/'.urlencode($propertyId))
);

return Property::fromResponse(
Expand Down
8 changes: 5 additions & 3 deletions src/Macros/PestHttpRecorder.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ class PestHttpRecorder
public static function register()
{
Http::macro('recordAndFakeLater', function (array|string $urls = ['*']) {
if (!is_array($urls)) {
if (! is_array($urls)) {
$urls = [$urls];
}

Expand Down Expand Up @@ -73,7 +73,9 @@ public function handle(Request $request)
$payload = ($method === 'get') ? ($urlInfo['query'] ?? null) : $request->body();
$queryName = array_pop($this->requestNames) ?? ($payload ? hash('adler32', $payload) : '');

if ($queryName != '') $queryName = '_' . $queryName;
if ($queryName != '') {
$queryName = '_'.$queryName;
}

$fileName = "{$method}_{$name}{$queryName}.json";
$directoryPath = "tests/{$this->snapshotDirectory}";
Expand All @@ -82,7 +84,7 @@ public function handle(Request $request)
// filter out Notion API Token Header
$header = Arr::except($header, ['Authorization']);

if ($forceRecording || !File::exists($filePath)) {
if ($forceRecording || ! File::exists($filePath)) {
File::makeDirectory($directoryPath, 0744, true, true);

$client = new Client();
Expand Down
2 changes: 1 addition & 1 deletion src/Notion.php
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,7 @@ public function getConnection(): ?PendingRequest
*/
public function checkValidVersion(string $version): void
{
if (!$this->validVersions->contains($version)) {
if (! $this->validVersions->contains($version)) {
throw HandlingException::instance('Invalid version for Notion-API endpoint', ['invalidVersion' => $version]);
}
}
Expand Down
11 changes: 3 additions & 8 deletions tests/RecordedEndpointPageTest.php
Original file line number Diff line number Diff line change
@@ -1,11 +1,6 @@
<?php

use Carbon\Carbon;
use FiveamCode\LaravelNotionApi\Entities\Collections\CommentCollection;
use FiveamCode\LaravelNotionApi\Entities\Comment;
use FiveamCode\LaravelNotionApi\Entities\Properties\Property;
use FiveamCode\LaravelNotionApi\Entities\PropertyItems\RichText;
use FiveamCode\LaravelNotionApi\Exceptions\NotionException;
use Illuminate\Support\Facades\Http;

$httpRecorder = null;
Expand All @@ -18,16 +13,16 @@
});

it('should fetch specific property items of a page', function () {

$this->httpRecorder->nameForNextRequest('database-for-properties');
$databaseStructure = \Notion::databases()->find('cdd4befe814144f7b1eecb9c123bd4fb');

$propertyKeys = $databaseStructure->getProperties()->map(fn ($o) => $o->getTitle());

foreach ($propertyKeys as $propertyKey) {
try {

if ($propertyKey == 'Rollup' || $propertyKey == 'Person' || $propertyKey == 'Name') continue;
if ($propertyKey == 'Rollup' || $propertyKey == 'Person' || $propertyKey == 'Name') {
continue;
}
$id = $databaseStructure->getProperty($propertyKey)->getId();
$property = \Notion::page('f1884dca3885460e93f52bf4da7cce8e')->property($id);

Expand Down