Skip to content

Commit

Permalink
Fixes #30, serializable issue with attachments
Browse files Browse the repository at this point in the history
  • Loading branch information
Robert Grant committed Nov 19, 2016
1 parent 4cfad1d commit b469024
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion groupy/api/endpoint.py
Original file line number Diff line number Diff line change
Expand Up @@ -479,13 +479,20 @@ def post(cls, bot_id, text, *attachments, picture_url=None):
:returns: the created message
:rtype: :class:`dict`
"""
def serializable(attachments):
for attachment in attachments:
try:
yield attachment.as_dict()
except AttributeError:
yield attachment

r = requests.post(
cls.build_url('post'),
data=json.dumps({
'bot_id': bot_id,
'text': text,
'picture_url': picture_url,
'attachments': attachments
'attachments': list(serializable(attachments)),
}),
headers={'content-type': 'application/json'}
)
Expand Down

0 comments on commit b469024

Please sign in to comment.