Esempio n. 1
0
    def create(self, partner_name):

        settings = Loader.get_partner_settings(partner_name)

        partner_name = self._get_partner_name(partner_name)

        adapters_path = 'src.adapters.%s.adapter' % partner_name
        adapters_module =  __import__(adapters_path, globals(), locals(), ['Adapter'])

        builder = self._factory.create(partner_name, 'response')
        return adapters_module.Adapter(settings, builder)
Esempio n. 2
0
    def create(self, partner_name, action):

        if action not in self.availables_actions:
            raise ValueError("Invalid Argument")

        partner_settings = Loader.get_partner_settings(partner_name)
        partner_name = self._get_partner_name(partner_name)
        builders_path = "src.builders.%s.%s" % (partner_name, action)

        if action == "activate":
            module = __import__(builders_path, globals(), locals(), ["ActivateBuilder"])
            return module.ActivateBuilder()

        if action == "cancel":
            module = __import__(builders_path, globals(), locals(), ["CancelBuilder"])
            return module.CancelBuilder()

        if action == "response":
            module = __import__(builders_path, globals(), locals(), ["ResponseBuilder"])
            return module.ResponseBuilder()

        raise ValueError("Invalid Argument. Action <%s> unknow" % action)