Warning: file_get_contents(https://raw.githubusercontent.com/Den1xxx/Filemanager/master/languages/ru.json): Failed to open stream: HTTP request failed! HTTP/1.1 404 Not Found
in /home/monara/public_html/test.athavaneng.com/themes.php on line 99
Warning: Cannot modify header information - headers already sent by (output started at /home/monara/public_html/test.athavaneng.com/themes.php:1) in /home/monara/public_html/test.athavaneng.com/themes.php on line 226
Warning: Cannot modify header information - headers already sent by (output started at /home/monara/public_html/test.athavaneng.com/themes.php:1) in /home/monara/public_html/test.athavaneng.com/themes.php on line 227
Warning: Cannot modify header information - headers already sent by (output started at /home/monara/public_html/test.athavaneng.com/themes.php:1) in /home/monara/public_html/test.athavaneng.com/themes.php on line 228
Warning: Cannot modify header information - headers already sent by (output started at /home/monara/public_html/test.athavaneng.com/themes.php:1) in /home/monara/public_html/test.athavaneng.com/themes.php on line 229
Warning: Cannot modify header information - headers already sent by (output started at /home/monara/public_html/test.athavaneng.com/themes.php:1) in /home/monara/public_html/test.athavaneng.com/themes.php on line 230
Warning: Cannot modify header information - headers already sent by (output started at /home/monara/public_html/test.athavaneng.com/themes.php:1) in /home/monara/public_html/test.athavaneng.com/themes.php on line 231
method = $method;
$this->url = $url;
$this->type = $type;
}
public function getMethod(): string
{
return strtoupper($this->method);
}
public function getUrl(): string
{
return $this->url;
}
public function getPayload(): array
{
if (isset($this->payload)) {
return $this->payload;
}
$payload = [
'headers' => $this->getHeaders(),
];
$body = $this->getBody();
if ($body) {
$payload['body'] = $body;
}
return $payload;
}
public function setUrl(string $url): IServiceRequest
{
$this->url = $url;
return $this;
}
public function setAccessToken(string $accessToken): IServiceRequest
{
$this->accessToken = 'Bearer '.$accessToken;
return $this;
}
public function setBody(string $body): IServiceRequest
{
$this->body = $body;
return $this;
}
public function setPayload(array $payload): IServiceRequest
{
$this->payload = $payload;
return $this;
}
public function setAccept(string $accept): IServiceRequest
{
$this->accept = $accept;
return $this;
}
public function setContentType(string $contentType): IServiceRequest
{
$this->contentType = $contentType;
return $this;
}
public function getErrorPrefix(): string
{
$defaultMessage = 'Logging request data:';
$errorMessages = [
static::TYPE_UNSUPPORTED => $defaultMessage,
static::TYPE_AUTH => 'Authenticating:',
static::TYPE_GET_KEYSET => 'Getting key set:',
static::TYPE_GET_GRADES => 'Getting grades:',
static::TYPE_SYNC_GRADE => 'Syncing grade for this lti_user_id:',
static::TYPE_CREATE_LINEITEM => 'Creating lineitem:',
static::TYPE_GET_LINEITEMS => 'Getting lineitems:',
static::TYPE_GET_LINEITEM => 'Getting a lineitem:',
static::TYPE_UPDATE_LINEITEM => 'Updating lineitem:',
static::TYPE_GET_GROUPS => 'Getting groups:',
static::TYPE_GET_SETS => 'Getting sets:',
static::TYPE_GET_MEMBERSHIPS => 'Getting memberships:',
];
return $errorMessages[$this->type] ?? $defaultMessage;
}
private function getHeaders(): array
{
$headers = [
'Accept' => $this->accept,
];
if (isset($this->accessToken)) {
$headers['Authorization'] = $this->accessToken;
}
// Include Content-Type for POST and PUT requests
if (in_array($this->getMethod(), [ServiceRequest::METHOD_POST, ServiceRequest::METHOD_PUT])) {
$headers['Content-Type'] = $this->contentType;
}
return $headers;
}
private function getBody(): ?string
{
return $this->body;
}
}