Files
PHPShop/moneta/class/protocol/CallbackResponse.php
T

56 lines
1.3 KiB
PHP

<?php
declare(strict_types=1);
namespace MonetaPhpShop\protocol;
/**
* Òåëî è òèï îòâåòà ìîäóëÿ íà Check URL / Pay URL.
*/
final class CallbackResponse
{
public const CONTENT_TYPE_XML = 'application/xml; charset=UTF-8';
public const CONTENT_TYPE_JSON = 'application/json; charset=UTF-8';
public const CONTENT_TYPE_TEXT = 'text/plain; charset=UTF-8';
/** @var string */
private $contentType;
/** @var string */
private $body;
private function __construct(string $contentType, string $body)
{
$this->contentType = $contentType;
$this->body = $body;
}
/**
* Îòêàç áåç ïîäðîáíîñòåé: ïðè÷èíà ïèøåòñÿ òîëüêî â æóðíàë ìîäóëÿ.
*/
public static function fail(): self
{
return new self(self::CONTENT_TYPE_TEXT, AssistantProtocol::TEXT_FAIL);
}
public static function xml(string $body): self
{
return new self(self::CONTENT_TYPE_XML, $body);
}
public static function json(string $body): self
{
return new self(self::CONTENT_TYPE_JSON, $body);
}
public function getContentType(): string
{
return $this->contentType;
}
public function getBody(): string
{
return $this->body;
}
}