class TokenResource(Resource): method_decorators = [protected(AuthType.Simple, False)] def post(self): """Get bearer token via simple auth.""" payload = {'user': g.user, 'token': create_access_token(g.user.id)} return IkiruJsonResponse(payload, 'Access token created successfully.')
class ReturnsResource(Resource): method_decorators = [protected(AuthType.JWT, self_only=True)] post_parser = reqparse.RequestParser() post_parser.add_argument('rental_uuid', dest='rental_uuid', required=True) def post(self): # post_parser remains editable - service layer is responsible # for copying the parser before doing any live edits return services.rental.return_rental(self.post_parser)
class EvalResource(Resource): method_decorators = [protected(AuthType.JWT, False)] def post(self): """ Check token validity.""" jwt = get_raw_jwt() return IkiruJsonResponse({ 'user': g.user, 'date_expires': datetime.utcfromtimestamp(jwt['exp']) })
class UserRentalsResource(Resource): method_decorators = [protected(AuthType.JWT, self_only=True)] def get(self, user_uuid): return services.user.get_user_rentals(user_uuid)
class GenresResource(Resource): method_decorators = [protected(AuthType.JWT)] def get(self): return services.genre.get_genres()
class GenreMoviesResource(Resource): method_decorators = [protected(AuthType.JWT)] def get(self, genre_uuid): return services.genre.get_genre_movies(genre_uuid)
class MovieResource(Resource): method_decorators = [protected(AuthType.JWT)] def get(self, movie_uuid): return services.movie.get_movie_by_uuid(movie_uuid)
class ReturnResource(Resource): method_decorators = [protected(AuthType.JWT, self_only=True)] def get(self, rental_uuid): return services.rental.get_cost(rental_uuid)