@staticmethod<EOL><INDENT>def convert(input, type):<DEDENT>
try:<EOL><INDENT>if not input:<EOL><INDENT>if type == Types.TYPE_STRING:<EOL><INDENT>return '<STR_LIT>'<EOL><DEDENT>else:<EOL><INDENT>return None<EOL><DEDENT><DEDENT>if type == Types.TYPE_STRING:<EOL><INDENT>if isinstance(input, datetime.date):<EOL><INDENT>return input.strftime('<STR_LIT>')<EOL><DEDENT>else:<EOL><INDENT>return input<EOL><DEDENT><DEDENT>if type == Types.TYPE_FLOAT:<EOL><INDENT>return float(input)<EOL><DEDENT>elif type == Types.TYPE_INT:<EOL><INDENT>return int(input)<EOL><DEDENT>elif type == Types.TYPE_DATE:<EOL><INDENT>if isinstance(input, datetime.date):<EOL><INDENT>return input<EOL><DEDENT>else:<EOL><INDENT>return datetime.datetime.strptime(input[<NUM_LIT:0>:<NUM_LIT:10>], '<STR_LIT>')<EOL><DEDENT><DEDENT>elif type == Types.TYPE_DATETIME:<EOL><INDENT>if isinstance(input, datetime.datetime):<EOL><INDENT>return input<EOL><DEDENT>else:<EOL><INDENT>return datetime.datetime.strptime(input[<NUM_LIT:0>:<NUM_LIT>], '<STR_LIT>') <EOL><DEDENT><DEDENT>else:<EOL><INDENT>return NotImplementedError('<STR_LIT>'.format(type))<EOL><DEDENT><DEDENT>except Exception as e:<EOL><INDENT>logging.error(e, exc_info=True)<EOL>raise Exception(e)<EOL><DEDENT>
Converts input value to request type
:param input: input value
:param type: type to cast
:return: converted value