def update_token(self, uid, token, refresh_token, appId=""): head = CONST.getHead(token, appId) data = { "uid" : uid, "refreshToken" : refresh_token } return requests.put(self.baseURL, params=data, headers=head)
def send_captcha(self, mobile, check_type, token="token", app_id=CONST.APPID): head = CONST.getHead(token, app_id) params = "mobile=" + mobile + "&checktype=" + str(check_type) return requests.get(self.baseUrl, params=params, headers=head)
def validate_captcha(self, mobile, captcha, check_type, token="token", app_id=CONST.APPID): head = CONST.getHead(token, app_id) data = {"mobile": mobile, "captcha": captcha, "checkType": check_type} return requests.put(self.baseUrl, data=data, headers=head)
def unbind_mobile(self, uid, token="token", app_id=CONST.APPID, unverified="true"): head = CONST.getHead(token, app_id) params = "unverified=" + str(unverified) url = self.baseUrl + "/" + str(uid) return requests.delete(url, headers=head, params=params)
def bind_sub_account(self, uid, temp_id, sub_app_id, token="token", app_id=CONST.APPID): head = CONST.getHead(token, app_id) data = {"uid": uid, "tempId": str(temp_id), "subAppId": sub_app_id} url = self.baseUrl + "/" + str(uid) return requests.post(url, data=data, headers=head)
def bind_mobile(self, uid, mobile, token="token", app_id=CONST.APPID, unverified="true"): head = CONST.getHead(token, app_id) data = {"mobile": mobile, "unverified": unverified} url = self.baseUrl + "/" + str(uid) return requests.put(url, data=data, headers=head)
def unbind_sub_account(self, uid, sub_app_id, sub_account, token="token", app_id=CONST.APPID): head = CONST.getHead(token, app_id) params = "subAppId=" + str(sub_app_id) + "&subAccount=" + sub_account url = self.baseUrl + "/" + str(uid) return requests.delete(url, params=params, headers=head)
def reset_password(self, uid, password, app_id=CONST.APPID, unverified="true"): head = CONST.getHead("token", app_id) if password != "": password = hashlib.md5(password.encode("utf8")).hexdigest() data = {"password": password, "unverified": unverified} url = self.baseUrl + "/" + str(uid) return requests.post(url, data=data, headers=head)
def login_subaccount(self, app_id, sub_app_id, sub_account): head = CONST.getHead("", app_id) timestamp = str(int(time.time()*1000)) url = self.baseURL+"/subaccount" data = { "subaccount": sub_account, "subAppId": sub_app_id, "scope": "" } return requests.post(url, data=data, headers=head)
def login(self, account, pwd, app_id=''): head = CONST.getHead("", app_id) timestamp = str(int(time.time()*1000)) pwd = Md5.encoder_pwd(pwd, account, timestamp) data = { "account": account, "password": pwd, "timestamp": timestamp, "scope": "" } #print(data) #print(head) return requests.post(self.baseURL, data=data, headers=head)
def update_user_info(self, uid, user_info, extend_info, token="token", app_id=CONST.APPID): head = CONST.getHead(token, app_id) data = { "userInfo": AccountUtils.get_up_user_info(), "extendInfo": AccountUtils.get_up_extend_info() } if user_info != "": data["userInfo"] = user_info if extend_info != "": data["extendInfo"] = extend_info url = self.baseUrl + "/" + str(uid) return requests.put(url, data=data, headers=head)
def update_password(self, uid, old_pwd, password, token="token", app_id=CONST.APPID, unverified="true"): head = CONST.getHead(token, app_id) if old_pwd != "": old_pwd = hashlib.md5(old_pwd.encode("utf8")).hexdigest() if password != "": password = hashlib.md5(password.encode("utf8")).hexdigest() data = { "oldPwd": old_pwd, "password": password, "unverified": unverified } url = self.baseUrl + "/" + str(uid) return requests.put(url, data=data, headers=head)
def register(self, user_code, password, user_info, extend_info, app_id=CONST.APPID, unverified="true"): head = CONST.getHead("token", app_id) if password != "": password = hashlib.md5(password.encode("utf8")).hexdigest() data = { "mobile": user_code, "password": password, "userInfo": AccountUtils.get_user_info(), "extendInfo": AccountUtils.get_extend_info(), "unverified": unverified } if user_info != "": data["userInfo"] = user_info if extend_info != "": data["extendInfo"] = extend_info return requests.post(self.baseUrl, data=data, headers=head)
def get_status(self, uid, target_id, token="token", app_id=CONST.APPID): head = CONST.getHead(token, app_id) url = self.baseUrl + "/" + str(uid) params = "targetId=" + str(target_id) return requests.get(url, params=params, headers=head)
def register(self, callback_url, app_id): head = CONST.getHead("", app_id) data = {"callBackUrl": callback_url} return requests.post(self.baseURL, data=data, headers=head)
def un_register(self, app_id): head = CONST.getHead("", app_id) return requests.delete(self.baseURL, headers=head)
def get_binding_status(self, uid, token="token", app_id=CONST.APPID): head = CONST.getHead(token, app_id) # params = "uid=" + str(uid) url = self.baseUrl + "/" + str(uid) return requests.get(url, headers=head)
def enable_user(self, uid, target_id, token="token", app_id=CONST.APPID): head = CONST.getHead(token, app_id) url = self.baseUrl + "/" + str(uid) params = "uid=" + str(uid) + "&targetId=" + str(target_id) return requests.delete(url, params=params, headers=head)
def get_sub_account(self, sub_account, sub_app_id, app_id=CONST.APPID): head = CONST.getHead("", app_id) params = "subAccount=" + str(sub_account) + "&subAppId=" + str( sub_app_id) url = self.baseUrl return requests.get(url, params=params, headers=head)
def get_sub_account_list(self, uid, token="token", app_id=CONST.APPID): head = CONST.getHead(token, app_id) # params = "uid=" + str(uid) url = self.baseUrl + "/" + str(uid) return requests.get(url, headers=head)
def query(self, token): return requests.get(self.baseURL, headers=CONST.getHead(token))
def query_user(self, uid, token): tmp_url = "%s/%s" % (self.baseURL, uid) head = CONST.getHead(token) return requests.get(tmp_url, headers=head)
def logout(self, token): return requests.delete(self.baseURL, headers=CONST.getHead(token))
def clean(self): head = CONST.getHead("token") requests.delete(self.baseUrl, headers=head)
def disable_user(self, uid, target_id, token="token", app_id=CONST.APPID): head = CONST.getHead(token, app_id) url = self.baseUrl + "/" + str(uid) data = {"targetId": target_id} return requests.put(url, data=data, headers=head)