Deserialize a new MediaGroupMessage from a given dictionary.

        :return: new MediaGroupMessage instance.
        :rtype: MediaGroupMessage
961766
def from_array(array):
        
        if array is None or not array:
            return None
        # end if
        assert_type_or_raise(array, dict, parameter_name="array")
        from pytgbot.api_types.sendable.input_media import InputMediaPhoto
        from pytgbot.api_types.sendable.input_media import InputMediaVideo
        

        data = {}
        if isinstance(array.get('media'), InputMediaPhoto):
            data['media'] = InputMediaPhoto.from_array_list(array.get('media'), list_level=1)
        elif isinstance(array.get('media'), InputMediaVideo):
            data['media'] = InputMediaVideo.from_array_list(array.get('media'), list_level=1)
        else:
            raise TypeError('Unknown type, must be one of InputMediaPhoto, InputMediaVideo.')
        # end if
        if array.get('chat_id') is None:
            data['receiver'] = None
        elif isinstance(array.get('chat_id'), None):
            data['receiver'] = None(array.get('chat_id'))
        elif isinstance(array.get('chat_id'), str):
            data['receiver'] = u(array.get('chat_id'))
        elif isinstance(array.get('chat_id'), int):
            data['receiver'] = int(array.get('chat_id'))
        else:
            raise TypeError('Unknown type, must be one of None, str, int or None.')
        # end if
        if array.get('reply_to_message_id') is None:
            data['reply_id'] = None
        elif isinstance(array.get('reply_to_message_id'), DEFAULT_MESSAGE_ID):
            data['reply_id'] = DEFAULT_MESSAGE_ID(array.get('reply_to_message_id'))
        elif isinstance(array.get('reply_to_message_id'), int):
            data['reply_id'] = int(array.get('reply_to_message_id'))
        else:
            raise TypeError('Unknown type, must be one of DEFAULT_MESSAGE_ID, int or None.')
        # end if
        data['disable_notification'] = bool(array.get('disable_notification')) if array.get('disable_notification') is not None else None
        return MediaGroupMessage(**data)
1138209
def _deserialize_dict(data, boxed_type):
    
    return {k: _deserialize(v, boxed_type)
            for k, v in six.iteritems(data)}
108182
def create_payload(self):
        
        payload = super(Media, self).create_payload()
        if 'path_' in payload:
            payload['path'] = payload.pop('path_')
        return {u'medium': payload}
391241
def from_dict(cls, label=None, label2=None, icon=None, thumbnail=None,
                  path=None, selected=None, info=None, properties=None,
                  context_menu=None, replace_context_menu=False,
                  is_playable=None, info_type='video', stream_info=None):
        '''
        '''
        listitem = cls(label, label2, icon, thumbnail, path)

        if selected is not None:
            listitem.select(selected)

        if info:
            listitem.set_info(info_type, info)

        if is_playable:
            listitem.set_is_playable(True)

        if properties:
            # Need to support existing tuples, but prefer to have a dict for
            # properties.
            if hasattr(properties, 'items'):
                properties = properties.items()
            for key, val in properties:
                listitem.set_property(key, val)

        if stream_info:
            for stream_type, stream_values in stream_info.items():
                listitem.add_stream_info(stream_type, stream_values)

        if context_menu:
            listitem.add_context_menu_items(context_menu, replace_context_menu)

        return listitem
16800
def as_dict(self):
        
        d = {}
        _add_string(d, 'obstory_name', self.obstory_name)
        _add_string(d, 'semantic_type', self.semantic_type)
        _add_value(d, 'time_min', self.time_min)
        _add_value(d, 'time_max', self.time_max)
        _add_string(d, 'group_id', self.group_id)
        _add_string(d, 'observation_id', self.observation_id)
        _add_value(d, 'skip', self.skip)
        _add_value(d, 'limit', self.limit)
        d['meta'] = list((x.as_dict() for x in self.meta_constraints))
        return d
483779
def dict_to_ddb(item):
    # type: (Dict[str, Any]) -> Dict[str, Any]
    # TODO: narrow these types down
    
    serializer = TypeSerializer()
    return {key: serializer.serialize(value) for key, value in item.items()}
496425
def _from_dict(cls, _dict):
        """"""
        args = {}
        if 'input' in _dict:
            args['input'] = MessageInput._from_dict(_dict.get('input'))
        if 'intents' in _dict:
            args['intents'] = [
                RuntimeIntent._from_dict(x) for x in (_dict.get('intents'))
            ]
        if 'entities' in _dict:
            args['entities'] = [
                RuntimeEntity._from_dict(x) for x in (_dict.get('entities'))
            ]
        return cls(**args)
1011484
def from_dict(self, d):
        
        self.length = d.get("length", 0)
        self.instanceHigh = d.get("instanceHigh", 0)
        self.instanceMid = d.get("instanceMid", 0)
        self.instanceLow = d.get("instanceLow", 0)

        material = d.get("material", {'Data1':0, 'Data2':0, 'Data3':0, 'Data4': [0 for i in range(8)]})

        self.Data1 = material.get('Data1', 0)
        self.Data2 = material.get('Data2', 0)
        self.Data3 = material.get('Data3', 0)

        self.Data4 = material.get("Data4", [0 for i in range(8)])
        self.SMPTELabel = d.get("SMPTELabel", [0 for i in range(12)])
576444
def get_groups_dict(self) -> Dict:
        
        return {
            k: deserializer.inventory.InventoryElement.serialize(v).dict()
            for k, v in self.groups.items()
        }
969527
def _from_dict(cls, _dict):
        """"""
        args = {}
        if 'request' in _dict:
            args['request'] = MessageRequest._from_dict(_dict.get('request'))
        else:
            raise ValueError(
                'Required property \'request\' not present in Log JSON')
        if 'response' in _dict:
            args['response'] = MessageResponse._from_dict(_dict.get('response'))
        else:
            raise ValueError(
                'Required property \'response\' not present in Log JSON')
        if 'log_id' in _dict:
            args['log_id'] = _dict.get('log_id')
        else:
            raise ValueError(
                'Required property \'log_id\' not present in Log JSON')
        if 'request_timestamp' in _dict:
            args['request_timestamp'] = _dict.get('request_timestamp')
        else:
            raise ValueError(
                'Required property \'request_timestamp\' not present in Log JSON'
            )
        if 'response_timestamp' in _dict:
            args['response_timestamp'] = _dict.get('response_timestamp')
        else:
            raise ValueError(
                'Required property \'response_timestamp\' not present in Log JSON'
            )
        if 'workspace_id' in _dict:
            args['workspace_id'] = _dict.get('workspace_id')
        else:
            raise ValueError(
                'Required property \'workspace_id\' not present in Log JSON')
        if 'language' in _dict:
            args['language'] = _dict.get('language')
        else:
            raise ValueError(
                'Required property \'language\' not present in Log JSON')
        return cls(**args)
7220
def create_message_set(messages, codec=CODEC_NONE, key=None, compresslevel=None):
    
    if codec == CODEC_NONE:
        return [create_message(m, k) for m, k in messages]
    elif codec == CODEC_GZIP:
        return [create_gzip_message(messages, key, compresslevel)]
    elif codec == CODEC_SNAPPY:
        return [create_snappy_message(messages, key)]
    else:
        raise UnsupportedCodecError("Codec 0x%02x unsupported" % (codec,))
1052950
def to_dict(self) -> Dict[str, Any]:
        
        jsn = {
            'kind': self.__class__.__name__,
            'message': self.message
        } # type: Dict[str, Any]
        data = self.data
        if data:
            jsn['data'] = data
        jsn = {'error': jsn}
        return jsn
736597
def to_json(msg):
    
    result = {}
    
    # herald specification version
    #result[herald.MESSAGE_HERALD_VERSION] = herald.HERALD_SPECIFICATION_VERSION
    
    # headers
    result[herald.MESSAGE_HEADERS] = {}        
    if msg.headers is not None:
        for key in msg.headers:
            result[herald.MESSAGE_HEADERS][key] = msg.headers.get(key) or None        
    
    # subject
    result[herald.MESSAGE_SUBJECT] = msg.subject
    # content
    if msg.content is not None:
        if isinstance(msg.content, str):
            # string content
            result[herald.MESSAGE_CONTENT] = msg.content
        else:
            # jaborb content
            result[herald.MESSAGE_CONTENT] = jabsorb.to_jabsorb(msg.content)
    
    # metadata
    result[herald.MESSAGE_METADATA] = {}        
    if msg.metadata is not None:
        for key in msg.metadata:
            result[herald.MESSAGE_METADATA][key] = msg.metadata.get(key) or None
            
    return json.dumps(result, default=herald.utils.json_converter)
841002
def to_array(self):
        
        array = super(InputMediaPhoto, self).to_array()
        array['type'] = u(self.type)  # py2: type unicode, py3: type str

        array['media'] = u(self.media)  # py2: type unicode, py3: type str

        if self.caption is not None:
            array['caption'] = u(self.caption)  # py2: type unicode, py3: type str

        if self.parse_mode is not None:
            array['parse_mode'] = u(self.parse_mode)  # py2: type unicode, py3: type str

        return array
239488
def to_array(self):
        
        array = super(Message, self).to_array()
        array['message_id'] = int(self.message_id)  # type int
        array['date'] = int(self.date)  # type int
        array['chat'] = self.chat.to_array()  # type Chat
        if self.from_peer is not None:
            array['from'] = self.from_peer.to_array()  # type User
        if self.forward_from is not None:
            array['forward_from'] = self.forward_from.to_array()  # type User
        if self.forward_from_chat is not None:
            array['forward_from_chat'] = self.forward_from_chat.to_array()  # type Chat
        if self.forward_from_message_id is not None:
            array['forward_from_message_id'] = int(self.forward_from_message_id)  # type int
        if self.forward_signature is not None:
            array['forward_signature'] = u(self.forward_signature)  # py2: type unicode, py3: type str
        if self.forward_date is not None:
            array['forward_date'] = int(self.forward_date)  # type int
        if self.reply_to_message is not None:
            array['reply_to_message'] = self.reply_to_message.to_array()  # type Message
        if self.edit_date is not None:
            array['edit_date'] = int(self.edit_date)  # type int
        if self.media_group_id is not None:
            array['media_group_id'] = u(self.media_group_id)  # py2: type unicode, py3: type str
        if self.author_signature is not None:
            array['author_signature'] = u(self.author_signature)  # py2: type unicode, py3: type str
        if self.text is not None:
            array['text'] = u(self.text)  # py2: type unicode, py3: type str
        if self.entities is not None:
            array['entities'] = self._as_array(self.entities)  # type list of MessageEntity
        if self.caption_entities is not None:
            array['caption_entities'] = self._as_array(self.caption_entities)  # type list of MessageEntity
        if self.audio is not None:
            array['audio'] = self.audio.to_array()  # type Audio
        if self.document is not None:
            array['document'] = self.document.to_array()  # type Document
        if self.animation is not None:
            array['animation'] = self.animation.to_array()  # type Animation
        if self.game is not None:
            array['game'] = self.game.to_array()  # type Game
        if self.photo is not None:
            array['photo'] = self._as_array(self.photo)  # type list of PhotoSize
        if self.sticker is not None:
            array['sticker'] = self.sticker.to_array()  # type Sticker
        if self.video is not None:
            array['video'] = self.video.to_array()  # type Video
        if self.voice is not None:
            array['voice'] = self.voice.to_array()  # type Voice
        if self.video_note is not None:
            array['video_note'] = self.video_note.to_array()  # type VideoNote
        if self.caption is not None:
            array['caption'] = u(self.caption)  # py2: type unicode, py3: type str
        if self.contact is not None:
            array['contact'] = self.contact.to_array()  # type Contact
        if self.location is not None:
            array['location'] = self.location.to_array()  # type Location
        if self.venue is not None:
            array['venue'] = self.venue.to_array()  # type Venue
        if self.new_chat_members is not None:
            array['new_chat_members'] = self._as_array(self.new_chat_members)  # type list of User
        if self.left_chat_member is not None:
            array['left_chat_member'] = self.left_chat_member.to_array()  # type User
        if self.new_chat_title is not None:
            array['new_chat_title'] = u(self.new_chat_title)  # py2: type unicode, py3: type str
        if self.new_chat_photo is not None:
            array['new_chat_photo'] = self._as_array(self.new_chat_photo)  # type list of PhotoSize
        if self.delete_chat_photo is not None:
            array['delete_chat_photo'] = bool(self.delete_chat_photo)  # type bool
        if self.group_chat_created is not None:
            array['group_chat_created'] = bool(self.group_chat_created)  # type bool
        if self.supergroup_chat_created is not None:
            array['supergroup_chat_created'] = bool(self.supergroup_chat_created)  # type bool
        if self.channel_chat_created is not None:
            array['channel_chat_created'] = bool(self.channel_chat_created)  # type bool
        if self.migrate_to_chat_id is not None:
            array['migrate_to_chat_id'] = int(self.migrate_to_chat_id)  # type int
        if self.migrate_from_chat_id is not None:
            array['migrate_from_chat_id'] = int(self.migrate_from_chat_id)  # type int
        if self.pinned_message is not None:
            array['pinned_message'] = self.pinned_message.to_array()  # type Message
        if self.invoice is not None:
            array['invoice'] = self.invoice.to_array()  # type Invoice
        if self.successful_payment is not None:
            array['successful_payment'] = self.successful_payment.to_array()  # type SuccessfulPayment
        if self.connected_website is not None:
            array['connected_website'] = u(self.connected_website)  # py2: type unicode, py3: type str
        if self.passport_data is not None:
            array['passport_data'] = self.passport_data.to_array()  # type PassportData
        return array
181635
def _from_dict(cls, _dict):
        """"""
        args = {}
        if 'global' in _dict:
            args['global_'] = MessageContextGlobal._from_dict(
                _dict.get('global'))
        if 'skills' in _dict:
            args['skills'] = MessageContextSkills._from_dict(
                _dict.get('skills'))
        return cls(**args)
1141219
def from_array(array):
        
        if array is None or not array:
            return None
        # end if
        assert_type_or_raise(array, dict, parameter_name="array")

        from ..receivable.media import Location
        from ..receivable.peer import User

        data = {}
        data['result_id'] = u(array.get('result_id'))
        data['from_peer'] = User.from_array(array.get('from'))
        data['query'] = u(array.get('query'))
        data['location'] = Location.from_array(array.get('location')) if array.get('location') is not None else None
        data['inline_message_id'] = u(array.get('inline_message_id')) if array.get('inline_message_id') is not None else None
        data['_raw'] = array
        return ChosenInlineResult(**data)