before calling any of the post functions.
"""
-
self._client = client
+ self.post_id = post_id
+
+
+ def fetch_data(self):
r = self._client.session.get(self._client.pod +
'/posts/' +
- post_id +
+ self.post_id +
'.json')
if r.status_code == 200:
self.data = r.json()
r = self._client.session.post(self._client.pod +
'/posts/' +
- str(self.data['id']) +
+ self.post_id +
'/likes',
data=data,
headers={'accept': 'application/json'})
data = {'authenticity_token': self._client.get_token()}
+ post_data = self.fetch_data()
+
r = self._client.session.delete(self._client.pod + '/posts/' +
- str(self.data['id']) +
+ self.post_id +
'/likes/' +
- str(self.data['interactions']
+ str(post_data['interactions']
['likes'][0]['id']),
data=data)
"""
- data = {'root_guid': self.data['guid'],
+ post_data = self.fetch_data()
+
+ data = {'root_guid': post_data['guid'],
'authenticity_token': self._client.get_token()}
r = self._client.session.post(self._client.pod +
r = self._client.session.post(self._client.pod +
'/posts/' +
- str(self.data['id']) +
+ self.post_id +
'/comments',
data=data,
headers={'accept': 'application/json'})
data = {'authenticity_token': self._client.get_token()}
r = self._client.session.delete(self._client.pod + '/posts/' +
- str(self.data['id']) +
+ self.post_id +
'/comments/' +
comment_id,
data=data,