Repository navigation
Expand file tree
/
Copy pathReplyPostResult.php
More file actions
61 lines (50 loc) · 1.67 KB
/
Copy pathReplyPostResult.php
File metadata and controls
61 lines (50 loc) · 1.67 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
<?php
declare(strict_types=1);
namespace App\Dto\Engagement;
use App\Enums\EngagementStatus;
final readonly class ReplyPostResult
{
private function __construct(
public EngagementStatus $status,
public ?string $remoteReplyId = null,
public ?string $remoteCid = null,
public ?string $message = null,
public ?string $processingContainerId = null,
) {}
public static function ok(string $remoteReplyId, ?string $remoteCid = null): self
{
return new self(EngagementStatus::Ok, $remoteReplyId, $remoteCid);
}
public static function unsupported(?string $message = null): self
{
return new self(EngagementStatus::Unsupported, message: $message);
}
public static function rateLimited(?string $message = null): self
{
return new self(EngagementStatus::RateLimited, message: $message);
}
public static function authExpired(?string $message = null): self
{
return new self(EngagementStatus::AuthExpired, message: $message);
}
public static function failed(?string $message = null): self
{
return new self(EngagementStatus::Failed, message: $message);
}
/**
* The platform has not finished the reply. Anything that cannot wait for it
* sees an ordinary failure.
*/
public static function processing(string $containerId): self
{
return new self(
EngagementStatus::Failed,
message: 'The platform is still processing the reply. Try again in a moment.',
processingContainerId: $containerId,
);
}
public function isOk(): bool
{
return $this->status->isOk();
}
}