def build_send(self, entity: BaseEntity, from_user: UserType, to_user_key: RsaKey = None) -> Union[str, Dict]:
        """
        Build POST data for sending out to remotes.

        :param entity: The outbound ready entity for this protocol.
        :param from_user: The user sending this payload. Must have ``private_key`` and ``id`` properties.
        :param to_user_key: (Optional) Public key of user we're sending a private payload to.
        :returns: dict or string depending on if private or public payload.
        """
        if entity.outbound_doc is not None:
            # Use pregenerated outbound document
            xml = entity.outbound_doc
        else:
            xml = entity.to_xml()
        me = MagicEnvelope(etree.tostring(xml), private_key=from_user.private_key, author_handle=from_user.handle)
        rendered = me.render()
        if to_user_key:
            return EncryptedPayload.encrypt(rendered, to_user_key)
        return rendered
def build_send ( self , entity : BaseEntity , from_user : UserType , to_user_key : RsaKey = None ) -> Union [ str , Dict ] : if entity . outbound_doc is not None : xml = entity . outbound_doc else : xml = entity . to_xml ( ) me = MagicEnvelope ( etree . tostring ( xml ) , private_key = from_user . private_key , author_handle = from_user . handle ) rendered = me . render ( ) if to_user_key : return EncryptedPayload . encrypt ( rendered , to_user_key ) return rendered
Build POST data for sending out to remotes.

        :param entity: The outbound ready entity for this protocol.
        :param from_user: The user sending this payload. Must have ``private_key`` and ``id`` properties.
        :param to_user_key: (Optional) Public key of user we're sending a private payload to.
        :returns: dict or string depending on if private or public payload.