projectal.entities.company API documentation

# projectal.entities.company

View Source

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

class Company(projectal.entity.Entity, projectal.linkers.LocationLinker, projectal.linkers.StaffLinker, projectal.linkers.CompanyLinker, projectal.linkers.DepartmentLinker, projectal.linkers.ProjectLinker, projectal.linkers.FileLinker, projectal.linkers.ContactLinker, projectal.linkers.NoteLinker, projectal.linkers.TagLinker): View Source

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

Implementation of the Company API.

@classmethod
def tree(cls, uuId=None, level=False, include_department=False): View Source

    19    @classmethod
    20    def tree(cls, uuId=None, level=False, include_department=False):
    21        """
    22        Return company list in organisation chart format.
    23
    24        `uuId`: Of a company. If no company is requested, the full
    25        organizational chart is returned (default: `None`)
    26
    27        `level`: If `True`, only returns the top level of the
    28        hierarchy (default: `False`).
    29
    30        `include_department`: If `True`, lists all departments within
    31        each company and their sub-companies (default: `False`).
    32
    33        """
    34        url = '/api/company/tree?'
    35        params = []
    36        params.append('uuId={}'.format(uuId)) if uuId else None
    37        params.append('level=true') if level else None
    38        params.append('includeDepartment=true') if include_department else None
    39        url += '&'.join(params)
    40
    41        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): View Source

    44    @classmethod
    45    def get_primary_company(cls, links=None):
    46        """Return the Primary company"""
    47        payload = {
    48            "name": "Find primary company uuId",
    49            "type": "msql", "start": 0, "limit": 1,
    50            "select": [
    51                ["COMPANY.uuId"]
    52            ],
    53            "filter": [["COMPANY.type", 'eq', CompanyType.Primary]]
    54        }
    55        response = api.query(payload)
    56        uuId = response[0][0]
    57        return cls.get(uuId, links)

Return the Primary company

##### Inherited Members

projectal.entity.Entity
  get
  update
  delete
  history
  create
  save
  clone
  list
  match
  match_startswith
  match_endswith
  match_one
  match_startswith_one
  match_endswith_one
  search
  query
  profile_get
  profile_set
  changes
  set_readonly
  get_link_definitions
  entity_name
projectal.linkers.LocationLinker
  link_location
  unlink_location
projectal.linkers.StaffLinker
  link_staff
  relink_staff
  unlink_staff
projectal.linkers.CompanyLinker
  link_company
  unlink_company
projectal.linkers.DepartmentLinker
  link_department
  unlink_department
projectal.linkers.ProjectLinker
  link_project
  unlink_project
projectal.linkers.FileLinker
  link_file
  unlink_file
projectal.linkers.ContactLinker
  link_contact
  unlink_contact
projectal.linkers.TagLinker
  link_tag
  unlink_tag
builtins.dict
  setdefault
  pop
  popitem
  keys
  items
  values
  fromkeys
  clear
  copy