Example #1
0
 def __init__(self, *args, **kwargs):
     super(CustomScreen, self).__init__(*args, **kwargs)
     self.custom_screen_instance = str_to_class(
         self.screen_content['screen_obj'])(
             self.ussd_request,
             self.handler,
             self.screen_content,
             initial_screen={},
         )
Example #2
0
 def validate_screen_obj(value):
     try:
         screen_obj = str_to_class(value)
     except Exception as e:
         raise serializers.ValidationError(str(e))
     else:
         if not isinstance(screen_obj, UssdHandlerMetaClass):
             raise serializers.ValidationError(
                 "Screen object should be of type UssdHandlerAbstract")
         return screen_obj
 def __init__(self, *args, **kwargs):
     super(CustomScreen, self).__init__(*args, **kwargs)
     self.custom_screen_instance = str_to_class(
         self.screen_content['screen_obj']
     )(
         self.ussd_request,
         self.handler,
         self.screen_content,
         initial_screen={},
     )
Example #4
0
    def handle(self):
        # Todo initiate the class in the core. to avoid double changing
        # if the parameter changes.

        # calling the custom screen handler method
        return str_to_class(self.screen_content['screen_obj'])(
            self.ussd_request,
            self.handler,
            self.screen_content,
            initial_screen={},
        ).handle()
 def validate_screen_obj(value):
     try:
         screen_obj = str_to_class(value)
     except Exception as e:
         raise serializers.ValidationError(str(e))
     else:
         if not isinstance(screen_obj, UssdHandlerMetaClass):
             raise serializers.ValidationError(
                 "Screen object should be of type UssdHandlerAbstract"
             )
         return screen_obj
Example #6
0
 def _deserialize(self, value: typing.Any, attr: typing.Optional[str],
                  data: typing.Optional[typing.Mapping[str, typing.Any]],
                  **kwargs):
     try:
         screen_obj = str_to_class(value)
     except Exception as e:
         raise ValidationError(str(e))
     else:
         if not isinstance(screen_obj, UssdHandlerMetaClass):
             raise ValidationError(
                 "Screen object should be of type UssdHandlerAbstract")
         return screen_obj