Beispiel #1
0
    def list_contacts(self, **kwargs):
        """
        List all contacts, optionally filtered by a query. Specify filters as
        query keyword argument, such as: 
        
        query= email is [email protected],
        query= mobile is 1234567890,
        query= phone is 1234567890,

        contacts can be filtered by name such as;
        
        letter=Prenit

        Passing None means that no named filter will be passed to
        Freshdesk, which returns list of all contacts

        """

        url = 'contacts.json?'
        if 'query' in kwargs.keys():
            filter_query = kwargs.pop('query')
            url = url + "query={}".format(filter_query)

        if 'state' in kwargs.keys():
            state_query = kwargs.pop('state')
            url = url + "state={}".format(state_query)    

        if 'letter' in kwargs.keys():
            name_query = kwargs.pop('letter')
            url = url + "letter={}".format(name_query)        
                
        contacts = self._api._get(url)    
        return [Contact(**c['user']) for c in contacts]
Beispiel #2
0
    def create_contact(self, *args, **kwargs):
        """Creates a contact"""
        url = "contacts.json"
        contact_data = {"active": True, "helpdesk_agent": False, "description": "Freshdesk Contact"}
        contact_data.update(kwargs)
        payload = {"user": contact_data}

        return Contact(**self._api._post(url, data=payload)["user"])
Beispiel #3
0
    def create_contact(self, *args, **kwargs):
        """Creates a contact"""
        url = 'contacts.json'
        contact_data = {
            'active': True,
            'helpdesk_agent': False,
            'description': 'Freshdesk Contact'
        }
        contact_data.update(kwargs)
        payload = {
            'user': contact_data
        }

        return Contact(**self._api._post(url, data=payload)['user'])
Beispiel #4
0
 def get_contact(self, contact_id):
     url = 'contacts/%d.json' % contact_id
     return Contact(**self._api._get(url)['user'])
Beispiel #5
0
 def get_contact(self, contact_id):
     url = "contacts/%d.json" % contact_id
     return Contact(**self._api._get(url)["user"])