Commit 473e0add authored by Florian Fuchs's avatar Florian Fuchs

* moved some class definitions

* item access for _Addresses objects
parent 1e6e07b0
...@@ -672,31 +672,14 @@ class _Addresses: ...@@ -672,31 +672,14 @@ class _Addresses:
self._addresses = [] self._addresses = []
self._addresses = content['entries'] self._addresses = content['entries']
def __getitem__(self, key):
return _Address(self._connection, self._addresses[key])
def __iter__(self): def __iter__(self):
for address in self._addresses: for address in self._addresses:
yield _Address(self._connection, address) yield _Address(self._connection, address)
class _Preferences:
def __init__(self, connection, address):
self._connection = connection
self._address = address
self._preferences = None
self._get_preferences()
def _get_preferences(self):
if self._preferences is None:
response, content = self._connection.call(
'addresses/{0}/preferences'.format(self._address))
if 'entries' not in content:
self._preferences = []
self._preferences = content['entries']
def __iter__(self):
for preference in self._preferences:
yield _Preference(self._connection, preference)
class _Address: class _Address:
def __init__(self, connection, address): def __init__(self, connection, address):
self._connection = connection self._connection = connection
...@@ -738,6 +721,26 @@ class _Address: ...@@ -738,6 +721,26 @@ class _Address:
self._info = None self._info = None
class _Preferences:
def __init__(self, connection, address):
self._connection = connection
self._address = address
self._preferences = None
self._get_preferences()
def _get_preferences(self):
if self._preferences is None:
response, content = self._connection.call(
'addresses/{0}/preferences'.format(self._address))
if 'entries' not in content:
self._preferences = []
self._preferences = content['entries']
def __iter__(self):
for preference in self._preferences:
yield _Preference(self._connection, preference)
LIST_READ_ONLY_ATTRS = ('bounces_address', 'created_at', 'digest_last_sent_at', LIST_READ_ONLY_ATTRS = ('bounces_address', 'created_at', 'digest_last_sent_at',
'fqdn_listname', 'http_etag', 'mail_host', 'fqdn_listname', 'http_etag', 'mail_host',
'join_address', 'last_post_at', 'leave_address', 'join_address', 'last_post_at', 'leave_address',
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment