【问题标题】:SoftLayer API: How to get invoices using orderId as the inputSoftLayer API:如何使用 orderId 作为输入获取发票
【发布时间】:2016-04-15 21:23:47
【问题描述】:

SoftLayer API:如何获取一个特定订单的所有发票?

例如我下了三个订单:一个带有 orderId1 的月度虚拟服务器,一个带有 orderId2 的小时裸机服务器,一个带有 orderId3 的月度裸机服务器。

SoftLayer_Billing_Order-> getInitialInvoice() 可以返回我的一份订单的初始发票。

SoftLayer_Account->getInvoices 可以返回我所有的发票。每个 SoftLayer_Billing_Invoice 包含我所有三个订单的详细信息。

我正在尝试寻找一种 API,它可以只为一个订单返回发票。

例如,使用 orderId 作为输入参数从设备的每个计费周期中获取金额

有没有办法做到这一点?

谢谢。

【问题讨论】:

    标签: api ibm-cloud-infrastructure


    【解决方案1】:

    这是一个使用过滤器的python脚本

    import SoftLayer
    # For nice debug output:
    from pprint import pprint as pp
    
    API_USERNAME = 'set me'
    API_KEY = 'set me'
    
    
    filterInstance = {
      'invoices': {
        'items': {
          'billingItem': {
            'orderItem': {
              'order': {
                'id': {
                  'operation': 2901586
                }
              }
            }
          }
        }
      }
    }
    
    # Creates a new connection to the API service.
    client = SoftLayer.Client(
        username=API_USERNAME,
        api_key=API_KEY
    )
    
    try:
        result = client['SoftLayer_Account'].getInvoices( filter = filterInstance)
        pp(result)
    
    except SoftLayer.SoftLayerAPIError as e:
        pp('Failed ...  faultCode=%s, faultString=%s'
            % (e.faultCode, e.faultString))
    

    希望对你有帮助。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-09-14
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多