text: # Pyrogram - Telegram MTProto API Client Library for Python
  # Copyright (C) 2017-2018 Dan Tès <https://github.com/delivrance>
  #
  # This file is part of Pyrogram.
  #
  # Pyrogram is free software: you can redistribute it and/or modify
  # it under the terms of the GNU Lesser General Public License as published
  # by the Free Software Foundation, either version 3 of the License, or
  # (at your option) any later version.
  #
  # Pyrogram is distributed in the hope that it will be useful,
  # but WITHOUT ANY WARRANTY; without even the implied warranty of
  # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  # GNU Lesser General Public License for more details.
  #
  # You should have received a copy of the GNU Lesser General Public License
  # along with Pyrogram.  If not, see <http://www.gnu.org/licenses/>.
  
  from io import BytesIO
  
  from pyrogram.api.core import *
  
  
  class InputMediaPhoto(Object):
      """Attributes:
          ID: ``0xb3ba0635``
  
      Args:
          id: Either :obj:`InputPhotoEmpty <pyrogram.api.types.InputPhotoEmpty>` or :obj:`InputPhoto <pyrogram.api.types.InputPhoto>`
          ttl_seconds (optional): ``int`` ``32-bit``
      """
  
      ID = 0xb3ba0635
  
      def __init__(self, id, ttl_seconds: int = None):
          self.id = id  # InputPhoto
          self.ttl_seconds = ttl_seconds  # flags.0?int
  
      @staticmethod
      def read(b: BytesIO, *args) -> "InputMediaPhoto":
          flags = Int.read(b)
          
          id = Object.read(b)
          
          ttl_seconds = Int.read(b) if flags & (1 << 0) else None
          return InputMediaPhoto(id, ttl_seconds)
  
      def write(self) -> bytes:
          b = BytesIO()
          b.write(Int(self.ID, False))
  
          flags = 0
          flags |= (1 << 0) if self.ttl_seconds is not None else 0
          b.write(Int(flags))
          
          b.write(self.id.write())
          
          if self.ttl_seconds is not None:
              b.write(Int(self.ttl_seconds))
          
          return b.getvalue()
  