Ponytech / appstoreconnectapi

Python wrapper around Apple App Store Api
https://ponytech.net/projects/app-store-connect
MIT License
161 stars 74 forks source link

How to modify user roles #30

Closed yangcaixing closed 3 years ago

yangcaixing commented 3 years ago

Hi Pony, I want to modify an existing user's roles (role and visibleApps), not invite new user. I look from appstore api document, it contain "Modify a User Account" api, but I don't find the related code from your api.py file. would please have a check, thanks very much.

ppawlak commented 3 years ago

@yangcaixing Thanks for reporting this. You're right modifying and removing a user account are missing from the library, I am working on it to add them.

yangcaixing commented 3 years ago

Thanks pony, I'm looking forward to your update.

ppawlak commented 3 years ago

@yangcaixing I have just made a new commit that allows to modify a user's role. You can try with:

from appstoreconnect import Api, UserRole

user = list(api.list_users())[0]
api.modify_user_account(user, roles=[UserRole.FINANCE, UserRole.APP_MANAGER, UserRole.ACCESS_TO_REPORTS])

I still have to add support for updating the visibleApps

ppawlak commented 3 years ago

Well, I've also handled visibleApps :

    apps = api.list_apps(filters={ 'name': 'My great app'})
    app = list(apps)[0]
        user = list(api.list_users())[0]
    user = api.modify_user_account(user, visibleApps=[app])

Let me know if everything works as expected before I close this issue.

yangcaixing commented 3 years ago

Hi pony, I have update appstoreconnect to v0.8.4, run the code have bellow errors. and I also check from the library api.py file, there no modify_user_account function existed, could you please check again, thanks.

Traceback (most recent call last): File "appstore.py", line 4, in from appstoreconnect import Api, UserRole ImportError: cannot import name 'UserRole'

Traceback (most recent call last): File "appstore.py", line 40, in api.modify_user_account(user, roles=[UserRole.FINANCE, UserRole.APP_MANAGER, UserRole.ACCESS_TO_REPORTS]) AttributeError: 'Api' object has no attribute 'modify_user_account' image

ppawlak commented 3 years ago

I have update appstoreconnect to v0.8.4

The _modify_useraccount endpoint is not yet included in a release published on PyPI. You have to checkout this repository to test it.

yangcaixing commented 3 years ago

Hi pony, I have checkout the repo and test, it works now, thanks very much.

ppawlak commented 3 years ago

I have checkout the repo and test, it works now,

Great! I am closing the issue then. I'll publish a new version including it soon.

yangcaixing commented 3 years ago

Hi Pony, BTW, I want to list a use's visibleApps, to check if user have some specific app's roles, but I don't find the visibleApps attribute under apple User.Attributes, could you help check it , thanks.

ppawlak commented 3 years ago

Hi @yangcaixing,

BTW, my name is not Pony 😄 I am Patrice.

You should be able to get a user's visible apps with: user.visibleApps() but it currently doesn't work. I have to implement the VisibleApps resource (https://developer.apple.com/documentation/appstoreconnectapi/user/relationships/visibleapps) You can open a separate issue for this.

yangcaixing commented 3 years ago

Hi Patrice, I'm sorry for call your name wrong, and I will open a new issue for this, thanks.