def getPeopleForProject(self, project_id, company_id): """Get people on project REST: GET /projects/#{project_id}/contacts/people/#{company_id} This will return all of the people in the given company that can access the given project. Response: <people> <person> ... </person> <person> ... </person> ... </people> """ # ensure that we got numerical company and project ids assert isinstance(project_id, int) assert isinstance(company_id, int) path = '/projects/%d/contacts/people/%d' % (project_id, company_id) response = self.get(path) if response.status == 404: raise NotFoundError, 'Project [%d] or Company [%d] is not found!' % ( project_id, company_id) rootElement = self.fromXML(response.contents) # TODO: use special Array attribute people = [] for data in rootElement.getElementsByTagName('person'): people.append(Person.load(data)) return people
def getPeopleForProject(self, project_id, company_id): """Get people on project REST: GET /projects/#{project_id}/contacts/people/#{company_id} This will return all of the people in the given company that can access the given project. Response: <people> <person> ... </person> <person> ... </person> ... </people> """ # ensure that we got numerical company and project ids assert isinstance(project_id, int) assert isinstance(company_id, int) path = '/projects/%d/contacts/people/%d' % (project_id, company_id) response = self.get(path) if response.status == 404: raise NotFoundError, 'Project [%d] or Company [%d] is not found!' % (project_id, company_id) rootElement = self.fromXML(response.contents) # TODO: use special Array attribute people = [] for data in rootElement.getElementsByTagName('person'): people.append(Person.load(data)) return people
def getCurrentPerson(self): """Returns the currently logged in person (you) REST: GET /me.xml Response: <person> <id type="integer">#{id}</id> <user-name>#{user_name}</user-name> ... </person> """ path = '/me.xml' response = self.get(path) if response.status != 200: return self.getErrors(response.contents) data = self.fromXML(response.contents) return Person.load(data)
def getPersonById(self, person_id): """Get person (by id) REST: GET /contacts/person/#{person_id} This will return information about the referenced person. Response: <person> ... </person> """ # ensure that we got numerical person id assert isinstance(person_id, int) path = '/contacts/person/%d' % person_id response = self.get(path) if response.status == 404: raise NotFoundError, 'Person with %d id is not found!' % person_id rootElement = self.fromXML(response.contents) return Person.load(rootElement)
def getPeopleForCompany(self, company_id, project_id=None): """Get people (for company) REST: GET /contacts/people/#{company_id} This will return all of the people in the given company. If a project id is given, it will be used to filter the set of people that are returned to include only those that can access the given project. Response: <people> <person> ... </person> <person> ... </person> ... </people> """ # ensure that we got numerical company id assert isinstance(company_id, int) path = '/contacts/people/%d' % company_id if project_id is not None: assert isinstance(project_id, int) path = '%s?project_id=%d' % (path, project_id) response = self.get(path) if response.status == 404: raise NotFoundError, 'Company [%d] or Project [%d] is not found!' % ( company_id, project_id) rootElement = self.fromXML(response.contents) # TODO: use special Array attribute people = [] for data in rootElement.getElementsByTagName('person'): people.append(Person.load(data)) return people
def getPeopleForCompany(self, company_id, project_id=None): """Get people (for company) REST: GET /contacts/people/#{company_id} This will return all of the people in the given company. If a project id is given, it will be used to filter the set of people that are returned to include only those that can access the given project. Response: <people> <person> ... </person> <person> ... </person> ... </people> """ # ensure that we got numerical company id assert isinstance(company_id, int) path = '/contacts/people/%d' % company_id if project_id is not None: assert isinstance(project_id, int) path = '%s?project_id=%d' % (path, project_id) response = self.get(path) if response.status == 404: raise NotFoundError, 'Company [%d] or Project [%d] is not found!' % (company_id, project_id) rootElement = self.fromXML(response.contents) # TODO: use special Array attribute people = [] for data in rootElement.getElementsByTagName('person'): people.append(Person.load(data)) return people