|
|
|
@ -204,6 +204,36 @@ class TimeBot: |
|
|
|
|
request.raise_for_status() |
|
|
|
|
return request.json()["data"] |
|
|
|
|
|
|
|
|
|
def get_tracking_data(self) -> dict: |
|
|
|
|
""" |
|
|
|
|
Get the current tracking state. |
|
|
|
|
|
|
|
|
|
This contains: |
|
|
|
|
|
|
|
|
|
* current presence state |
|
|
|
|
* last booking |
|
|
|
|
* last booking date |
|
|
|
|
* available quick actions |
|
|
|
|
|
|
|
|
|
:return: dict of the info mentioned above |
|
|
|
|
""" |
|
|
|
|
request = self.session.get(self.baseurl + "Tracking/GetTrackingData") |
|
|
|
|
request.raise_for_status() |
|
|
|
|
return request.json() |
|
|
|
|
|
|
|
|
|
def get_account_information(self) -> list: |
|
|
|
|
""" |
|
|
|
|
Get the current account information. |
|
|
|
|
|
|
|
|
|
* remaining vacation days |
|
|
|
|
* time account balance |
|
|
|
|
|
|
|
|
|
:return: list with mentioned infos |
|
|
|
|
""" |
|
|
|
|
request = self.session.get(self.baseurl + "Employee/GetAccountInformation") |
|
|
|
|
request.raise_for_status() |
|
|
|
|
return request.json() |
|
|
|
|
|
|
|
|
|
def punch_in(self, punch_datetime: datetime.datetime): |
|
|
|
|
""" |
|
|
|
|
:param datetime.datetime punch_datetime: datetime object |
|
|
|
@ -242,15 +272,8 @@ if __name__ == '__main__': |
|
|
|
|
parser.add_argument("--save-cookies", help="save auth cookies to `./.kekse`", action="store_true", default=False) |
|
|
|
|
subparsers = parser.add_subparsers(help='sub-command help', dest='subparser_name') |
|
|
|
|
|
|
|
|
|
# subparser command: `punch` |
|
|
|
|
parser_punch = subparsers.add_parser("punch", |
|
|
|
|
help="use this command to punch in, punch out, or create break entries") |
|
|
|
|
parser_punch.add_argument("-t", |
|
|
|
|
help=f"type of time entry; this can be {', '.join(PUNCH_COMMANDS)}", |
|
|
|
|
default="punch_in", |
|
|
|
|
choices=PUNCH_COMMANDS) |
|
|
|
|
parser_punch.add_argument("-s", help=f"timestamp in format `{SIMPLE_DATETIME_FORMAT_HUMAN}` or `now`", |
|
|
|
|
default="now") |
|
|
|
|
# subparser command: `status` |
|
|
|
|
parser_status = subparsers.add_parser("status", help="show your current tracking status") |
|
|
|
|
|
|
|
|
|
# subparser command: `list-entries` |
|
|
|
|
parser_list_entries = subparsers.add_parser("list-entries", help="use this command to list your time entries") |
|
|
|
@ -262,6 +285,16 @@ if __name__ == '__main__': |
|
|
|
|
f"(default: now; unset for default)") |
|
|
|
|
parser_list_entries.add_argument("--items", help="max items to request per page", default=20, type=int) |
|
|
|
|
|
|
|
|
|
# subparser command: `punch` |
|
|
|
|
parser_punch = subparsers.add_parser("punch", |
|
|
|
|
help="use this command to punch in, punch out, or create break entries") |
|
|
|
|
parser_punch.add_argument("-t", |
|
|
|
|
help=f"type of time entry; this can be {', '.join(PUNCH_COMMANDS)}", |
|
|
|
|
default="punch_in", |
|
|
|
|
choices=PUNCH_COMMANDS) |
|
|
|
|
parser_punch.add_argument("-s", help=f"timestamp in format `{SIMPLE_DATETIME_FORMAT_HUMAN}` or `now`", |
|
|
|
|
default="now") |
|
|
|
|
|
|
|
|
|
# subparser command: `smart-punch` |
|
|
|
|
parser_smart_punch = subparsers.add_parser("smart-punch", |
|
|
|
|
help="use this command to auto punch in, punch out and create break " |
|
|
|
@ -331,6 +364,16 @@ if __name__ == '__main__': |
|
|
|
|
data.reverse() |
|
|
|
|
for i in data: |
|
|
|
|
print("Entry: {} - DateTime: {} - Note: {}".format(i["entryName"], i["dateTime"], i["note"])) |
|
|
|
|
elif args.subparser_name == "status": |
|
|
|
|
tracking_data = tb.get_tracking_data() |
|
|
|
|
account_info = tb.get_account_information() |
|
|
|
|
print("Tracking Info:") |
|
|
|
|
print(f" Current State: {tracking_data['actualState']}") |
|
|
|
|
print(f" Last Booking: {tracking_data['lastBooking']}") |
|
|
|
|
print(f" Last Booking Date: {tracking_data['lastBookingDate']}") |
|
|
|
|
print("Account Infos:") |
|
|
|
|
for i in account_info: |
|
|
|
|
print(f" {i['accountName']}: {i['value']}") |
|
|
|
|
else: |
|
|
|
|
logger.error("Noting done... dunno what you want!") |
|
|
|
|
sys.exit(1) |
|
|
|
|