projectal.entities.company

 1from projectal.entity import Entity
 2from projectal.enums import CompanyType
 3from projectal.linkers import *
 4from projectal import api
 5
 6
 7class Company(
 8    Entity,
 9    LocationLinker,
10    StaffLinker,
11    CompanyLinker,
12    DepartmentLinker,
13    ProjectLinker,
14    FileLinker,
15    ContactLinker,
16    NoteLinker,
17    TagLinker,
18):
19    """
20    Implementation of the [Company](https://projectal.com/docs/latest/#tag/Company) API.
21    """
22
23    _path = "company"
24    _name = "company"
25
26    _links = [
27        LocationLinker,
28        StaffLinker,
29        CompanyLinker,
30        DepartmentLinker,
31        ProjectLinker,
32        FileLinker,
33        ContactLinker,
34        NoteLinker,
35        TagLinker,
36    ]
37
38    @classmethod
39    def tree(cls, uuId=None, level=False, include_department=False):
40        """
41        Return company list in organisation chart format.
42
43        `uuId`: Of a company. If no company is requested, the full
44        organizational chart is returned (default: `None`)
45
46        `level`: If `True`, only returns the top level of the
47        hierarchy (default: `False`).
48
49        `include_department`: If `True`, lists all departments within
50        each company and their sub-companies (default: `False`).
51
52        """
53        url = "/api/company/tree?"
54        params = []
55        params.append("uuId={}".format(uuId)) if uuId else None
56        params.append("level=true") if level else None
57        params.append("includeDepartment=true") if include_department else None
58        url += "&".join(params)
59
60        return api.get(url)
61
62    @classmethod
63    def get_primary_company(cls, links=None):
64        """Return the Primary company"""
65        payload = {
66            "name": "Find primary company uuId",
67            "type": "msql",
68            "start": 0,
69            "limit": 1,
70            "select": [["COMPANY.uuId"]],
71            "filter": [["COMPANY.type", "eq", CompanyType.Primary]],
72        }
73        response = api.query(payload)
74        uuId = response[0][0]
75        return cls.get(uuId, links)
 8class Company(
 9    Entity,
10    LocationLinker,
11    StaffLinker,
12    CompanyLinker,
13    DepartmentLinker,
14    ProjectLinker,
15    FileLinker,
16    ContactLinker,
17    NoteLinker,
18    TagLinker,
19):
20    """
21    Implementation of the [Company](https://projectal.com/docs/latest/#tag/Company) API.
22    """
23
24    _path = "company"
25    _name = "company"
26
27    _links = [
28        LocationLinker,
29        StaffLinker,
30        CompanyLinker,
31        DepartmentLinker,
32        ProjectLinker,
33        FileLinker,
34        ContactLinker,
35        NoteLinker,
36        TagLinker,
37    ]
38
39    @classmethod
40    def tree(cls, uuId=None, level=False, include_department=False):
41        """
42        Return company list in organisation chart format.
43
44        `uuId`: Of a company. If no company is requested, the full
45        organizational chart is returned (default: `None`)
46
47        `level`: If `True`, only returns the top level of the
48        hierarchy (default: `False`).
49
50        `include_department`: If `True`, lists all departments within
51        each company and their sub-companies (default: `False`).
52
53        """
54        url = "/api/company/tree?"
55        params = []
56        params.append("uuId={}".format(uuId)) if uuId else None
57        params.append("level=true") if level else None
58        params.append("includeDepartment=true") if include_department else None
59        url += "&".join(params)
60
61        return api.get(url)
62
63    @classmethod
64    def get_primary_company(cls, links=None):
65        """Return the Primary company"""
66        payload = {
67            "name": "Find primary company uuId",
68            "type": "msql",
69            "start": 0,
70            "limit": 1,
71            "select": [["COMPANY.uuId"]],
72            "filter": [["COMPANY.type", "eq", CompanyType.Primary]],
73        }
74        response = api.query(payload)
75        uuId = response[0][0]
76        return cls.get(uuId, links)

Implementation of the Company API.

@classmethod
def tree(cls, uuId=None, level=False, include_department=False):
39    @classmethod
40    def tree(cls, uuId=None, level=False, include_department=False):
41        """
42        Return company list in organisation chart format.
43
44        `uuId`: Of a company. If no company is requested, the full
45        organizational chart is returned (default: `None`)
46
47        `level`: If `True`, only returns the top level of the
48        hierarchy (default: `False`).
49
50        `include_department`: If `True`, lists all departments within
51        each company and their sub-companies (default: `False`).
52
53        """
54        url = "/api/company/tree?"
55        params = []
56        params.append("uuId={}".format(uuId)) if uuId else None
57        params.append("level=true") if level else None
58        params.append("includeDepartment=true") if include_department else None
59        url += "&".join(params)
60
61        return api.get(url)

Return company list in organisation chart format.

uuId: Of a company. If no company is requested, the full organizational chart is returned (default: None)

level: If True, only returns the top level of the hierarchy (default: False).

include_department: If True, lists all departments within each company and their sub-companies (default: False).

@classmethod
def get_primary_company(cls, links=None):
63    @classmethod
64    def get_primary_company(cls, links=None):
65        """Return the Primary company"""
66        payload = {
67            "name": "Find primary company uuId",
68            "type": "msql",
69            "start": 0,
70            "limit": 1,
71            "select": [["COMPANY.uuId"]],
72            "filter": [["COMPANY.type", "eq", CompanyType.Primary]],
73        }
74        response = api.query(payload)
75        uuId = response[0][0]
76        return cls.get(uuId, links)

Return the Primary company