#!/usr/bin/env python3
# -*- coding: utf-8 -*-

'''REST API test for Fulvio'''

# Third-party modules
from flask_restx import Namespace, Resource

# import devices

############################
# REST API
############################

api = Namespace('fulvio', description='Fulvio test')

@api.route("/test")
class TestApi(Resource):
    """First get/post test of Fulvio."""

    def get(self):
        """GET fulvio test."""
        res = {
            "response": "get ciao",
            "error": "",
        }
        return res

    def post(self):
        """POST fulvio test."""
        target = api.payload

        if target != "bbb":
            err = "Non va bene, scrivi bbb"
        else:
            err = "nessun errore"

        res = {
            "response": target,
            "error": err,
        }
        return res
