summaryrefslogtreecommitdiffstats
path: root/g4f/.v1/unfinished/openprompt/mail.py
diff options
context:
space:
mode:
authorMIDORIBIN <aquarion123@gmail.com>2023-07-28 12:07:17 +0200
committerMIDORIBIN <aquarion123@gmail.com>2023-08-14 04:46:32 +0200
commitf6ef3cb2237d8c336e915ef77ddbe6f37934c4fd (patch)
treec8bc44917ea03909cf586140f984ff0814bc30ea /g4f/.v1/unfinished/openprompt/mail.py
parent~ | small fixes & new pypi version | v-0.0.1.9 (diff)
downloadgpt4free-f6ef3cb2237d8c336e915ef77ddbe6f37934c4fd.tar
gpt4free-f6ef3cb2237d8c336e915ef77ddbe6f37934c4fd.tar.gz
gpt4free-f6ef3cb2237d8c336e915ef77ddbe6f37934c4fd.tar.bz2
gpt4free-f6ef3cb2237d8c336e915ef77ddbe6f37934c4fd.tar.lz
gpt4free-f6ef3cb2237d8c336e915ef77ddbe6f37934c4fd.tar.xz
gpt4free-f6ef3cb2237d8c336e915ef77ddbe6f37934c4fd.tar.zst
gpt4free-f6ef3cb2237d8c336e915ef77ddbe6f37934c4fd.zip
Diffstat (limited to 'g4f/.v1/unfinished/openprompt/mail.py')
-rw-r--r--g4f/.v1/unfinished/openprompt/mail.py111
1 files changed, 0 insertions, 111 deletions
diff --git a/g4f/.v1/unfinished/openprompt/mail.py b/g4f/.v1/unfinished/openprompt/mail.py
deleted file mode 100644
index 1130e7df..00000000
--- a/g4f/.v1/unfinished/openprompt/mail.py
+++ /dev/null
@@ -1,111 +0,0 @@
-import email
-
-import requests
-
-
-class MailClient:
-
- def __init__(self):
- self.username = None
- self.token = None
- self.raw = None
- self.mailids = None
- self.mails = None
- self.mail = None
-
- def create(self, force=False):
- headers = {
- 'accept': 'application/json',
- }
-
- if self.username:
- pass
- else:
- self.response = requests.put(
- 'https://www.developermail.com/api/v1/mailbox', headers=headers)
- self.response = self.response.json()
- self.username = self.response['result']['name']
- self.token = self.response['result']['token']
-
- return {'username': self.username, 'token': self.token}
-
- def destroy(self):
- headers = {
- 'accept': 'application/json',
- 'X-MailboxToken': self.token,
- }
- self.response = requests.delete(
- f'https://www.developermail.com/api/v1/mailbox/{self.username}', headers=headers)
- self.response = self.response.json()
- self.username = None
- self.token = None
- return self.response
-
- def newtoken(self):
- headers = {
- 'accept': 'application/json',
- 'X-MailboxToken': self.token,
- }
- self.response = requests.put(
- f'https://www.developermail.com/api/v1/mailbox/{self.username}/token', headers=headers)
- self.response = self.response.json()
- self.token = self.response['result']['token']
- return {'username': self.username, 'token': self.token}
-
- def getmailids(self):
- headers = {
- 'accept': 'application/json',
- 'X-MailboxToken': self.token,
- }
-
- self.response = requests.get(
- f'https://www.developermail.com/api/v1/mailbox/{self.username}', headers=headers)
- self.response = self.response.json()
- self.mailids = self.response['result']
- return self.mailids
-
- def getmails(self, mailids: list = None):
- headers = {
- 'accept': 'application/json',
- 'X-MailboxToken': self.token,
- 'Content-Type': 'application/json',
- }
-
- if mailids is None:
- mailids = self.mailids
-
- data = str(mailids)
-
- self.response = requests.post(
- f'https://www.developermail.com/api/v1/mailbox/{self.username}/messages', headers=headers, data=data)
- self.response = self.response.json()
- self.mails = self.response['result']
- return self.mails
-
- def getmail(self, mailid: str, raw=False):
- headers = {
- 'accept': 'application/json',
- 'X-MailboxToken': self.token,
- }
- self.response = requests.get(
- f'https://www.developermail.com/api/v1/mailbox/{self.username}/messages/{mailid}', headers=headers)
- self.response = self.response.json()
- self.mail = self.response['result']
- if raw is False:
- self.mail = email.message_from_string(self.mail)
- return self.mail
-
- def delmail(self, mailid: str):
- headers = {
- 'accept': 'application/json',
- 'X-MailboxToken': self.token,
- }
- self.response = requests.delete(
- f'https://www.developermail.com/api/v1/mailbox/{self.username}/messages/{mailid}', headers=headers)
- self.response = self.response.json()
- return self.response
-
-
-client = MailClient()
-client.newtoken()
-print(client.getmails())