def get(self): ''' HTTP GET Method Handler Returns a JSON list of objects with keys 'name' and 'id' Parameters: - int business: the ID of the business that created the coupon - int user: the ID of the user whose coupons you want to check - int active: 0 if you want non-active coupons ''' params = self.load_http_params({ 'business': (int, False), 'user': (int, False), 'year': (int, False), 'month': (int, False), 'day': (int, False), 'hour': (int, False), 'min': (int, False) }, use_default=True) try: time = datetime.datetime( params['year'], params['month'], params['day'], params['hour'], params['minute'] ) except KeyError: time = None coupon_keys = Coupon.list_coupons( user_id=params['user'], business_id=params['business'], time=time, keys_only=True ) self.status = '200 OK' flag = False for key in coupon_keys: if flag: self.response.write('\n') else: flag = True self.response.write(str(key.id()) + '\n')