RAPP Platform API
 All Classes Namespaces Files Functions Variables Typedefs
EmailFetch.py
Go to the documentation of this file.
1 from RappCloud.Objects import (
2  File,
3  Payload)
4 
5 from Cloud import (
6  CloudMsg,
7  CloudRequest,
8  CloudResponse)
9 
10 
11 class EmailFetch(CloudMsg):
12  """ Email Fetch Cloud Message object """
13 
14  class Request(CloudRequest):
15  """ Email Fetch Cloud Request object.
16 
17  EmailFetch.Request
18  """
19  def __init__(self, **kwargs):
20  """!
21  Constructor
22 
23  @param **kwargs - Keyword arguments. Apply values to the request attributes.
24  - @ref email
25  - @ref password
26  - @ref server
27  - @ref port
28  - @ref date_from
29  - @ref date_to
30  - @ref email_status
31  - @ref num_emails
32  """
33 
34  ## User's email username
35  self.email = ''
36  ## User's email password
37  self.password = ''
38  ## The email server's imap address, i.e. 'imap.gmail.com'.
39  self.server = ''
40  ## The email server imap port. leave empty to use default value.
41  self.port = ''
42  ## Emails since date. Unix timestamp.
43  self.date_from = 0
44  ## Emails until date. Unix timestamp.
45  self.date_to = 0
46  ## Define which mails the users requests. Values: ALL, UNSEEN(DEFAULT)
47  self.email_status = ''
48  ## Number of requested emails.
49  self.num_emails = 0
50 
51  super(EmailFetch.Request, self).__init__(**kwargs)
52 
53 
54  def make_payload(self):
55  """ Create and return the Payload of the Request. """
56  return Payload(
57  email=self.email,
58  passwd=self.password,
59  server=self.server,
60  port=self.port,
61  from_date=self.date_from,
62  to_date=self.date_to,
63  email_status=self.email_status,
64  num_emails=self.num_emails)
65 
66 
67  def make_files(self):
68  """ Create and return Array of File objects of the Request. """
69  return []
70 
71 
72  class Response(CloudResponse):
73  """ Email Fetch Cloud Response object.
74 
75  EmailFetch.Response
76  """
77  def __init__(self, **kwargs):
78  """!
79  Constructor
80 
81  @param **kwargs - Keyword arguments. Apply values to the request attributes.
82  - @ref error
83  - @ref emails
84  """
85 
86  ## Error message
87  self.error = ''
88  ## An array of emailEntry objects, where emailEntry is of structure:
89  # {sender: '', receivers: [], date: '', body: '', attachments: []}
90  self.emails = []
91  super(EmailFetch.Response, self).__init__(**kwargs)
92 
93 
94  def __init__(self, **kwargs):
95  """!
96  Constructor
97 
98  @param **kwargs - Keyword argumen.ts. Apply values to the request attributes.
99  - @ref Request.email
100  - @ref Request.password
101  - @ref Request.server
102  - @ref Request.port
103  - @ref Request.date_from
104  - @ref Request.date_to
105  - @ref Request.email_status
106  - @ref Request.num_emails
107  """
108 
109  # Create and hold the Request object for this CloudMsg
111  # Create and hold the Response object for this CloudMsg
113  super(EmailFetch, self).__init__(
114  svcname='email_fetch', **kwargs)
115 
116 
server
The email server's imap address, i.e.
Definition: EmailFetch.py:39
email_status
Define which mails the users requests.
Definition: EmailFetch.py:47
emails
An array of emailEntry objects, where emailEntry is of structure: {sender: '', receivers: []...
Definition: EmailFetch.py:90