Skip to content
This repository has been archived by the owner on Dec 29, 2022. It is now read-only.

Handle setting a forwarding address when creating a filter. #46

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions src/gdata/apps/emailsettings/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,8 @@ def delete_label(self, username, label, **kwargs):
def create_filter(self, username, from_address=None,
to_address=None, subject=None, has_the_word=None,
does_not_have_the_word=None, has_attachments=None,
label=None, mark_as_read=None, archive=None, **kwargs):
label=None, mark_as_read=None, archive=None,
forward_to=None, **kwargs):
"""Creates a filter with the given properties.

Args:
Expand All @@ -211,6 +212,7 @@ def create_filter(self, username, from_address=None,
messages matching the filter criteria as read.
archive: Boolean (optional) Whether or not to move messages
matching to Archived state.
forwardTo: (optional) The email address to forward matching messages to.
kwargs: The other parameters to pass to gdata.client.GDClient.post().

Returns:
Expand All @@ -224,7 +226,8 @@ def create_filter(self, username, from_address=None,
has_the_word=has_the_word,
does_not_have_the_word=does_not_have_the_word,
has_attachments=has_attachments, label=label,
mark_as_read=mark_as_read, archive=archive)
mark_as_read=mark_as_read, archive=archive,
forward_to=forward_to)
return self.post(new_filter, uri, **kwargs)

CreateFilter = create_filter
Expand Down
14 changes: 12 additions & 2 deletions src/gdata/apps/emailsettings/data.py
Original file line number Diff line number Diff line change
Expand Up @@ -392,10 +392,18 @@ def SetArchive(self, value):

archive = pyproperty(GetArchive, SetArchive)

def GetForwardTo(self):
return self._GetProperty(FORWARDING_TO)

def SetForwardTo(self, value):
self._SetProperty(FORWARDING_TO, value)

forward_to = pyproperty(GetForwardTo, SetForwardTo)

def __init__(self, uri=None, from_address=None, to_address=None,
subject=None, has_the_word=None, does_not_have_the_word=None,
has_attachments=None, label=None, mark_as_read=None,
archive=None, *args, **kwargs):
archive=None, forward_to=None, *args, **kwargs):
"""Constructs a new EmailSettingsFilter object with the given arguments.

Args:
Expand Down Expand Up @@ -441,6 +449,8 @@ def __init__(self, uri=None, from_address=None, to_address=None,
self.mark_as_read = str(mark_as_read)
if archive is not None:
self.archive = str(archive)
if forward_to is not None:
self.forward_to = forward_to


class EmailSettingsSendAsAlias(EmailSettingsEntry):
Expand Down Expand Up @@ -1270,4 +1280,4 @@ class EmailSettingsSendAsAliasFeed(gdata.data.GDFeed):

class EmailSettingsDelegationFeed(gdata.data.GDFeed):
"""Main feed containing a list of email delegation entries."""
entry = [EmailSettingsDelegation]
entry = [EmailSettingsDelegation]