public function testTransform() { /** @var Message $message */ $message = DataTransformer::transform(['message_id' => 12, 'from' => ['id' => 10], 'reply_to_message' => ['message_id' => 10]], Message::class); $this->assertEquals(12, $message->getMessageId()); $this->assertEquals(10, $message->getFrom()->getId()); $this->assertEquals(10, $message->getReplyToMessage()->getMessageId()); /** @var UserProfilePhotos $userProfilePhotos */ $userProfilePhotos = DataTransformer::transform(['total_count' => 2, 'photos' => [[['file_id' => 1], ['file_id' => 2]]]], UserProfilePhotos::class); $this->assertEquals(1, $userProfilePhotos->getPhotos()[0][0]->getFileId()); /** @var Fixture $fixture */ $fixture = DataTransformer::transform(['id' => '10', 'name' => 'Alireza', 'expires_at' => '2015-09-09'], Fixture::class); $this->assertEquals(10, $fixture->getId()); $this->assertEquals('Alireza', $fixture->getName()); $this->assertInstanceOf(DateTime::class, $fixture->getExpiresAt()); $this->assertEquals(9, $fixture->getExpiresAt()->format('m')); /** @var Fixture $fixture */ $fixture = DataTransformer::transform(['expires_at' => false], Fixture::class); $this->assertNull($fixture->getExpiresAt()); /** @var Fixture $fixture */ $fixture = DataTransformer::transform(['expires_at' => null], Fixture::class); $this->assertNull($fixture->getExpiresAt()); }
/** * @Api * Get File * * Use this method to get basic info about a file and prepare it for downloading. For the moment, bots can download * files of up to 20MB in size. On success, a File object is returned. The file can then be downloaded via the link * https://api.telegram.org/file/bot<token>/<file_path>, where <file_path> is taken from the response. It is * guaranteed that the link will be valid for at least 1 hour. When the link expires, a new one can be requested by * calling getFile again. * * @see https://core.telegram.org/bots/api#getfile * * @param string $fileId File identifier to get info about * @return mixed */ public function getFile($fileId) { return DataTransformer::transform($this->post('getFile', ['file_id' => $fileId])->getResult(), File::class); }