예제 #1
0
 def __init__(self, workspace, node_id):
     """
     :param workspace: A Workspace Object for authenticating on Contacthub
     :param node_id: The id of the Contacthub node
     """
     self.workspace = workspace
     self.node_id = str(node_id)
     self.customer_api_manager = _CustomerAPIManager(node=self)
     self.event_api_manager = _EventAPIManager(node=self)
예제 #2
0
    def __init__(self, customer, parent_attr=None, properties_class=None, **attributes):
        """
        Initialize a new Job object for customer in a node with the specified attributes.

        :param customer: the customer associated to this Job object
        :param parent_attr: the parent attribute for compiling the mutation tracker dictionary
        :param attributes: key-value arguments for generating the structure of the Job's attributes
        :param properties_class: reference to the actual Properties class
        """
        self.customer = customer
        self.attributes = attributes
        self.customer_api_manager = _CustomerAPIManager(node=customer.node)
        self.entity_name = 'jobs'
        self.parent_attr = parent_attr
        self.properties_class = properties_class
예제 #3
0
    def all(self):
        """
        Get all queried data of an entity from the API

        :return: a ReadOnly list with all object queried
        """

        complete_query = {
            'name': 'query',
            'query': self.inner_query
        } if self.inner_query else None

        if self.entity is Customer:
            return PaginatedList(node=self.node,
                                 function=_CustomerAPIManager(
                                     self.node).get_all,
                                 entity_class=Customer,
                                 query=complete_query)
    def __init__(self, node, default_attributes=None, **attributes):
        """
        Initialize a customer in a node with the specified attributes.

        :param node: the node of the customer
        :param default_attributes: the attributes schema. By default is the following dictionary:
            {
            'base':
                    {
                    'contacts': {}
                    },
            'extended': {},
            'tags': {
                    'manual': [],
                    'auto': []
                    }
            }
        :param attributes: key-value arguments for generating the structure of Customer's attributes
        """

        convert_properties_obj_in_prop(properties=attributes,
                                       properties_class=Properties)
        if default_attributes is None:
            if 'base' not in attributes:
                attributes['base'] = {}

            if 'contacts' not in attributes['base']:
                attributes['base']['contacts'] = {}

            if 'extended' not in attributes or attributes['extended'] is None:
                attributes['extended'] = {}

            if 'tags' not in attributes or attributes['tags'] is None:
                attributes['tags'] = {'auto': [], 'manual': []}
            self.attributes = attributes
        else:
            default_attributes.update(attributes)
            self.attributes = default_attributes

        self.node = node
        self.customer_api_manager = _CustomerAPIManager(node=self.node)
        self.event_api_manager = _EventAPIManager(node=self.node)
        self.mute = {}