Browse Source

Added newuser to api.py .

Thanks to WassimDhib and xet7 !

Fixes #4774,
fixes #4771
Lauri Ojansivu 3 years ago
parent
commit
f485ccea2f
1 changed files with 16 additions and 0 deletions
  1. 16 0
      api.py

+ 16 - 0
api.py

@@ -40,6 +40,7 @@ if arguments == 0:
     print("  python3 api.py addcard AUTHORID BOARDID SWIMLANEID LISTID CARDTITLE CARDDESCRIPTION")
     print("  python3 api.py addcard AUTHORID BOARDID SWIMLANEID LISTID CARDTITLE CARDDESCRIPTION")
     print("  python3 api.py editcard BOARDID LISTID CARDID NEWCARDTITLE NEWCARDDESCRIPTION")
     print("  python3 api.py editcard BOARDID LISTID CARDID NEWCARDTITLE NEWCARDDESCRIPTION")
     print("  python3 api.py listattachments BOARDID # List attachments")
     print("  python3 api.py listattachments BOARDID # List attachments")
+    print("  python3 api.py newuser USERNAME EMAIL PASSWORD")
 # TODO:
 # TODO:
 #   print("  python3 api.py attachmentjson BOARDID ATTACHMENTID # One attachment as JSON base64")
 #   print("  python3 api.py attachmentjson BOARDID ATTACHMENTID # One attachment as JSON base64")
 #   print("  python3 api.py attachmentbinary BOARDID ATTACHMENTID # One attachment as binary file")
 #   print("  python3 api.py attachmentbinary BOARDID ATTACHMENTID # One attachment as binary file")
@@ -231,6 +232,21 @@ if arguments == 6:
         print(data2)
         print(data2)
         # ------- EDIT CARD END -----------
         # ------- EDIT CARD END -----------
 
 
+if arguments == 4:
+
+    if sys.argv[1] == 'newuser':
+
+        # ------- CREATE NEW USER START -----------
+        username = sys.argv[2]
+        email = sys.argv[3]
+        password = sys.argv[4]
+        headers = {'Accept': 'application/json', 'Authorization': 'Bearer {}'.format(apikey)}
+        post_data = {'username': '{}'.format(username),'email': '{}'.format(email),'password': '{}'.format(password)}
+        body = requests.post(users, data=post_data, headers=headers)
+        print("=== CREATE NEW USER ===\n")
+        print(body.text)
+        # ------- CREATE NEW USER END -----------
+
 if arguments == 3:
 if arguments == 3:
 
 
     if sys.argv[1] == 'createlist':
     if sys.argv[1] == 'createlist':