I tried to save the record that already exists as an estimate on the portal as a PDF via API.
It is assumed that you understand the following articles. Learn more about the Bluemix Infrastructure (formerly SoftLayer) API.
ShinobiLayer: SoftLayer API Next Step: Data Type Object (1) --Qiita
I made a script to get the quote ID, so please use it.
getQuotes.py
#import package
import SoftLayer
import json
from prettytable import PrettyTable
# account info
client = SoftLayer.create_client_from_env()
objectmask = """
id,
name,
status,
createDate,
expirationDate,
order[
id,
orderTotalAmount
]
"""
# getActiveQuotes
gAQ = client['Account'].getActiveQuotes(mask=objectmask)
# define table
table = PrettyTable([
'QuoteID',
'Name',
'Amount',
'Status',
'createDate',
'expirationDate'
])
for key in range(len(gAQ)):
table.add_row([
gAQ[key]['id'],
gAQ[key]['name'],
gAQ[key]['order'].get('orderTotalAmount',""),
gAQ[key]['status'],
gAQ[key]['createDate'],
gAQ[key]['expirationDate']
])
print len(gAQ)
print table.get_string(sortby="QuoteID")
#Execution command
python getQuotes.py
#result
5
+---------+-------------+---------+---------+---------------------------+---------------------------+
| QuoteID | Name | Amount | Status | createDate | expirationDate |
+---------+-------------+---------+---------+---------------------------+---------------------------+
| 1111111 | BMS_28Cores | 1402.31 | PENDING | 2016-11-16T10:51:51+09:00 | 2017-02-14T10:51:51+09:00 |
...
I made a script that can be saved as a PDF by specifying QuoteId, so please use it.
getPdf.py
# beginning message
print 'Saving the quote as PDF ...'
# import
import SoftLayer
import sys
parm=sys.argv
quoteId=parm[1]
# account info
client = SoftLayer.create_client_from_env()
# getPdf as a binary data
getPdf = client['Billing_Order_Quote'].getPdf(id=quoteId)
# confirm as xmlrpclib.Binary
# print getPdf.__class__
# Save as a PDF
quoteFileName = "Quote_ID_%s.pdf" % quoteId
w = open(quoteFileName, "wb")
w.write(getPdf.data)
w.close()
# finishing message
print 'Completed!'
#Execution command
python getPdf.py 1111111
#result
Saving the quote as PDF ...
Completed!
#「Quote_ID_1111111.It will be saved as "pdf"