init commit
This commit is contained in:
@@ -1,25 +1,45 @@
|
||||
import logging
|
||||
|
||||
import connexion
|
||||
from typing import Dict
|
||||
from typing import Tuple
|
||||
from typing import Union
|
||||
|
||||
from bson import json_util
|
||||
from flask import Response
|
||||
from pymongo import MongoClient
|
||||
|
||||
from openapi_server.__main__ import collection
|
||||
from openapi_server.models.patch_notes import PatchNotes # noqa: E501
|
||||
from openapi_server import util
|
||||
|
||||
|
||||
def get_patchnotes(): # noqa: E501
|
||||
"""get_patchnotes
|
||||
|
||||
def patchnotes_date_get(date): # noqa: E501
|
||||
"""patchnotes_date_get
|
||||
|
||||
returns list of all unseen Patch notes from the user # noqa: E501
|
||||
|
||||
:param date:
|
||||
:type date: str
|
||||
|
||||
:rtype: Union[List[PatchNotes], Tuple[List[PatchNotes], int], Tuple[List[PatchNotes], int, Dict[str, str]]
|
||||
"""
|
||||
return 'do some magic!'
|
||||
# TODO Implement this:
|
||||
|
||||
# try:
|
||||
# formatted_date = response_data.strftime('%Y-%m-%d')
|
||||
# logging.error(formatted_date)
|
||||
# logging.info("valid date")
|
||||
# except ValueError:
|
||||
# logging.error("Not valid date")
|
||||
return date
|
||||
# _date = util.deserialize_date(date)
|
||||
# return 'do some magic!'
|
||||
|
||||
|
||||
def patch_note_delete(patch_id): # noqa: E501
|
||||
"""patch_note_delete
|
||||
def patchnotes_patch_iddelete(patch_id): # noqa: E501
|
||||
"""patchnotes_patch_iddelete
|
||||
|
||||
deletes one Patch note # noqa: E501
|
||||
|
||||
@@ -32,8 +52,8 @@ def patch_note_delete(patch_id): # noqa: E501
|
||||
return 'do some magic!'
|
||||
|
||||
|
||||
def post_patchnotes(body=None): # noqa: E501
|
||||
"""post_patchnotes
|
||||
def patchnotes_post(body=None): # TODO done for now
|
||||
"""patchnotes_post
|
||||
|
||||
creates new Patch notes # noqa: E501
|
||||
|
||||
@@ -43,9 +63,11 @@ def post_patchnotes(body=None): # noqa: E501
|
||||
:rtype: Union[List[PatchNotes], Tuple[List[PatchNotes], int], Tuple[List[PatchNotes], int, Dict[str, str]]
|
||||
"""
|
||||
patch_notes = body
|
||||
with conn.cursor() as cur:
|
||||
player_name = player_post_request.name
|
||||
player_id = uuid.uuid4()
|
||||
cur.execute(f"INSERT INTO player VALUES ('{player_id}','{player_name}');")
|
||||
conn.commit() # noqa: E501
|
||||
return 'do some magic!'
|
||||
logging.error('patch notes' + str(patch_notes))
|
||||
if patch_notes is None:
|
||||
return Response(json_util.dumps({'error': 'No patch notes provided'}), status=400)
|
||||
# Insert the document into the MongoDB collection
|
||||
posted_patch_id = collection.insert_one(patch_notes)
|
||||
|
||||
return Response(json_util.dumps(f'patch with ID: {posted_patch_id} was created'), mimetype='application/json',
|
||||
status=200)
|
||||
Reference in New Issue
Block a user