Esempio n. 1
0
    def get(self, payment_id, **kwargs):
        """
        Args:
            detailed (bool)
            limit (int)
            offset (int)

        """
        filtering = {
            'filter_by': kwargs,
            'available': {
                'detailed':
                lambda x: Item.sanitize_bool_integer_value(
                    x, 'detailed', blank=True)
            }
        }

        request_data = {
            'url': self.URL,
            'payment_id': Item.sanitize_id(payment_id)
        }

        return self.transport.get() \
                   .set_pagination(**kwargs) \
                   .set_filtering(filtering) \
                   .request(**request_data)
Esempio n. 2
0
    def get(self, **kwargs):
        """
        Args:
            has_statement (bool)
            limit (int)
            offset (int)

        """
        filtering = {
            'filter_by': kwargs,
            'available': {
                'has_statement': lambda x: Item.sanitize_bool_integer_value(x, 'has_statement', blank=True)
            }
        }

        return self.transport.get() \
                   .set_pagination(**kwargs) \
                   .set_filtering(filtering) \
                   .request(url=self.URL)
Esempio n. 3
0
    def get(self, **kwargs):
        """
        Args:
            has_statement (bool)
            limit (int)
            offset (int)

        """
        filtering = {
            'filter_by': kwargs,
            'available': {
                'has_statement':
                lambda x: Item.sanitize_bool_integer_value(
                    x, 'has_statement', blank=True)
            }
        }

        return self.transport.get() \
                   .set_pagination(**kwargs) \
                   .set_filtering(filtering) \
                   .request(url=self.URL)
Esempio n. 4
0
    def get(self, **kwargs):
        """
        Args:
            website (int)
            active (bool)
            limit (int)
            offset (int)

        """
        filtering = {
            'filter_by': kwargs,
            'available': {
                'website': lambda x: Item.sanitize_integer_value(x, 'website', True),
                'active': lambda x: Item.sanitize_bool_integer_value(x, 'active', True)
            }
        }

        return self.transport.get() \
                   .set_pagination(**kwargs) \
                   .set_filtering(filtering) \
                   .request(url=self.URL)
Esempio n. 5
0
    def get(self, payment_id, **kwargs):
        """
        Args:
            detailed (bool)
            limit (int)
            offset (int)

        """
        filtering = {
            'filter_by': kwargs,
            'available': {
                'detailed': lambda x: Item.sanitize_bool_integer_value(x, 'detailed', blank=True)
            }
        }

        request_data = {
            'url': self.URL,
            'payment_id': Item.sanitize_id(payment_id)
        }

        return self.transport.get() \
                   .set_pagination(**kwargs) \
                   .set_filtering(filtering) \
                   .request(**request_data)
Esempio n. 6
0
class WebsitesManage(Item):
    """
    Manage websites

    """

    SCOPE = 'manage_websites'

    CREATE_URL = Item.prepare_url('website/create')
    UPDATE_URL = Item.prepare_url('website/update/%(website_id)s')
    VERIFY_URL = Item.prepare_url('website/verify/%(website_id)s')
    DELETE_URL = Item.prepare_url('website/delete/%(website_id)s')

    CREATE_FIELDS = {
        'name': lambda x: Item.sanitize_string_value(
            x, 'name', max_length=200),
        'kind': lambda x: Item.sanitize_string_value(
            x, 'kind', max_length=20),
        'language': lambda x: Item.sanitize_string_value(
            x, 'language', max_length=2),
        'adservice': lambda x: Item.sanitize_integer_value(
            x, 'adservice', blank=True),
        'site_url': lambda x: Item.sanitize_string_value(
            x, 'site_url', max_length=255),
        'description': lambda x: Item.sanitize_string_value(
            x, 'description', max_length=20000, min_length=100),
        'categories': lambda x: Item.sanitize_integer_array(
            x, 'categories'),
        'regions': lambda x: Item.sanitize_string_array(
            x, 'regions', max_length=2),
        'mailing_targeting': lambda x: Item.sanitize_bool_integer_value(
            x, 'mailing_targeting', blank=True)
    }

    UPDATE_FIELDS = {
        'name': lambda x: Item.sanitize_string_value(
            x, 'name', max_length=200, blank=True),
        'kind': lambda x: Item.sanitize_string_value(
            x, 'kind', max_length=20, blank=True),
        'language': lambda x: Item.sanitize_string_value(
            x, 'language', max_length=2, blank=True),
        'adservice': lambda x: Item.sanitize_integer_value(
            x, 'adservice', blank=True),
        'site_url': lambda x: Item.sanitize_string_value(
            x, 'site_url', max_length=255, blank=True),
        'description': lambda x: Item.sanitize_string_value(
            x, 'description', max_length=20000, min_length=100, blank=True),
        'categories': lambda x: Item.sanitize_integer_array(
            x, 'categories', blank=True),
        'regions': lambda x: Item.sanitize_string_array(
            x, 'regions', max_length=2, blank=True),
        'mailing_targeting': lambda x: Item.sanitize_bool_integer_value(
            x, 'mailing_targeting', blank=True)
    }

    def create(self, **kwargs):
        """
        Args:
            name (str)
            kind (str)
            language (str)
            adservice (int)
            site_url (str)
            description (str)
            categories (list of int)
            regions (list of str)
            mailing_targeting (bool)

        """
        data = Item.sanitize_fields(self.CREATE_FIELDS, **kwargs)

        return self.transport.post().set_data(data).request(url=self.CREATE_URL)

    def update(self, _id, **kwargs):
        """
        Args:
            _id (int)
            name (str)
            kind (str)
            language (str)
            adservice (int)
            site_url (str)
            description (str)
            categories (list of int)
            regions (list of str)
            mailing_targeting (bool)

        """
        data = Item.sanitize_fields(self.UPDATE_FIELDS, **kwargs)

        request_data = {
            'url': self.UPDATE_URL,
            'website_id': Item.sanitize_id(_id)
        }

        return self.transport.post().set_data(data).request(**request_data)

    def verify(self, _id):
        """
        Args:
            _id (int)

        """
        request_data = {
            'url': self.VERIFY_URL,
            'website_id': Item.sanitize_id(_id)
        }

        return self.transport.post().request(**request_data)

    def delete(self, _id):
        """
        Args:
            _id (int)

        """
        request_data = {
            'url': self.DELETE_URL,
            'website_id': Item.sanitize_id(_id)
        }

        return self.transport.post().request(**request_data)
Esempio n. 7
0
class RetagManager(Item):

    SCOPE = 'manage_webmaster_retag'

    CREATE_URL = Item.prepare_url('retag/create')
    UPDATE_URL = Item.prepare_url('retag/update/%(retag_id)s')
    DELETE_URL = Item.prepare_url('retag/delete/%(retag_id)s')

    CREATE_FIELDS = {
        'website': lambda x: Item.sanitize_integer_value(x, 'website'),
        'level': lambda x: Item.sanitize_integer_value(x, 'level'),
        'active': lambda x: Item.sanitize_bool_integer_value(x, 'active', blank=True),
        'script': lambda x: Item.sanitize_string_value(x, 'script'),
        'comment': lambda x: Item.sanitize_string_value(x, 'comment', blank=True),
    }

    UPDATE_FIELDS = {
        'level': lambda x: Item.sanitize_integer_value(x, 'level', blank=True),
        'active': lambda x: Item.sanitize_bool_integer_value(x, 'active', blank=True),
        'script': lambda x: Item.sanitize_string_value(x, 'script', blank=True),
        'comment': lambda x: Item.sanitize_string_value(x, 'comment', blank=True),
    }

    def create(self, **kwargs):
        """
        Args:
            website (int)
            level (int)
            active (bool)
            script (str)
            comment (str)

        """
        data = Item.sanitize_fields(self.CREATE_FIELDS, **kwargs)

        return self.transport.post().set_data(data).request(url=self.CREATE_URL)

    def update(self, retag_id, **kwargs):
        """
        Args:
            retag_id (int)
            level (int)
            active (bool)
            script (str)
            comment (str)

        """
        request_data = {
            'url': self.UPDATE_URL,
            'retag_id': Item.sanitize_id(retag_id)
        }

        data = Item.sanitize_fields(self.UPDATE_FIELDS, **kwargs)

        return self.transport.post().set_data(data).request(**request_data)

    def delete(self, retag_id):
        """
        Args:
            retag_id (int)

        """
        request_data = {
            'url': self.DELETE_URL,
            'retag_id': Item.sanitize_id(retag_id)
        }

        return self.transport.post().request(**request_data)