logger->info("Getting message {$message_id}"); $uri = "/message/{$message_id}"; $response = $this->communicator->get($uri); $body = $response->getBody()->getContents(); if (trim($body) === '') { throw new EmptyResponse($uri); } $json = json_decode($body); if (!isset($json->message)) { throw new MissingResponse('message'); } return $json->message; } public function grabAttachments(string $message_uid): int { $this->logger->info("Grabbing attachments for message UID {$message_uid}"); $uri = '/attachments/grab'; $response = $this->communicator->put($uri, ['messages' => [$message_uid]]); $body = $response->getBody()->getContents(); if (trim($body) === '') { return 0; } $json = json_decode($body); if (!isset($json->total)) { return 0; } return $json->total; } }