當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。