def getSubmissionId(self, premiseUserID): submissionID = "" try: httpCall = HttpCalls() jsonData = httpCall.sendGet( TaskService.getUserSubmissions + premiseUserID, ApiCoreUtil.authorizationToken, "GET") print("json Response getSubmissionId: ", jsonData) # submissionID = super(TaskService, self).retrieveJSONValue(jsonData, "items") submissionID = super(TaskService, self).retrieveSubmissionID(jsonData, "items") # submissionID = super(TaskService, self).iterate_all(jsonData, "key") # submissionID = super(TaskService, self).find("submissionId",jsonData) app = ApiCoreUtil() print("type>>>SSSSSSSSSSSSSSS", type(jsonData)) # data = json.dumps(jsonData) # print("type>>>SSSSSSSSSSSSSSS", type(data)) # submissionID = app.find123("submissionId", data) # submissionID =[] # submissionID = get_all_keys(jsonData) # self.mytest(jsonData) # submissionID = app.retrieveJSONValueTEST("items", jsonData) print(" Submission ID - ", submissionID) print(" typeSubmission ID - ", type(submissionID)) print(" geteSubmission ID - ", submissionID) except: print("Exception encountered for getting Submission Id :::", sys.exc_info()) return submissionID
def setObservationId(self, submissionID, action): try: httpCall = HttpCalls() jsonData = httpCall.sendGet( TaskService.getCompletedTasks + submissionID, ApiCoreUtil.authorizationToken, "GET") print("Observation Data ::: ", jsonData) observationSet = self.getObservationIDs(jsonData, "observationId") for obsID in observationSet: print("obsID>>", obsID) jsonData1 = httpCall.sendPost( TaskService.submitObservation.replace( "SUBMISSIONID", submissionID).replace("OBSERVATIONID", obsID), ApiCoreUtil.authorizationToken, action) # itr = observationSet.iterator() # while(itr.hasNext()): # observationID = itr.next().toString() # print(observationSet) # jsonData1 = httpCall.sendPost(TaskService.submitObservation.replace("SUBMISSIONID", submissionID).replace("OBSERVATIONID", observationID), ApiCoreUtil.authorizationToken, action) except: print("Exception encountered for submitting observationId :::", sys.exc_info()) return False return True
def taskSubmissionAction(self, emailID, action, observationFeedback, submissionFeedback): print("#" * 10, "taskSubmissionAction", "*" * 10) try: user = UserService() premiseUserID = user.getUser(emailID) submissionID = self.getSubmissionId(premiseUserID) print("Final submissionID>>", submissionID) observationStatus = self.setObservationId( submissionID, self.prepareFeedback(observationFeedback, action)) if submissionID != "" and observationStatus == True: newUrl = TaskService.saveSubmission.replace( "SUBMISSIONID", submissionID) print("TaskService URL >>", newUrl) httpCall = HttpCalls() jsonData1 = httpCall.sendPost( TaskService.saveSubmission.replace("SUBMISSIONID", submissionID), ApiCoreUtil.authorizationToken, self.prepareFeedback(submissionFeedback, action)) submissionStatus = super(TaskService, self).retrieveJSONValue( jsonData1, "status") print(" Submission Status is - ", submissionStatus) else: print("Unable to perform ", action, " ::: Could not get Submission Id") except: print("Exception encountered in acceptSubmission :::", sys.exc_info()) return False return True
def softDeleteUser(self, emailID): try: premiseUserID = self.getUser(emailID) if (premiseUserID != ""): httpCall = HttpCalls() jsonData = httpCall.sendDelete( UserService.deleteUser + premiseUserID, UserService.authorizationToken, "DELETE") data = json.dumps(jsonData) if "User not found" not in data: userStatus = self.retrieveJSONValue(jsonData, "state") print("Status of email id - " + emailID + " is :- " + userStatus) else: print("Unable to softDelete") return False except: print("Encountered exception in softDeleteUser:::" + sys.exc_info()) return False return True
def localPartialUpdateUser(self, emailID): print("*localPartialUpdateUser", "*" * 5) try: premiseUserID = self.getUser(emailID) if premiseUserID != "": self.partialUpdateUserURL = UserService.partialUpdateUser.replace( "USERID", premiseUserID) print("partialUpdateUser URL:::" + self.partialUpdateUserURL) httpCall = HttpCalls() jsonData = httpCall.sendPut(self.partialUpdateUserURL, UserService.authorizationToken, self.prepareLocalUpdateJSON()) data = json.dumps(jsonData) if "User not found" not in data: self.printUserDetails(jsonData) else: print("Unable to update Partial User as Premise ID is empty") return False except: print("Encountered exception in partialUpdateUser:::" + sys.exc_info()) return False
def partialUpdateUserMethod(self, emailID, partialUpdateUserPayLoad): try: premiseUserID = self.getUser(emailID) if (premiseUserID != ""): partialUpdateUserURL = UserService.partialUpdateUser.replace( "USERID", premiseUserID) print("partialUpdateUser URL:::>>", partialUpdateUserURL) httpCall = HttpCalls() jsonData = httpCall.sendPut( self.partialUpdateUserURL, UserService.authorizationToken, self.prepareUpdateJSON(partialUpdateUserPayLoad)) data = json.dumps(jsonData) if "User not found" not in data: self.printUserDetails(jsonData) else: print( "Unable to update Partial User as Premise ID is empty") return False except: print("Encountered exception in partialUpdateUser:::", sys.exc_info()) return False return True
def getUser(self, emailID): premiseUserID = "" print("In getUser") try: if (super(UserService, self).getAutorizationToken() != None): httpCall = HttpCalls() str = UserService.getUserURL + emailID jsonObj = httpCall.sendGet(str, UserService.authorizationToken, "GET") print("Type of json>>", type(jsonObj)) if jsonObj != None: print("jsonObj result ::: ", jsonObj) data = json.dumps(jsonObj) print("type(data", type(data)) print("data = json.dumps(jsonObj) ", data) if "User not found" not in data: premiseUserID = super(UserService, self).retrieveJSONValue( jsonObj, UserService.jsonFlow) print(" Premise User Id - ", premiseUserID) print("PASSS") else: self.setUserGetErrorMsg(jsonObj) else: print( "Unable to get Premise User id:::Json object is NULL") else: print( "Unable to get Premise user id:::Null Authorization token") except: print("Encountered exception while retrieving user idr:::", sys.exc_info()) return premiseUserID