def sync_subscriber( self, subscriber, subids = [], unsubids = [] ):
        assert IActiveCampaignSubscriber.providedBy(subscriber)

        params = dict(
            api_key=self.get_api_key(),
            api_action='subscriber_sync',
            api_output='json',
            email=subscriber.email,
            first_name=subscriber.first_name,
            last_name=subscriber.last_name,
        )

        params.update(
            self.get_formatted_fields('p', subids + unsubids, subids + unsubids)
        )
        params.update(
            self.get_formatted_fields('status', subids,
                                      [ACTIVE] * len(subids))
        )
        params.update(
            self.get_formatted_fields('status', unsubids,
                                      [UNSUBSCRIBED] * len(unsubids))
        )

        result = self.post_to_active_campaign(params)
        return result['result_code']
    def add_subscriber(self, subscriber, listids, custom_parameters=None):
        assert IActiveCampaignSubscriber.providedBy(subscriber)

        params = dict(
            api_key=self.get_api_key(),
            api_action='subscriber_add',
            api_output='json',
            email=subscriber.email,
            first_name=subscriber.first_name,
            last_name=subscriber.last_name,
        )
        # XXX WTF
        params.update(
            self.get_formatted_fields('p', listids, listids)
        )
        params.update(
            self.get_formatted_fields('status', listids,
                                      [ACTIVE] * len(listids))
        )

        if custom_parameters is not None:
            params.update(custom_parameters)

        result = self.post_to_active_campaign(params)
        return result['result_code']
    def edit_subscriber_email( self, subscriber, new_email ):
        assert IActiveCampaignSubscriber.providedBy(subscriber)

        params = dict(
            api_key=self.get_api_key(),
            api_action='subscriber_edit',
            api_output='json',
            overwrite = 0,
            id = subscriber.sid,
            email=new_email,
        )

        result = self.post_to_active_campaign(params)
        return result['result_code']