def userCancelOrderActivity(self): self.rsp = httpPost( url = userCancelOrderActivityUrl, headers = self.jsonheart, reqJsonData = self.userCancelOrderActivityReqjson ) return self.rsp
def writeHttpReqRspDataToFile(bsDict=None, reqHeaderData={}, reqBodyData={}, httpUrl=""): baseDictTranDataDict(bsDict) method = bsDict["method"] url = bsDict["url"] formatReqJsonFile = bsDict["formatReqJsonFile"] formatRspJsonFile = bsDict["formatRspJsonFile"] # os.mknod(formatReqJsonFile) # os.mknod(formatRspJsonFile) if method == "post": rsp = httpPost(url=httpUrl, headers=reqHeaderData, reqJsonData=reqBodyData) writeStrToJsonFile(filePath=formatReqJsonFile, jsonStr=reqBodyData, rwmode="a+") writeStrToJsonFile(filePath=formatRspJsonFile, jsonStr=rsp, rwmode="a+") elif method == "get": writeUrlLowDataToFile(filePath=formatReqJsonFile, jsonStr="top " + httpUrl) rsp = httpGet(url=httpUrl, headers=reqHeaderData) writeStrToJsonFile(filePath=formatRspJsonFile, jsonStr=rsp, rwmode="a+")
def userCancelAppleMatch(): token = getTokenReset() print("token=%s" % token) heartJson = {"token":token,"Content-Type":"application/json"} getUserAppleMatchCode() rsp = httpPost(url = "https://uat-steam-api.opg.cn/match-service/member/apply/cancel" , headers = heartJson , reqJsonData = cancelAppleMatchReq) print(rsp)
def userAppleMatch(phoneNo = None,memberId = None,ip = None): #token = getTokenReset() #print("token=%s" % token) heartJson = {"memberId":memberId,"Content-Type":"application/json"} appleJson["contactPhone"] = phoneNo print(appleJson) rsp = httpPost(url = "http://%s/match-service/member/apply" % ip , headers = heartJson , reqJsonData = appleJson) print(rsp)
def getTokenData(cls): if cls.token is None: kwgs = { "username": "******", "password": "******" } rsp = httpPost(url = adminLoginUrl, headers = {}, reqJsonData = kwgs) cls.token = query_json(json_content=json.loads(rsp), query="token") return cls.token
def login(self, userType="admin", phoneNum="", vfyUrl="", lgUrl="", lgDataBy={}, vfyCodeName="code", queryTokenFmt="data.token"): dataBody = {"phoneNo": phoneNum} rsp = httpPost(url=vfyUrl, reqJsonData=dataBody) print("phoneNum=%s,vfyUrl-rsp:%s" % (phoneNum, rsp)) retcode = query_json(json_content=json.loads(rsp), query="code") if retcode == "000000": verifyCode = getVerifyCodeByUserType(userType, phoneNum) print("verifyCode:%s" % verifyCode) lgDataBy[vfyCodeName] = verifyCode print("lgDataBy :%s" % str(lgDataBy)) rsp = httpPost(url=lgUrl, reqJsonData=lgDataBy) print("lgDataBy-rsp:%s" % rsp) return query_json(json_content=json.loads(rsp), query=queryTokenFmt)
def getUserAppleMatchCode(): token = getTokenReset() print("token=%s" % token) heartJson = { "token":token, "Content-Type":"application/json" } rsp = httpPost(url = "https://uat-steam-api.opg.cn/match-service/member/mp/query" , headers = heartJson , reqJsonData = {"matchId":22}) print(rsp) rsp = json.loads(rsp) if len(rsp["applyInfoList"]) > 0: cancelAppleMatchReq["applyId"] = rsp["applyInfoList"][0]["applyCode"] return rsp["applyInfoList"][0]["applyCode"]
def userAddAddressReq(self): reqjson = { "consignee": self.inputKV["consignee"], "phone": self.inputKV["phone"], "address": self.inputKV["address"], "addressCode": self.inputKV["addressCode"], "province": self.inputKV["province"], "city": self.inputKV["city"], "county": self.inputKV["county"], "isDefault": self.inputKV["isDefault"] } self.rsp = httpPost(url=userAddAddressUrl, reqJsonData=reqjson, headers=self.jsonheart) addressId = MemberAddressService( kwargs=self.inputKV).getMemberAddressIdByNameOrTel( conName=reqjson["consignee"], conTel=reqjson["phone"]) self.inputKV["addressId"] = addressId self.reqjsondata = "?id=%(addressId)s" % self.inputKV
def userCollectionReq(self): httpPost(url=userCollectionUrl, reqJsonData={"resourceId": self.inputKV["resourceId"]}, headers=self.jsonheart)
self.rsp = httpReqSend(url=url, headers=self.jsonheart, reqJson=self.reqjsondata, fileName=self.inputKV.get('file', None), method=method) return self.rsp @resultData(param="getRetcodeByRsp") def getRetcodeByRsp(self, response=None, format="code"): retcode = "000000" try: retcode = query_json(json_content=json.loads(self.rsp), query=format) except Exception as e: print("返回报文异常") print(e) logger.info("返回报文异常") logger.info(e) retcode = "2000001" finally: return retcode if __name__ == "__main__": httpPost( url="https://uat-steam-api.opg.cn/operation-manage/course/removeCourse", headers={ "login_type": "CMS", "token": "9e8a038e5bb84cd49fa0e1e35aa8ed35" }, reqJsonData={"resourceId": 5318})
def delArticle(self): articleid = self.getArticleIdByRsp(self.rsp) delclassfiyRsp = httpPost(url=delArticleurl, headers=self.jsonheart, reqJsonData={"resourceId": articleid}) return delclassfiyRsp
def alertClassfiy(self): self.rsp = httpPost(url=alertentryurl, headers=self.jsonheart, reqJsonData=self.reqjsondata) return self.rsp
def userLogin(self): self.rsp = httpPost(url = adminLoginUrl, headers = self.jsonheart, reqJsonData = self.reqjsondata) return self.rsp
def appleRest(): httpPost(url = "http://10.205.248.165:20000/tool/applyNumsReset", headers = {}, reqJsonData = reqjson)