"README.rst" did not exist on "38c9338c4672906b9522231fb5f48d927e85ada1"
notify.py 890 Bytes
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28
from flask_restful import Resource, reqparse, abort, fields, marshal_with
import json


class Notify(Resource):
    def setup_request_parser(self):
        parser = reqparse.RequestParser()
        parser.add_argument(
            "client_id", type=str, help="A unique name to identify the client"
        )
        parser.add_argument(
            "secret", type=str, help="A human friendly name to identify the client"
        )
        parser.add_argument("content", type=str, help="The message")
        self.parser = parser

    def parse(self):
        return self.parser.parse_args()

    def put(self, client_id):
        args = clients_file.parse()

        client = clients_file.find(client_id)
        if not client:
            abort(404, message="No client with id: {}".format(client_id))
        else:
            client = clients_file.update(args)
        return client, 201