def create_answer(answer): survey_link = answer['surveyLink'] url = SPRING_URL + 'answer/' + survey_link test_log(inspect.stack()[0][3], url) rev = requests.post(url, json=answer) if rev.status_code is 200: print('Rev from POST : ' + url + rev.text) return util.string_to_json(rev.text) else: error = "[SPRING return error]" + str(rev.status_code) return util.string_to_json(rev.text)
def create_survey(data): # @PostMapping(value="/account/{accountId}/addsurvey") url = SPRING_URL + 'account/{0}/addsurvey'.format(current_user.get_id()) test_log(inspect.stack()[0][3], url) rev = requests.post(url, json=data) json = util.string_to_json(rev.text) return json
def get_survey_by_id(surveyId): url = SPRING_URL + 'survey?surveyId=' + str(surveyId) test_log(inspect.stack()[0][3], url) rev = requests.get(url) json = util.string_to_json(rev.text) cur_survey_id = json['id'] return json
def get_report_by_id(uid, sid): # GET http://localhost:8080/account/1/report/?surveyId=8 url = (SPRING_URL + 'account/{0}/report/?surveyId={1}'.format(uid, sid)) test_log(inspect.stack()[0][3], url) rev = requests.get(url) test_log(inspect.stack()[0][3], rev.text) json = util.string_to_json(rev.text) return json
def get_password(username): try: rev = requests.get(SPRING_URL + 'api/get_user_id?email=' + username) json = util.string_to_json(rev.text) return json['password'] except Exception as e: print(e) error_log(inspect.stack()[0][3], "get password failed") return None
def get_all_surveys_for_user(uid): ''' :return a list of survey object string ''' url = SPRING_URL + 'account/' + str(uid) + '/allsurveys' test_log(inspect.stack()[0][3], url) rev = requests.get(url) json = util.string_to_json(rev.text) return json
def get_username(user_id): try: rev = requests.get(SPRING_URL + 'account/' + user_id) json = util.string_to_json(rev.text) if json: return json['email'] except Exception as e: print(e) error_log(inspect.stack()[0][3], "get username error") return None
def create_question(data): surveyId = data['surveyId'] url = SPRING_URL + 'addquestion/' + str(surveyId) test_log(inspect.stack()[0][3], url) data['surveyId'] = int(surveyId) rev = requests.post(url, json=data) if rev.status_code == 200: print('Rev from POST: ' + url + rev.text) return util.string_to_json(rev.text) return False
def get_all_general_surveys(): url = SPRING_URL + 'survey/surveyType/' + 'GENERAL' test_log(inspect.stack()[0][3], url) rev = requests.get(url) json = util.string_to_json(rev.text) return json
def get_survey_by_uuid(uuid): url = SPRING_URL + 'survey/' + uuid test_log(inspect.stack()[0][3], url) rev = requests.get(url) json = util.string_to_json(rev.text) return json