diff --git a/weclapp/api.py b/weclapp/api.py index dbba5ec..98c6ccf 100644 --- a/weclapp/api.py +++ b/weclapp/api.py @@ -97,8 +97,8 @@ def call(self, command, method, query = {}, body = None, expected_status_code = kwargs = {} if len(cts) > 1 and cts[1].startswith('charset'): enc = cts[1].split("=") - if len(enc) > 1: - kwargs['encoding'] = enc[1] + #if len(enc) > 1: + # kwargs['encoding'] = enc[1] try: data = json.loads(data, **kwargs) diff --git a/weclapp/models/base.py b/weclapp/models/base.py index faf616e..5a50a14 100644 --- a/weclapp/models/base.py +++ b/weclapp/models/base.py @@ -59,7 +59,7 @@ def __repr__(self): @classmethod - def load(cls, sort=None, pageSize=100, serializeNulls=True): + def load(cls, sort=None, pageSize=-1, serializeNulls=True): """ Fetches the data from the public API diff --git a/weclapp/models/project.py b/weclapp/models/project.py index b72c083..c15b1a0 100644 --- a/weclapp/models/project.py +++ b/weclapp/models/project.py @@ -49,7 +49,7 @@ def print(self, indent='', with_color=True, file=sys.stdout): print(msg.format(indent, self.projectNumber, self.name, self.id, billable)) @classmethod - def load(cls, tasks=True, time_records=100, **kwargs): + def load(cls, tasks=True, time_records=-1, **kwargs): """ Loads projects diff --git a/weclapp/models/timeRecord.py b/weclapp/models/timeRecord.py index 81c40d0..a7189dd 100644 --- a/weclapp/models/timeRecord.py +++ b/weclapp/models/timeRecord.py @@ -47,6 +47,12 @@ def dict_for_upload(self): for field in ['billable', 'projectId', 'projectTaskId', 'durationSeconds' ]: ret[field] = getattr(self, field) + # Necessary fix because variable is set to false somewhere + ret['billable'] = bool(True) + + # Necessary fix since weclapp needs this vaule to be != 0 or billable will be set to false + ret['billableDurationSeconds'] = ret['durationSeconds'] + ret['startDate'] = int(self.startDate.timestamp() * 1000) if isinstance(self.description, str) and self.description.strip() != '': @@ -90,6 +96,9 @@ def upload_to_weclapp(self): body = json.dumps(self.dict_for_upload()) + # Uncomment the following line if you want to see the plain request being sent + #print("DEBUG Request body: %s" % body) + try: res = self.__api__.call(self.__fetch_command__, 'POST', body=body, expected_status_code=201) except: