sjmh/pyqb

Can I add user management to this?

Opened this issue · 2 comments

I was wondering if this repo was open to new contributors. I wanted to add some user management functionality.
I can add them as decorators to the Client class, but felt it was worth trying to share.

    def addUser(self, database=None, roleid=None, userEmail=None, 
                userFirst=None, userLast=None):
        if database is None:
            database = self.database
        req = {'roleid':roleid, 'email':userEmail, 'fname':userFirst, 'lname':userLast}
        res = self.__request("ProvisionUser", database, req)
        return xmltodict.parse(et.tostring(res))['qdbapi']

    def getUserID(self, userEmail=None):
        req = {'email':userEmail}
        res = self.__request("GetUserInfo", 'main', req)
        return xmltodict.parse(et.tostring(res))['qdbapi']['user']['@id']

    def sendInvite(self, database=None, userid=None, messageText=None):
        if database is None:
            database = self.database
        req = {'userid':userid, 'usertext':messageText}
        res = self.__request("SendInvitation", database, req)
        return xmltodict.parse(et.tostring(res))['qdbapi']

    def changeUserRole(self, database=None, userid=None, roleid='9', newroleid=None):
        if database is None:
            database = self.database
        req = {'userid':userid, 'roleid':roleid}
        if newroleid is not None:
            req['newroleid'] = newroleid
        res = self.__request("ChangeUserRole", database, req)
        return xmltodict.parse(et.tostring(res))['qdbapi']

I can see this being a giant long term management headache. I'll understand that these probably don't need to be added to the main library.

sjmh commented

If you'd like to submit a PR, I'd be willing to look at it.

Unfortunately, I no longer have access to Quickbase, as I don't work at Intuit anymore ( where I mostly used it ), so it's hard for me to test any of this.