def update_ticket(ticket_id): """Update a specific ticket.""" ticket_data = request.get_json() user_by_id = None response = None # get ticket by id ticket_by_id = TicketController.get_ticket_by_id(ticket_id) # check if there is assignee key provided in request if "ticket_assignee" in ticket_data: user_by_id = UserController.get_users_by_id( ticket_data["ticket_assignee"]) if user_by_id is None: return (error_response(404, "Resource Not Found") ) # return not found response if wrong user provided # check if ticket was found and update accordingly if ticket_by_id: TicketController.update_ticket(ticket_by_id, ticket_data, user_by_id) response = success_response_body(ticket_data) else: # return no user error response = error_response(404, "Resource Not Found") return response
def delete_ticket(ticket_id): """Delete a specific ticket.""" if TicketController.get_ticket_by_id(ticket_id): TicketController.delete_ticket(ticket_id) response = success_response_body({}) else: response = error_response(404, "Resource Not Found") return response
def get_single_ticket(ticket_id): """Get the details of a single ticket.""" tickets_array = TicketController.get_ticket_by_id(ticket_id) return jsonify(tickets_array.conv_ticket_to_dict())
def get_single_ticket(ticket_id): """Return a single ticket based on its ID.""" ticket = TicketController.get_ticket_by_id(ticket_id) return jsonify(ticket.ticket_to_dict())