-
- def _setpostdata(self, text, aspect_ids, photos):
- """This function prepares data for posting.
-
- :param text: Text to post.
- :type text: str
- :param aspect_ids: Aspect ids to send post to.
- :type aspect_ids: str
- """
- data = {}
- data['aspect_ids'] = aspect_ids
- data['status_message'] = {'text': text}
- if photos:
- data['photos'] = photos
- self._post_data = data
-
- def _post(self):
- """Sends post to an aspect.
-
- :returns: diaspy.models.Post -- the Post which has been created
- """
- r = self.connection.post('status_messages',
- data=json.dumps(self._post_data),
- headers={'content-type': 'application/json',
- 'accept': 'application/json',
- 'x-csrf-token': self.get_token()})
- if r.status_code != 201:
- raise Exception('{0}: Post could not be posted.'.format(
- r.status_code))
-
- return diaspy.models.Post(str(r.json()['id']), self.connection)