| 1 |
<?php |
| 2 |
|
| 3 |
namespace Yoast\WP\SEO\AI_HTTP_Request\Domain; |
| 4 |
|
| 5 |
/** |
| 6 |
* Class Response |
| 7 |
* Represents a response from the AI Generator API. |
| 8 |
*/ |
| 9 |
class Response { |
| 10 |
|
| 11 |
/** |
| 12 |
* The response body. |
| 13 |
* |
| 14 |
* @var string |
| 15 |
*/ |
| 16 |
private $body; |
| 17 |
|
| 18 |
/** |
| 19 |
* The response code. |
| 20 |
* |
| 21 |
* @var int |
| 22 |
*/ |
| 23 |
private $response_code; |
| 24 |
|
| 25 |
/** |
| 26 |
* The response message. |
| 27 |
* |
| 28 |
* @var string |
| 29 |
*/ |
| 30 |
private $message; |
| 31 |
|
| 32 |
/** |
| 33 |
* The error code. |
| 34 |
* |
| 35 |
* @var string |
| 36 |
*/ |
| 37 |
private $error_code; |
| 38 |
|
| 39 |
/** |
| 40 |
* The missing licenses. |
| 41 |
* |
| 42 |
* @var array<string> |
| 43 |
*/ |
| 44 |
private $missing_licenses; |
| 45 |
|
| 46 |
/** |
| 47 |
* Response constructor. |
| 48 |
* |
| 49 |
* @param string $body The response body. |
| 50 |
* @param int $response_code The response code. |
| 51 |
* @param string $message The response message. |
| 52 |
* @param string $error_code The error code. |
| 53 |
* @param array<string> $missing_licenses The missing licenses. |
| 54 |
*/ |
| 55 |
public function __construct( string $body, int $response_code, string $message, string $error_code = '', $missing_licenses = [] ) { |
| 56 |
$this->body = $body; |
| 57 |
$this->response_code = $response_code; |
| 58 |
$this->message = $message; |
| 59 |
$this->error_code = $error_code; |
| 60 |
$this->missing_licenses = $missing_licenses; |
| 61 |
} |
| 62 |
|
| 63 |
/** |
| 64 |
* Gets the response body. |
| 65 |
* |
| 66 |
* @return string The response body. |
| 67 |
*/ |
| 68 |
public function get_body() { |
| 69 |
return $this->body; |
| 70 |
} |
| 71 |
|
| 72 |
/** |
| 73 |
* Gets the response code. |
| 74 |
* |
| 75 |
* @return int The response code. |
| 76 |
*/ |
| 77 |
public function get_response_code(): int { |
| 78 |
return $this->response_code; |
| 79 |
} |
| 80 |
|
| 81 |
/** |
| 82 |
* Gets the response message. |
| 83 |
* |
| 84 |
* @return string The response message. |
| 85 |
*/ |
| 86 |
public function get_message(): string { |
| 87 |
return $this->message; |
| 88 |
} |
| 89 |
|
| 90 |
/** |
| 91 |
* Gets the error code. |
| 92 |
* |
| 93 |
* @return string The error code. |
| 94 |
*/ |
| 95 |
public function get_error_code(): string { |
| 96 |
return $this->error_code; |
| 97 |
} |
| 98 |
|
| 99 |
/** |
| 100 |
* Gets the missing licenses. |
| 101 |
* |
| 102 |
* @return array<string> The missing licenses. |
| 103 |
*/ |
| 104 |
public function get_missing_licenses(): array { |
| 105 |
return $this->missing_licenses; |
| 106 |
} |
| 107 |
} |
| 108 |
|