python-telegram-bot/telegram/location.py

26 lines
588 B
Python
Raw Normal View History

#!/usr/bin/env python
2015-07-09 16:40:44 +02:00
import json
class Location(object):
2015-07-09 02:58:13 +02:00
def __init__(self,
longitude,
latitude):
self.longitude = longitude
self.latitude = latitude
@staticmethod
def de_json(data):
return Location(longitude=data.get('longitude', None),
latitude=data.get('latitude', None))
2015-07-09 16:40:44 +02:00
def to_json(self):
json_data = {'longitude': self.longitude,
'latitude': self.latitude}
return json.dumps(json_data)
def __str__(self):
return self.to_json()