def get_activity(data): """Requests activity's data and creates an instance of the :class:`models.Activity`. :param id: ID of the requested activity. """ # create the person person_kwargs = Person.from_google(data["actor"]) publisher = Person(**person_kwargs) # create the activity activity_kwargs = Activity.from_google(data) return Activity(publisher=publisher, **activity_kwargs)
def get_activities(data): """Requests information about given persons's public activities and creates a list of :obj:`models.Activity`. :param id: ID of the person who's activities will be requested. """ activities = [] for item in data["items"]: # create the person person_kwargs = Person.from_google(item["actor"]) publisher = Person(**person_kwargs) # create the activity activity_kwargs = Activity.from_google(item) activity = Activity(publisher=publisher, **activity_kwargs) activities.append(activity) return activities