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


Python Util.active方法代码示例

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


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

示例1: stop

# 需要导入模块: from util import Util [as 别名]
# 或者: from util.Util import active [as 别名]
 def stop(self, params=None):
     if params is None:
         params = dict()
     if hasattr(self, 'lineitem_id'):
         params['lineitem_id'] = self.lineitem_id
         return Api.call('sales/stop_lineitem_recurring', params)
     elif hasattr(self, 'sale_id'):
         active_lineitems = Util.active(self)
         if dict(active_lineitems):
             result = dict()
             i = 0
             for k, v in active_lineitems.items():
                 lineitem_id = v
                 params = {'lineitem_id': lineitem_id}
                 result[i] = Api.call('sales/stop_lineitem_recurring', params)
                 i += 1
             response = { "response_code": "OK",
                          "response_message": str(len(result)) + " lineitems stopped successfully"
             }
         else:
             response = {
                 "response_code": "NOTICE",
                 "response_message": "No active recurring lineitems"
             }
     else:
         response = { "response_code": "NOTICE",
                       "response_message": "This method can only be called on a sale or lineitem"
         }
     return Sale(response)
开发者ID:2Checkout,项目名称:2checkout-python,代码行数:31,代码来源:sale.py

示例2: stop

# 需要导入模块: from util import Util [as 别名]
# 或者: from util.Util import active [as 别名]
 def stop(cls, params=None):
     if params is None:
         params = dict()
     if 'lineitem_id' in params:
         url = 'sales/stop_lineitem_recurring'
         return Api.call(url, params)
     elif 'sale_id' in params:
         url = 'sales/detail_sale'
         sale = Api.call(url, params)
         sale = json.loads(sale)
         if 'response_code' in sale:
             active_lineitems = Util.active(sale['sale']['invoices'])
             if dict(active_lineitems):
                 url = 'sales/stop_lineitem_recurring'
                 result = dict()
                 i = 0
                 for k, v in active_lineitems.items():
                     lineitem_id = v
                     params = {'lineitem_id': lineitem_id}
                     result[i] = Api.call(url, params)
                     i += 1
                 return json.dumps(result, sort_keys=True, indent=4)
             else:
                 return '{"response":{"code":"SUCCESS","message":"No active recurring lineitems"}}'
         else:
             return sale
     else:
         return '{"errors":{"code":"INVALID PARAMETER","message":"You must pass a sale_id or lineitem_id."}}'
开发者ID:2Checkout,项目名称:2checkout-python-tutorial,代码行数:30,代码来源:sale.py

示例3: active

# 需要导入模块: from util import Util [as 别名]
# 或者: from util.Util import active [as 别名]
 def active(self):
     active_lineitems = Util.active(self)
     if dict(active_lineitems):
         result = dict()
         i = 0
         for k, v in active_lineitems.items():
             lineitem_id = v
             result[i] = lineitem_id
             i += 1
         response = { "response_code": "ACTIVE",
                      "response_message": str(len(result)) + " active recurring lineitems"
         }
     else:
         response = {
             "response_code": "NOTICE","response_message":
             "No active recurring lineitems"
         }
     return Sale(response)
开发者ID:2Checkout,项目名称:2checkout-python,代码行数:20,代码来源:sale.py

示例4: active

# 需要导入模块: from util import Util [as 别名]
# 或者: from util.Util import active [as 别名]
 def active(cls, params=None):
     if params is None:
         params = dict()
     if 'sale_id' in params:
         url = 'sales/detail_sale'
         sale = Api.call(url, params)
         sale = json.loads(sale)
         if 'response_code' in sale:
             active_lineitems = Util.active(sale['sale']['invoices'])
         else:
             return sale
     else:
         return '{"errors":{"code":"INVALID PARAMETER","message":"You must pass a sale_id."}}'
     if dict(active_lineitems):
         response = active_lineitems
     else:
         response = '{"response":{"code":"SUCCESS","message":"No active reurring lineitems"}}'
     return response
开发者ID:2Checkout,项目名称:2checkout-python-tutorial,代码行数:20,代码来源:sale.py


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