Example #1
0
 def from_json(json):
     if json:
         item = YelpItem(
             id=json.get('id'),
             name=json.get('name'),
             image_url=json.get('image_url'),
             url=json.get('url'),
             phone=json.get('phone'),
             rating=json.get('rating'),
             review_count=json.get('review_count'),
             location=Location.from_json(json.get('location'))
         )
         return item
     return None
Example #2
0
 def from_json(json):
     item = Item(
         name=json.get('name'),
         yelp_category_id=json.get('yelp_category', {}).get('id'),
         yelp_category = YelpCategory.from_json(json.get('yelp_category')),
         plan_id=json.get('plan_id'),
         start_time=datetime.strptime(json.get('start_time'), "%Y-%m-%d %H:%M:%S %z") if json.get('start_time') is not None else None,
         end_time=datetime.strptime(json.get('end_time'), "%Y-%m-%d %H:%M:%S %z") if json.get('end_time') is not None else None,
         description=json.get("description"),
         type=json.get("type"),
         yelp_item_id=json.get('yelp_item', {}).get('id'),
         yelp_item=YelpItem.from_json(json.get('yelp_item')),
         location_id=json.get('location', {}).get('id'),
         location=Location.from_json(json.get('location'))
     )
     return item