function testSerialize() { $object = new Message(); $object->setMessageId(12); $chat = new Chat(); $chat->setFirstName('Masoud'); $object->setChat($chat); $serialized = DataTransformer::serialize($object); $this->assertEquals(['message_id' => 12, 'chat' => ['first_name' => 'Masoud']], $serialized); $object = new UserProfilePhotos(); $object->setTotalCount(5); $object->setPhotos([(new PhotoSize())->setFileId(10), (new PhotoSize())->setFileId(20)]); $this->assertEquals(['total_count' => 5, 'photos' => [['file_id' => 10], ['file_id' => 20]]], DataTransformer::serialize($object)); $object = new Fixture(); $object->setExpiresAt(new DateTime()); $serialized = DataTransformer::serialize($object); $this->assertEquals(date('c'), $serialized['expires_at']); }
/** * @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); }