57 public function request(
string $method,
string $uri, array $params): array
59 $getLogContext =
static function (
int $statusCode, $response,
string $error =
'' )
60 use ($method, $uri, $params): array
67 'requestParams' => $params,
68 'statusCode' => $statusCode,
70 'response' => $response,
81 $this->httpClient->waitResponse(
true);
82 $this->httpClient->query($method, $uri, $paramString);
84 if ($this->httpClient->getStatus() < 300)
87 $this->context->getLogger()
88 ->debug(
"API office365 success" . $this->httpClient->getStatus()
90 $this->httpClient->getStatus(),
91 $this->httpClient->getResult(),
99 $error = Json::decode($this->httpClient->getResult());
102 "[" . $error[
'error'][
'code'] .
"] " . $error[
'error'][
'message'],
104 $this->context->getLogger()
105 ->warning(
"API office365 returned error code "
106 . $this->httpClient->getStatus()
107 .
": " . $error[
'error'][
'message'],
109 $this->httpClient->getStatus(),
110 $this->httpClient->getResult(),
111 $error[
'error'][
'message']
114 switch ($this->httpClient->getStatus())
118 $error[
'error'][
'code'],
125 $error[
'error'][
'code'],
132 $error[
'error'][
'code'],
139 $error[
'error'][
'code'],
146 $error[
'error'][
'code'],
153 $error[
'error'][
'code'],
154 $this->httpClient->getStatus(),
162 $this->context->getLogger()
163 ->error(
"ArgumentException from office365", $getLogContext(
164 $this->httpClient->getStatus(),
165 $this->httpClient->getResult(),
166 $exception->getMessage()
168 foreach($this->httpClient->getError() as $code => $error)
170 $this->
getStatus()->addError($code, $error);
177 $this->context->getLogger()
178 ->error(
"ApiException from office365", $getLogContext(
188 $this->context->getLogger()
189 ->error(
"Exception from office365: " . $e->getMessage(), $getLogContext(
430 $contentType = $this->httpClient->getHeaders()->getContentType();
432 if ($contentType ===
'multipart/mixed')
435 $this->httpClient->getResult(),
436 $this->httpClient->getHeaders()->getBoundary()
441 $response = $this->httpClient->getResult()
442 ? Json::decode($this->httpClient->getResult())