def get_person(data): """Requests user's data and creates an instance of the :class:`models.Person`. :param id: ID of the requested user. Posible value is ``'me'``, which requests the user that is currently logged in. """ # create the person kwargs = Person.from_google(data) return Person(**kwargs)
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_people(data): """Requests information about given persons's friends and creates a list :obj:`models.Person`. :param id: ID of the person who's friends will be requested. """ people = [] for item in data["items"]: # create the person kwargs = Person.from_google(item) person = Person(**kwargs) people.append(person) return people
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