本文整理汇总了Python中recurly.resource.Resource类的典型用法代码示例。如果您正苦于以下问题:Python Resource类的具体用法?Python Resource怎么用?Python Resource使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Resource类的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: refund_line_items_xml
def refund_line_items_xml(self, line_items):
elem = ElementTree.Element(self.nodename)
line_items_elem = ElementTree.Element('line_items')
for item in line_items:
adj_elem = ElementTree.Element('adjustment')
adj_elem.append(Resource.element_for_value('uuid',
item['adjustment'].uuid))
adj_elem.append(Resource.element_for_value('quantity',
item['quantity']))
adj_elem.append(Resource.element_for_value('prorate', item['prorate']))
line_items_elem.append(adj_elem)
elem.append(line_items_elem)
return elem
开发者ID:mgall,项目名称:recurly-client-python,代码行数:15,代码来源:__init__.py
示例2: generate
def generate(self, amount):
elem = ElementTree.Element(self.nodename)
elem.append(Resource.element_for_value('number_of_unique_codes', amount))
url = urljoin(self._url, '%s/generate' % (self.coupon_code, ))
body = ElementTree.tostring(elem, encoding='UTF-8')
response = self.http_request(url, 'POST', body, { 'Content-Type':
'application/xml; charset=utf-8' })
if response.status not in (200, 201, 204):
self.raise_http_error(response)
return Page.page_for_url(response.getheader('Location'))
开发者ID:carriercomm,项目名称:recurly-client-python,代码行数:14,代码来源:__init__.py
示例3: objects_for_push_notification
def objects_for_push_notification(notification):
"""Decode a push notification with the given body XML.
Returns a dictionary containing the constituent objects of the push
notification. The kind of push notification is given in the ``"type"``
member of the returned dictionary.
"""
notification_el = ElementTree.fromstring(notification)
objects = {'type': notification_el.tag}
for child_el in notification_el:
tag = child_el.tag
res = Resource.value_for_element(child_el)
objects[tag] = res
return objects
开发者ID:vnbang2003,项目名称:recurly-client-python,代码行数:15,代码来源:__init__.py
示例4: objects_for_push_notification
def objects_for_push_notification(notification):
"""Decode a push notification with the given body XML.
Returns a dictionary containing the constituent objects of the push
notification. The kind of push notification is given in the ``"type"``
member of the returned dictionary.
NOTE: Push notification object attributes do not match up one-to-one with
their Recurly Resource counterparts. Some attributes will be trimmed in this
process.
"""
notification_el = ElementTree.fromstring(notification)
objects = {'type': notification_el.tag}
for child_el in notification_el:
tag = child_el.tag
res = Resource.value_for_element(child_el)
objects[tag] = res
return objects
开发者ID:sprintly,项目名称:recurly-client-python,代码行数:18,代码来源:__init__.py
示例5: from_element
attributes = (
'message',
'created_at',
)
@classmethod
def from_element(cls, elem):
new_note = Note()
for child_el in elem:
if not child_el.tag:
continue
setattr(new_note, child_el.tag, child_el.text)
return new_note
Resource._learn_nodenames(locals().values())
def objects_for_push_notification(notification):
"""Decode a push notification with the given body XML.
Returns a dictionary containing the constituent objects of the push
notification. The kind of push notification is given in the ``"type"``
member of the returned dictionary.
"""
notification_el = ElementTree.fromstring(notification)
objects = {'type': notification_el.tag}
for child_el in notification_el:
tag = child_el.tag
res = Resource.value_for_element(child_el)
开发者ID:vnbang2003,项目名称:recurly-client-python,代码行数:30,代码来源:__init__.py
示例6: refund_open_amount_xml
def refund_open_amount_xml(self, amount_in_cents):
elem = ElementTree.Element(self.nodename)
elem.append(Resource.element_for_value('amount_in_cents',
amount_in_cents))
return elem
开发者ID:mgall,项目名称:recurly-client-python,代码行数:5,代码来源:__init__.py
注:本文中的recurly.resource.Resource类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论