sniner / docuware-client

A Python client library for the REST API of DocuWare's DMS
BSD 3-Clause "New" or "Revised" License
7 stars 6 forks source link

Feat/add user group functions #2

Closed patrick-cichon-gcx closed 1 year ago

patrick-cichon-gcx commented 1 year ago

Hey @sniner,

in context of issue #1 I added the following functionality to the client library:

Get user user = org.get_user('Ingo.Ittmann') Get user list userList = org.get_user_list() Create user response = org.create_user(createDict) Info: An example for the structure of the createDict can be found in the functions description. Deactivate user response = org.deactivate_user("Ingo.Ittmann") Activate user response = org.activate_user('Ingo.Ittmann')

Get group group = org.get_group('Erfasser') Get group list groupList = org.get_group_list() Add group to user response = org.add_group_to_user('Sales', 'Ingo.Ittmann') Remove group from user response = org.remove_group_from_user('Sales', 'Ingo.Ittmann')

In order to achieve some of the above functionality it was necessary to create functions to execute PUT requests against the DocuWare API. These functions have been added to the conn library.

sniner commented 1 year ago

Great work @patrick-cichon-gcx :-) I assume you are using this enhancement productively at your end and it works? Currently I can't test it live on our Docuware system, hence my question.

I have only a few small suggestions for changes: According to PEP8, CamelCase should only be used on class names, not variables or functions. Please change the names of the parameters to snake_case.

In activate_user() you split the username into first and last name by cutting it apart at a single dot. I think the convention "firstname.lastname" is common, but probably not enforced anywhere. We should use a more robust method to separate the name. For example something like that:

name_parts = user_name.rsplit('.', 1)
if len(name_parts) > 1:
    first_name = name_parts[0]
    last_name = name_parts[1]
else:
    first_name = ""
    last_name = user_name
patrick-cichon-gcx commented 1 year ago

Hey @sniner, thanks for looking at my code! Ok, I'll change the parameters to snake_case.

Regarding the split of first and last name: I agree your solution is more robust. I worked it into the script. I'll open the PR this afternoon probably, I'm currently finishing up.

Yes, I tested the changes productively and they worked well on my end.

EDIT: I just commited the changes to this PR. I'm not sure but I think I do not need to open a new PR as you can view the changes in this PR. Let me know if this is not correct then I'll open a new PR.

sniner commented 1 year ago

Thanks @patrick-cichon-gcx for contributing to the project with this PR. I will upload the new version to PyPI next weekend.