def to_api_data(self, restrict_keys=None):
cc = self._cc  <EOL>message = {<EOL>cc('<STR_LIT>'): self.subject,<EOL>cc('<STR_LIT:body>'): {<EOL>cc('<STR_LIT>'): self.body_type,<EOL>cc('<STR_LIT:content>'): self.body},<EOL>cc('<STR_LIT>'): cc(self.importance.value),<EOL>cc('<STR_LIT>'): self.flag.to_api_data(),<EOL>cc('<STR_LIT>'): self.is_read_receipt_requested,<EOL>cc('<STR_LIT>'): self.is_delivery_receipt_requested,<EOL>}<EOL>if self.to:<EOL><INDENT>message[cc('<STR_LIT>')] = [self._recipient_to_cloud(recipient)<EOL>for recipient in self.to]<EOL><DEDENT>if self.cc:<EOL><INDENT>message[cc('<STR_LIT>')] = [self._recipient_to_cloud(recipient)<EOL>for recipient in self.cc]<EOL><DEDENT>if self.bcc:<EOL><INDENT>message[cc('<STR_LIT>')] = [self._recipient_to_cloud(recipient)<EOL>for recipient in self.bcc]<EOL><DEDENT>if self.reply_to:<EOL><INDENT>message[cc('<STR_LIT>')] = [self._recipient_to_cloud(recipient) for<EOL>recipient in self.reply_to]<EOL><DEDENT>if self.attachments:<EOL><INDENT>message[cc('<STR_LIT>')] = self.attachments.to_api_data()<EOL><DEDENT>if self.sender and self.sender.address:<EOL><INDENT>message[cc('<STR_LIT>')] = self._recipient_to_cloud(self.sender)<EOL><DEDENT>if self.categories or '<STR_LIT>' in (restrict_keys or {}):<EOL><INDENT>message[cc('<STR_LIT>')] = self.categories<EOL><DEDENT>if self.object_id and not self.__is_draft:<EOL><INDENT>message[cc('<STR_LIT:id>')] = self.object_id<EOL>if self.created:<EOL><INDENT>message[cc('<STR_LIT>')] = self.created.astimezone(<EOL>pytz.utc).isoformat()<EOL><DEDENT>if self.received:<EOL><INDENT>message[cc('<STR_LIT>')] = self.received.astimezone(<EOL>pytz.utc).isoformat()<EOL><DEDENT>if self.sent:<EOL><INDENT>message[cc('<STR_LIT>')] = self.sent.astimezone(<EOL>pytz.utc).isoformat()<EOL><DEDENT>message[cc('<STR_LIT>')] = bool(self.attachments)<EOL>message[cc('<STR_LIT>')] = self.is_read<EOL>message[cc('<STR_LIT>')] = self.__is_draft<EOL>message[cc('<STR_LIT>')] = self.conversation_id<EOL>message[cc('<STR_LIT>')] = self.folder_id<EOL><DEDENT>if restrict_keys:<EOL><INDENT>for key in list(message.keys()):<EOL><INDENT>if key not in restrict_keys:<EOL><INDENT>del message[key]<EOL><DEDENT><DEDENT><DEDENT>return message<EOL>
Returns a dict representation of this message prepared to be send
        to the cloud

        :param restrict_keys: a set of keys to restrict the returned
         data to
        :type restrict_keys: dict or set
        :return: converted to cloud based keys
        :rtype: dict