Skip to content

Commit 63f4fed

Browse files
authored
Merge pull request #5 from php-api-clients/resource-warning
Warning resource
2 parents 5b9c21e + 1f177fe commit 63f4fed

File tree

10 files changed

+186
-0
lines changed

10 files changed

+186
-0
lines changed

src/Resource/Async/EmptyWarning.php

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
<?php declare(strict_types=1);
2+
3+
namespace ApiClients\Client\Twitter\Resource\Async;
4+
5+
use ApiClients\Client\Twitter\Resource\EmptyWarning as BaseEmptyWarning;
6+
7+
class EmptyWarning extends BaseEmptyWarning
8+
{
9+
}

src/Resource/Async/Warning.php

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
<?php declare(strict_types=1);
2+
3+
namespace ApiClients\Client\Twitter\Resource\Async;
4+
5+
use ApiClients\Client\Twitter\Resource\Warning as BaseWarning;
6+
7+
class Warning extends BaseWarning
8+
{
9+
public function refresh() : Warning
10+
{
11+
throw new \Exception('TODO: create refresh method!');
12+
}
13+
}

src/Resource/EmptyWarning.php

+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
<?php declare(strict_types=1);
2+
3+
namespace ApiClients\Client\Twitter\Resource;
4+
5+
use ApiClients\Foundation\Resource\EmptyResourceInterface;
6+
7+
abstract class EmptyWarning implements WarningInterface, EmptyResourceInterface
8+
{
9+
/**
10+
* @return array
11+
*/
12+
public function status() : array
13+
{
14+
return null;
15+
}
16+
17+
/**
18+
* @return string
19+
*/
20+
public function timestampMs() : string
21+
{
22+
return null;
23+
}
24+
}

src/Resource/Sync/EmptyWarning.php

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
<?php declare(strict_types=1);
2+
3+
namespace ApiClients\Client\Twitter\Resource\Sync;
4+
5+
use ApiClients\Client\Twitter\Resource\EmptyWarning as BaseEmptyWarning;
6+
7+
class EmptyWarning extends BaseEmptyWarning
8+
{
9+
}

src/Resource/Sync/Warning.php

+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
<?php declare(strict_types=1);
2+
3+
namespace ApiClients\Client\Twitter\Resource\Sync;
4+
5+
use ApiClients\Client\Twitter\Resource\Warning as BaseWarning;
6+
use ApiClients\Client\Twitter\Resource\WarningInterface;
7+
use ApiClients\Foundation\Hydrator\CommandBus\Command\BuildAsyncFromSyncCommand;
8+
9+
class Warning extends BaseWarning
10+
{
11+
public function refresh() : Warning
12+
{
13+
return $this->wait(
14+
$this->handleCommand(
15+
new BuildAsyncFromSyncCommand(self::HYDRATE_CLASS, $this)
16+
)->then(
17+
function (WarningInterface $warning) {
18+
return $warning->refresh();
19+
}
20+
)
21+
);
22+
}
23+
}

src/Resource/Warning.php

+38
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
<?php declare(strict_types=1);
2+
3+
namespace ApiClients\Client\Twitter\Resource;
4+
5+
use ApiClients\Foundation\Hydrator\Annotations\EmptyResource;
6+
use ApiClients\Foundation\Resource\AbstractResource;
7+
8+
/**
9+
* @EmptyResource("EmptyWarning")
10+
*/
11+
abstract class Warning extends AbstractResource implements WarningInterface
12+
{
13+
/**
14+
* @var array
15+
*/
16+
protected $status;
17+
18+
/**
19+
* @var string
20+
*/
21+
protected $timestamp_ms;
22+
23+
/**
24+
* @return array
25+
*/
26+
public function status() : array
27+
{
28+
return $this->status;
29+
}
30+
31+
/**
32+
* @return string
33+
*/
34+
public function timestampMs() : string
35+
{
36+
return $this->timestamp_ms;
37+
}
38+
}

src/Resource/WarningInterface.php

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
<?php declare(strict_types=1);
2+
3+
namespace ApiClients\Client\Twitter\Resource;
4+
5+
use ApiClients\Foundation\Resource\ResourceInterface;
6+
7+
interface WarningInterface extends ResourceInterface
8+
{
9+
const HYDRATE_CLASS = 'Warning';
10+
11+
/**
12+
* @return array
13+
*/
14+
public function status() : array;
15+
16+
/**
17+
* @return string
18+
*/
19+
public function timestampMs() : string;
20+
}

tests/Resource/Async/WarningTest.php

+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
<?php declare(strict_types=1);
2+
3+
namespace ApiClients\Tests\Client\Twitter\Resource\Async;
4+
5+
use ApiClients\Client\Twitter\ApiSettings;
6+
use ApiClients\Client\Twitter\Resource\Warning;
7+
use ApiClients\Tools\ResourceTestUtilities\AbstractResourceTest;
8+
9+
class WarningTest extends AbstractResourceTest
10+
{
11+
public function getSyncAsync() : string
12+
{
13+
return 'Async';
14+
}
15+
public function getClass() : string
16+
{
17+
return Warning::class;
18+
}
19+
public function getNamespace() : string
20+
{
21+
return Apisettings::NAMESPACE;
22+
}
23+
}

tests/Resource/Sync/WarningTest.php

+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
<?php declare(strict_types=1);
2+
3+
namespace ApiClients\Tests\Client\Twitter\Resource\Sync;
4+
5+
use ApiClients\Client\Twitter\ApiSettings;
6+
use ApiClients\Client\Twitter\Resource\Warning;
7+
use ApiClients\Tools\ResourceTestUtilities\AbstractResourceTest;
8+
9+
class WarningTest extends AbstractResourceTest
10+
{
11+
public function getSyncAsync() : string
12+
{
13+
return 'Sync';
14+
}
15+
public function getClass() : string
16+
{
17+
return Warning::class;
18+
}
19+
public function getNamespace() : string
20+
{
21+
return Apisettings::NAMESPACE;
22+
}
23+
}

yaml/warning.yml

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
class: Warning
2+
properties:
3+
status: array
4+
timestamp_ms: string

0 commit comments

Comments
 (0)