class ConversationApiService(object): def __init__(self): self.apiaddress = ApiAddressService() self.storagecookie = StorageCookieService() def All(self): return requests.get("{0}/Conversation/All".format( self.apiaddress.getaddress()), cookies=self.storagecookie.get()) def SendMessage(self, conversationId, Message): return requests.post("{0}/Conversation/SendMessage".format( self.apiaddress.getaddress()), data={ "Id": conversationId, "Content": Message }, cookies=self.storagecookie.get()) def GetMesssages(self, conversationId, take): return requests.get( "{0}/Conversation/GetMessage?Id={1}&take={2}".format( self.apiaddress.getaddress(), str(conversationId), str(take)), cookies=self.storagecookie.get()) def ConversationDetail(self, conversationid): return requests.get( "{0}/Conversation/ConversationDetail?id={1}".format( self.apiaddress.getaddress(), str(conversationid)), cookies=self.storagecookie.get())
class AuthApiService(object): def __init__(self): self.apiaddress = ApiAddressService() self.storagecookie = StorageCookieService() def Version(self): return requests.get("{0}/Auth/Version".format(self.apiaddress.getaddress())) def AuthByPassword(self, email, password): return requests.post("{0}/Auth/AuthByPassword".format(self.apiaddress.getaddress()), data={ "Email": email, "Password": password }) def InitPusher(self): return requests.get("{0}/Auth/InitPusher".format(self.apiaddress.getaddress()), cookies=self.storagecookie.get()) def SignInStatus(self): return requests.get("{0}/Auth/SignInStatus".format(self.apiaddress.getaddress(), cookies=self.storagecookie.get())) def Me(self): return requests.get( "{0}/Auth/Me".format(self.apiaddress.getaddress()), cookies=self.storagecookie.get())
class FriendShipApiService(object): def __init__(self): self.apiaddress = ApiAddressService() self.storagecookie = StorageCookieService() def Mine(self): return requests.get("{0}/Friendship/Mine".format(self.apiaddress.getaddress()), cookies=self.storagecookie.get()) def UserDetail(self, userid): return requests.get("{0}/Friendship/UserDetail?id={1}".format(self.apiaddress.getaddress(), str(userid)), cookies=self.storagecookie.get()) def DeleteFriend(self, userid): return requests.post("{0}/Friendship/DeleteFriend".format(self.apiaddress.getaddress()), data={ "id": str(userid) }, cookies=self.storagecookie.get())
class GroupApiService(object): def __init__(self): self.apiaddress = ApiAddressService() self.storagecookie = StorageCookieService() def LeaveGroup(self, groupname): return requests.post("{0}/Groups/LeaveGroup".format( self.apiaddress.getaddress()), data={"groupName": groupname}, cookies=self.storagecookie.get())
class FileApiService(object): def __init__(self): self.apiaddress = ApiAddressService() self.storagecookie = StorageCookieService() def FileDownloadAddress(self, filekey): return requests.post("{0}/Files/FileDownloadAddress".format( self.apiaddress.getaddress()), data={"FileKey": filekey}, cookies=self.storagecookie.get())
class SignInStatusCheckService(object): def __init__(self): self.storagecookie = StorageCookieService() self.apiaddress = ApiAddressService() def check(self): if os.path.exists("{0}/user.cookie.bin".format( HomeFloderConfig().getconfigpath())): cookies = self.storagecookie.get() err = requests.post("{0}/Auth/SignInStatus".format( self.apiaddress.getaddress()), cookies=cookies) err = json.loads(err.text) if err["value"]: return True else: return False else: return False
def __init__(self): self.storagecookie = StorageCookieService() self.apiaddress = ApiAddressService()
def __init__(self): self.apiaddress = ApiAddressService() self.authapiservice = AuthApiService()