65
63
raise Exception('!!')
67
def get_messages(self, archive_id, message_ids=None, date_range=None,
68
limit=None, memo=None, order=None, headers=None,
69
include_hidden=False, max_body_length=None,
65
def get_messages(self, archive_id, message_ids=None, limit=None,
66
memo=None, order=None, headers=None,
67
max_body_length=None, include_hidden=False):
71
68
"""Retrieve specified messages.
73
70
:param archive_id: The archive to retrieve messages from.
74
71
:param message_ids: (optional) Retrieve only messages with these ids.
75
:param date_range: Retrieve the messages from or between a range of
76
dates. Example: 2012-01-01..2012-01-31 retrieve all the messages
77
between the 01 and 31 of January, including message from 01
79
72
:param limit: The maximum number of messages to return. The server
80
73
may, at its discretion, return fewer.
81
74
:param memo: (optional) Opaque identifier describing the position in
95
88
:param include_hidden: If true, include messages that have been
96
89
flagged "hidden" in the results.
97
:param display_type: Adjust the message content to meet the needs of
98
the intended display. Valid values are:
99
all: (the default) include all message content.
100
text-only: include only plain/text parts; exclude all other parts.
101
headers-only: include only the message headers.
104
92
if message_ids is not None:
105
93
parameters['message_ids'] = message_ids
106
if date_range is not None:
107
parameters['date_range'] = date_range
108
94
if limit is not None:
109
95
parameters['limit'] = limit
110
96
if memo is not None:
115
101
parameters['headers'] = headers
116
102
if max_body_length is not None:
117
103
parameters['max_body_length'] = max_body_length
118
parameters['display_type'] = display_type
119
104
parameters['include_hidden'] = include_hidden
120
105
query = {'parameters': simplejson.dumps(parameters)}
121
106
response = self._method_archive('GET', archive_id, query)
122
107
if response.status == httplib.BAD_REQUEST:
123
if response.reason == UnsupportedOrder.__doc__:
124
raise UnsupportedOrder
125
elif response.reason == UnsupportedDisplayType.__doc__:
126
raise UnsupportedDisplayType
127
elif response.reason == UnparsableDateRange.__doc__:
128
raise UnparsableDateRange
130
raise ValueError('Bad request')
108
raise UnsupportedOrder
131
109
data = response.read()
132
110
return simplejson.loads(data)