"""   To Parse the JSON generated by driver   """

import json
from enum import Enum


class Parser:

    # Method to parse JSON string.
    @staticmethod
    def parse(raw_data: str):
        raw_data = json.loads(raw_data)
        data = ParsedData()
        data.request_type = list(raw_data.keys())[0]
        data.meta_data = raw_data[list(raw_data.keys())[0]]["meta"]
        data.user_data = raw_data[list(raw_data.keys())[0]]["data"]
        return data


class ParsedData:

    def __init__(self):
        self.request_type: RequestType
        self.meta_data: dict = {}
        self.user_data: dict = {}

    def __str__(self):
        return str(self.request_type) + str(self.meta_data) + str(self.user_data)


class RequestType(Enum):
    Read = 1
    Insert = 2
    Delete = 3
    Update = 4
