Skip to content

Commit

Permalink
Merge pull request #77 from cedarville-university/develop
Browse files Browse the repository at this point in the history
Summer 2024 Release PR
  • Loading branch information
nattyboyme3 authored Jun 25, 2024
2 parents 2a5caf0 + 74ffaad commit f50e286
Show file tree
Hide file tree
Showing 5 changed files with 137 additions and 4 deletions.
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
setup(
name='TDXLib',
description='a python library for interacting with the TeamDynamix Web API',
version='0.5.2',
version='0.5.3',
author='Nat Biggs, Stephen Gaines, Josiah Lansford',
author_email='tdxlib@cedarville.edu',
packages=['tdxlib'],
Expand Down
5 changes: 4 additions & 1 deletion tdxlib/__init__.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
__all__ = [
"tdx_ticket_integration",
"tdx_report_integration",
"tdx_asset_integration",
"tdx_api_exceptions",
"tdx_utils",
Expand All @@ -14,7 +15,9 @@
import tdxlib.tdx_asset_integration
import tdxlib.tdx_ticket_integration
import tdxlib.tdx_ticket
import tdxlib.tdx_report_integration
import tdxlib.tdx_report
import tdxlib.tdx_utils


__version__ = "0.5.2"
__version__ = "0.5.3"
4 changes: 2 additions & 2 deletions tdxlib/tdx_constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@
'caching': False,
'timezone': '-0500',
'log_level': 'ERROR',
# 'full_host': ''

# 'full_host': '',
'filename': 'tdxlib.ini'
}

config_keys = {
Expand Down
92 changes: 92 additions & 0 deletions tdxlib/tdx_report.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
import json
from typing import Optional
from enum import Enum
import tdxlib.tdx_api_exceptions
import tdxlib.tdx_utils
import datetime
from typing_extensions import TypedDict
import json
from typing import TYPE_CHECKING

if TYPE_CHECKING:
import tdxlib.tdx_report_integration

class OrderByColumn(TypedDict):
ColumnLabel: str
ColumnName: str
IsAscending: bool
class ChartSetting(TypedDict):
Axis: Optional[str]
ColumnLabel: Optional[str]
ColumnName: Optional[str]
class ColumnDataType(Enum):
GenericData = 0
String = 1
Integer = 2
Decimal = 3
Currency = 4
Percentage = 5
Date = 6
DateAndTime = 7
Boolean = 8
TimeSpan = 9
ProjectHealth = 10
Html = 11
class AggregateFunction(Enum):
NONE = 0
Average = 1
Count = 2
Maximum = 3
Minimum = 4
Sum = 5
class ComponentFunction(Enum):
NONE = 0
Year = 1
MonthYear = 2
WeekYear = 3
Hour = 4
HourWeek = 5
HourMonth = 6
class DisplayColumn(TypedDict):
HeaderText: str
ColumnName: str
DataType: ColumnDataType
SortColumnExpression: Optional[str]
SortColumnName: Optional[str]
SortDataType: ColumnDataType
Aggregate: AggregateFunction
Component: ComponentFunction
FooterExpression: Optional[str]
class TDXReportData(TypedDict):
Description: Optional[str]
MaxResults: int
DisplayedColumns: Optional[list[DisplayColumn]]
SortOrder: Optional[list[OrderByColumn]]
ChartType: Optional[str]
ChartSettings: Optional[list[ChartSetting]]
DataRows: Optional[list[dict[str, object]]]
ID: int
Name: str
CreatedUid: Optional[str]
CreatedFullName: str
CreatedDate: datetime.datetime
OwningGroupID: Optional[int]
OwningGroupName: str
SystemAppName: str
PlatformAppID: int
PlatformAppName: Optional[str]
ReportSourceID: int
ReportSourceName: str
Uri: str
class TDXReport(TypedDict):
report_data: TDXReportData
tdx_api: 'tdxlib.tdx_report_integration.TDXReportIntegration'
def __repr__(self):
return str(self.report_data.__dict__)

def __str__(self):
return json.dumps(self)

def __init__(self, integration: 'tdxlib.tdx_report_integration.TDXReportIntegration', json: str):
self.tdx_api = integration
self.report_data = json.loads(json)
38 changes: 38 additions & 0 deletions tdxlib/tdx_report_integration.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
import tdxlib.tdx_report
import copy
import datetime
from tdxlib.tdx_integration import TDXIntegration
import tdxlib.tdx_api_exceptions
from typing import Union
from typing import BinaryIO
import json

class TDXReportIntegration(TDXIntegration):
def __init__(self, filename: str = None, config=None):
tdxlib.tdx_integration.TDXIntegration.__init__(self, filename, config)
self.clean_cache()
def make_report_call(self, url: str, action: str, post_body: dict = None):
url_string = '/reports'
if len(url) > 0:
url_string += '/' + url
if action == 'get':
return self.make_get(url_string)
if action == 'delete':
return self.make_delete(url_string)
if action == 'post' and post_body:
return self.make_post(url_string, post_body)
if action == 'put' and post_body:
return self.make_put(url_string, post_body)
if action == 'patch' and post_body:
return self.make_patch(url_string, post_body)
raise tdxlib.tdx_api_exceptions.TdxApiHTTPRequestError('No method ' + action + ' or no post information')
def get_report_by_id(self, id: int, withData: bool = False, dataSortExpression: str = "") -> tdxlib.tdx_report.TDXReport:
url_string = f"{id}?withData={withData}&dataSortExpression={dataSortExpression}"
report_data = self.make_report_call(url_string, 'get')
if report_data:
#return tdxlib.tdx_report.TDXReport.__init__(integration=self, json=report_data)
result: tdxlib.tdx_report.TDXReport = {
'report_data': report_data,
'tdx_api': self
}
return result

0 comments on commit f50e286

Please sign in to comment.