当前位置: 首页>>代码示例>>Python>>正文


Python Item.sanitize_fields方法代码示例

本文整理汇总了Python中admitad.items.base.Item.sanitize_fields方法的典型用法代码示例。如果您正苦于以下问题:Python Item.sanitize_fields方法的具体用法?Python Item.sanitize_fields怎么用?Python Item.sanitize_fields使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在admitad.items.base.Item的用法示例。


在下文中一共展示了Item.sanitize_fields方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: update

# 需要导入模块: from admitad.items.base import Item [as 别名]
# 或者: from admitad.items.base.Item import sanitize_fields [as 别名]
    def update(self, optcode_id, **kwargs):
        data = Item.sanitize_fields(self.UPDATE_FIELDS, **kwargs)
        request_data = {
            'url': self.UPDATE_URL,
            'optcode_id': Item.sanitize_id(optcode_id),
        }

        return self.transport.post().set_data(data).request(**request_data)
开发者ID:admitad,项目名称:admitad-python-api,代码行数:10,代码来源:optcodes.py

示例2: get

# 需要导入模块: from admitad.items.base import Item [as 别名]
# 或者: from admitad.items.base.Item import sanitize_fields [as 别名]
    def get(self, link, **kwargs):
        """
        Args:
            link (str)

        """
        data = Item.sanitize_fields(self.GET_FIELDS, link=link)

        return self.transport.get().set_data(data).request(url=self.URL)
开发者ID:admitad,项目名称:admitad-python-api,代码行数:11,代码来源:links.py

示例3: create

# 需要导入模块: from admitad.items.base import Item [as 别名]
# 或者: from admitad.items.base.Item import sanitize_fields [as 别名]
    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)
开发者ID:admitad,项目名称:admitad-python-api,代码行数:15,代码来源:retag.py

示例4: create

# 需要导入模块: from admitad.items.base import Item [as 别名]
# 或者: from admitad.items.base.Item import sanitize_fields [as 别名]
    def create(self, **kwargs):
        """
        Args:
            subject (str)
            text (str)
            campaign (int)
            category (int)
            priority (int)

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

        return self.transport.post().set_data(data).request(url=self.CREATE_URL)
开发者ID:admitad,项目名称:admitad-python-api,代码行数:15,代码来源:tickets.py

示例5: test_sanitize_fields

# 需要导入模块: from admitad.items.base import Item [as 别名]
# 或者: from admitad.items.base.Item import sanitize_fields [as 别名]
    def test_sanitize_fields(self):
        fields = {
            'field1': lambda x: Item.sanitize_non_blank_value(x, ''),
            'field2': lambda x: Item.sanitize_integer_value(x, ''),
            'field3': lambda x: Item.sanitize_string_value(x, '', blank=True),
        }

        data = Item.sanitize_fields(fields, field1='foobarbaz', field2=42, field3='')

        self.assertDictEqual(data, {
            'field1': 'foobarbaz',
            'field2': 42,
            'field3': ''
        })

        data = Item.sanitize_fields(fields, field1='foobarbaz', field2=42, field3='', field4='another')

        self.assertDictEqual(data, {
            'field1': 'foobarbaz',
            'field2': 42,
            'field3': ''
        })
开发者ID:admitad,项目名称:admitad-python-api,代码行数:24,代码来源:test_base.py

示例6: comment

# 需要导入模块: from admitad.items.base import Item [as 别名]
# 或者: from admitad.items.base.Item import sanitize_fields [as 别名]
    def comment(self, ticket_id, **kwargs):
        """
        Args:
            ticket_id (int)
            text (str)

        """
        request_data = {
            'url': self.COMMENT_URL,
            'ticket_id': Item.sanitize_id(ticket_id)
        }

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

        return self.transport.post().set_data(data).request(**request_data)
开发者ID:admitad,项目名称:admitad-python-api,代码行数:17,代码来源:tickets.py

示例7: create

# 需要导入模块: from admitad.items.base import Item [as 别名]
# 或者: from admitad.items.base.Item import sanitize_fields [as 别名]
    def create(self, attachments, **kwargs):
        """
        Args:
            attachments (list of str)
            campaign (int)
            website (int)
            order_id (str)
            order_date (date)
            order_price (float)
            appeal_id (str)
            comment (str)

        """
        data = Item.sanitize_fields(self.CREATE_FIELDS, **kwargs)
        files = [('attachment', open(item, 'rb')) for item in Item.sanitize_string_array(attachments, 'attachments')]

        return self.transport.post().set_data(data).set_files(files).request(url=self.CREATE_URL)
开发者ID:admitad,项目名称:admitad-python-api,代码行数:19,代码来源:lost_orders.py

示例8: create

# 需要导入模块: from admitad.items.base import Item [as 别名]
# 或者: from admitad.items.base.Item import sanitize_fields [as 别名]
    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)
开发者ID:admitad,项目名称:admitad-python-api,代码行数:19,代码来源:websites.py

示例9: create

# 需要导入模块: from admitad.items.base import Item [as 别名]
# 或者: from admitad.items.base.Item import sanitize_fields [as 别名]
    def create(self, website_id, campaign_id, **kwargs):
        """
        Args:
            website_id (int)
            campaign_id (int)
            ulp (list of str)
            subid (str)

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

        request_data = {
            'url': self.CREATE_URL,
            'website_id': Item.sanitize_id(website_id),
            'campaign_id': Item.sanitize_id(campaign_id),
        }

        return self.transport.get().set_data(data).request(**request_data)
开发者ID:admitad,项目名称:admitad-python-api,代码行数:20,代码来源:deeplinks.py

示例10: update

# 需要导入模块: from admitad.items.base import Item [as 别名]
# 或者: from admitad.items.base.Item import sanitize_fields [as 别名]
    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)
开发者ID:admitad,项目名称:admitad-python-api,代码行数:20,代码来源:retag.py

示例11: update

# 需要导入模块: from admitad.items.base import Item [as 别名]
# 或者: from admitad.items.base.Item import sanitize_fields [as 别名]
    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)
开发者ID:admitad,项目名称:admitad-python-api,代码行数:25,代码来源:websites.py

示例12: create

# 需要导入模块: from admitad.items.base import Item [as 别名]
# 或者: from admitad.items.base.Item import sanitize_fields [as 别名]
 def create(self, **kwargs):
     data = Item.sanitize_fields(self.CREATE_FIELDS, **kwargs)
     return self.transport.post().set_data(data).request(url=self.CREATE_URL)
开发者ID:admitad,项目名称:admitad-python-api,代码行数:5,代码来源:optcodes.py


注:本文中的admitad.items.base.Item.sanitize_fields方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。