本文整理汇总了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)
示例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)
示例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)
示例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)
示例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': ''
})
示例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)
示例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)
示例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)
示例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)
示例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)
示例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)
示例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)